New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 660178 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Spaces/newlines before/after atomic inlines can offset text-align: center/right

Project Member Reported by danakj@chromium.org, Oct 27 2016

Issue description

In this fiddle: https://jsfiddle.net/4d5nmjs4/2/

The sides of the blue and red boxes should line up, but on Chrome the top blue row is offset.

The only difference between the blue and red boxes is a single newline.
 

Comment 1 by danakj@chromium.org, Mar 16 2017

Hey szager, should this get a different owner? It's been sitting for half a year

Comment 2 by szager@chromium.org, Mar 16 2017

Cc: kojii@chromium.org
Owner: e...@chromium.org
This is a line layout issue, adding some people who do more of that stuff.

Comment 3 by danakj@chromium.org, Mar 16 2017

Thanks!
Cc: -esprehn@chromium.org

Comment 5 by kojii@chromium.org, Mar 21 2017

Can repro with two consecutive spaces. So we probably measure collapsed spaces when we apply text-align.

Comment 6 by e...@chromium.org, Mar 21 2017

Status: Started (was: Assigned)
Thanks Koji!

Comment 7 by e...@chromium.org, Mar 27 2017

Cc: e...@chromium.org
Owner: ----
Status: Available (was: Started)
The problem appears to be that in updateLogicalWidthForAlignment the totalLogicalWidth has the width of an extra space yet, as the extra space is in the middle, there is no trailingSpaceRun.

Yet another reason that I'm happy that we're moving towards doing white-space collapsing as a separate stage in NG. As for fixing this bug we'd either need to ensure that the totalLogicalWidth passed into updateLogicalWidthForAlignment is the width *without* the extra space, or pass in a width of the extra spaces and subtract it.

Comment 8 by e...@chromium.org, Mar 27 2017

Owner: kojii@chromium.org
Status: Assigned (was: Available)

Comment 9 by kojii@chromium.org, Mar 29 2017

Summary: Spaces/newlines before/after atomic inlines can offset text-align: center/right (was: Newlines cause layout inaccuracies)
We seem to be measuring spaces both before and after replaced elements:
http://output.jsbin.com/yoluviy

* Reproduces on Safari. Edge/Gecko are fine.
* "-webkit-line-break: after-white-space" can workaround the problem.

Comment 10 by kojii@chromium.org, Mar 29 2017

Status: Started (was: Assigned)
Project Member

Comment 11 by bugdroid1@chromium.org, Mar 31 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1bdce8bacd54f2f8397939561e42822916c4fcb7

commit 1bdce8bacd54f2f8397939561e42822916c4fcb7
Author: kojii <kojii@chromium.org>
Date: Fri Mar 31 03:52:48 2017

Fix text-align: center/right when line wraps at atomic inline and spaces

LayoutBlockFlow::updateLogicalWidthForAlignment() requires
trailingSpaceRun to compute center/right alignment when line wraps at
atomic inline and spaces, but InlineBidiResolver computes
trailingSpaceRun only when UAX#9 L1 is needed. This patch fixes to
compute trailingSpaceRun also when text-align needs it.

The used value of text-align is saved in LineInfo to use later since it
is now computed earlier, and computing it is more than reading from
ComputedStyle.

Also turns soft-hyphen-4.html to a ref test.

BUG= 660178 

Review-Url: https://codereview.chromium.org/2786753002
Cr-Commit-Position: refs/heads/master@{#461018}

[modify] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/LayoutTests/TestExpectations
[add] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/LayoutTests/fast/css/text-align-img-expected.html
[add] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/LayoutTests/fast/css/text-align-img.html
[add] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/LayoutTests/fast/text/soft-hyphen-4-expected.html
[delete] https://crrev.com/f73bd477a4ec4815ddae1e9878fc283f1ec5c98f/third_party/WebKit/LayoutTests/fast/text/soft-hyphen-4-expected.txt
[delete] https://crrev.com/f73bd477a4ec4815ddae1e9878fc283f1ec5c98f/third_party/WebKit/LayoutTests/platform/linux/fast/text/soft-hyphen-4-expected.png
[delete] https://crrev.com/f73bd477a4ec4815ddae1e9878fc283f1ec5c98f/third_party/WebKit/LayoutTests/platform/mac/fast/text/soft-hyphen-4-expected.png
[delete] https://crrev.com/f73bd477a4ec4815ddae1e9878fc283f1ec5c98f/third_party/WebKit/LayoutTests/platform/win/fast/text/soft-hyphen-4-expected.png
[modify] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
[modify] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
[modify] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/Source/core/layout/line/InlineIterator.h
[modify] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/Source/core/layout/line/LineInfo.h
[modify] https://crrev.com/1bdce8bacd54f2f8397939561e42822916c4fcb7/third_party/WebKit/Source/platform/text/BidiResolver.h

Comment 13 by kojii@chromium.org, Mar 31 2017

Status: Fixed (was: Started)

Sign in to add a comment