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

Issue 703969 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Equal fractional margin and padding don't cancel out on inline elements

Reported by laughing...@gmail.com, Mar 22 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3047.0 Safari/537.36

Steps to reproduce the problem:
1. Create an element with display inline
2. Give it a positive padding and a negative margin, both equal to a fraction of an em or ex, with that fraction not exactly representable in binary (say, padding:0.1, margin: -0.1 reproduces the bug, padding:0.5, margin:-0.5 behaves as expected)

What is the expected behavior?
Since the padding and margin are equal with opposite signs, we expect them to cancel out exactly.

Works in Firefox.

What went wrong?
The padding rounds down and the margin rounds up, creating (as far as we can tell) a 1px difference.

In the example, we expect the black and gray text to line up exactly (like they do in the inline-block example), but the gray text is offset by 2px relative to the black text.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 59.0.3047.0  Channel: canary
OS Version: OS X 10.11.6
Flash Version: 21.0.0.213
 
gistfile1.html
673 bytes View Download
Screen Shot 2017-03-21 at 19.10.00.png
29.1 KB View Download

Comment 1 by ajha@chromium.org, Mar 22 2017

Labels: Needs-Triage-M59
Cc: sureshkumari@chromium.org
Labels: Needs-Feedback
Unable to reproduce the issue on Windows-7,Mac-10.12.3 and Linux Ubuntu 14.04 using chrome stable version 57.0.2987.110 and canary 59.0.3047.0 with the steps mentioned in comment#0.
Observed same behavior in Firefox too.
Please find the attached screen cast and let us know if anything missed here to reproduce the issue.

Thanks.
703969.mov
3.1 MB Download
The problem is you zoomed in by 250% and 500%. I just now reproduced it at normal 100% zoom with Chrome Canary 59.0.3048.0 on Mac-10.12.3, and used the System Preferences > (sidebar) Zoom > "Use scroll gesture with modifier keys to zoom" feature to zoom into the words "blah blah" to the right of the span.

Another way this can be more noticeable is if JS is used to toggle `display: inline-block`, then everything to the right of the span shifts (this is how we discovered it). We figured JS would only complicate a test case for a CSS bug, but attached is a version with a button to toggle `display: inline-block`, and a video showing the "blah blah" on the right shifting when toggling the CSS (in Chrome Canary).
gistfile1.html
660 bytes View Download
screencap.mov
913 KB Download
Project Member

Comment 4 by sheriffbot@chromium.org, Mar 22 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "sureshkumari@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Actually, experimenting with the toggle so that it's noticeable, it varies by zoom level but can still happen at some large zoom levels:

- 100%: fairly noticeable
- 110%: even more noticeable
- 125%: doesn't happen
- 150%: barely noticeable
- 175%: fairly noticeable
- 200%: almost doesn't happen
- 250%: doesn't happen
- 300%: fairly noticeable
- 400%: barely noticeable
- 500%: doesn't happen

Comment 6 by kojii@chromium.org, Mar 22 2017

Status: Untriaged (was: Unconfirmed)
> The padding rounds down and the margin rounds up

We both round up, and that is probably the problem, we'll need to round down negative values, or in other words, round up in magnitude.
  -1.1 rounds up to -1
   1.1 rounds up to 2

trunc() rounds down in magnitude, but there's no standard function that rounds up in magnitude.
http://www.cplusplus.com/reference/cmath/trunc/

Comment 7 by kojii@chromium.org, Mar 22 2017

Labels: OS-Windows
and I can confirm on Windows.

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

LayoutUnit::round always rounds away from zero if I call correctly. Perhaps we can use that? Another option would be to branch on the sign, we do that in a couple of places.

Comment 9 by e...@chromium.org, Mar 28 2017

Cc: kojii@chromium.org e...@chromium.org
Status: Available (was: Untriaged)
Project Member

Comment 10 by sheriffbot@chromium.org, Apr 2 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 11 by e...@chromium.org, Apr 4 2018

Status: Available (was: Untriaged)

Sign in to add a comment