Bug 152142 - Browser zoom inconsistently scales box model properties
Summary: Browser zoom inconsistently scales box model properties
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Other
Hardware: Mac OS X 10.11
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-10 09:28 PST by Ben Mosher
Modified: 2015-12-10 10:54 PST (History)
2 users (show)

See Also:


Attachments
Reproduces issue (698 bytes, text/html)
2015-12-10 10:48 PST, Ben Mosher
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Mosher 2015-12-10 09:28:20 PST
Given a <div> containing <spans>, and given the CSS fragment

div > span {
  border: 1px solid blue;
  margin: -1px;
}

when zoomed to some level other than an integer multiple of 100% (200%, 300%) the width of the border does not appear to equal the width of the margin.

Specifically, in Chrome 48 (current Chrome beta at time of writing), at 110% zoom, the computed border-width is shown in devtools as 0.909px, as if the browser has divided out the zoom level from the border.

The computed border width continues to decrease until 200% zoom, at which point it reports 1px again.

It's not clear to me whether this is a Chromium issue or a WebKit issue (I'm not familiar enough with either to know where one ends and the other begins), so I apologize if I'm barking up the wrong tree. I see this same behavior in both Safari (El Capitan) and Firefox, though Firefox reports 1px as the computed value regardless of zoom level.

I assume the intent here is to avoid non-integer border width for a solid border, but it breaks my layout and results in layouts that are in conflict with my (albeit naive) knowledge of the CSS box model.

Thanks for your time. I did try to find duplicates, but nothing I saw addressed this specifically--apologies if I missed one.

Cheers,

--Ben Mosher
Comment 1 Simon Fraser (smfr) 2015-12-10 10:21:33 PST
Does this reproduce in Safari?
Comment 2 Ben Mosher 2015-12-10 10:48:32 PST
Created attachment 267115 [details]
Reproduces issue

Zooming in between 100% and 200%, note that the border boxes in the abs-positioned "overlay" div are not exactly around the front layer's spans.

Note: this actually works as expected on Safari 9. I will need to revisit my full example and see what's different. I did attempt to reproduce with the original (non-toy) application and it seemed to be broken as it is in Chrome (48) and Firefox (39).
Comment 3 Ben Mosher 2015-12-10 10:52:44 PST
Now that I take a second look at Safari, it does seem to scale border-width at the same rate as the margin, resulting in a correct layout. Sorry about that.

Does that imply it's a Chromium issue, then?
Comment 4 Simon Fraser (smfr) 2015-12-10 10:54:23 PST
It does! Please report in the Blink bug tracker.