Bug 125757 - Subpixel layout: Rounding padding vales pushes the content 1px off.
Summary: Subpixel layout: Rounding padding vales pushes the content 1px off.
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks: 126283
  Show dependency treegraph
 
Reported: 2013-12-15 12:22 PST by zalan
Modified: 2014-01-14 15:07 PST (History)
5 users (show)

See Also:


Attachments
test case (205 bytes, text/html)
2013-12-15 12:23 PST, zalan
no flags Details
screenshot(wikipedia) (304.78 KB, image/gif)
2013-12-19 17:00 PST, zalan
no flags Details
regressed test case (wikipedia) (139 bytes, text/html)
2013-12-19 17:01 PST, zalan
no flags Details
Testing FF's rendering. (118.77 KB, image/jpeg)
2014-01-14 15:06 PST, zalan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2013-12-15 12:22:46 PST
<html>
<head>
<style>
  body {
    font-size: 99%;
    padding-left: 0.5em;
  }
</style>
</head>
<body>This line is pushed to left by 1px. (body's padding-left is 0.5em with font-size: 99%.)</body>
</html>
Comment 1 zalan 2013-12-15 12:23:50 PST
Created attachment 219279 [details]
test case
Comment 2 zalan 2013-12-15 12:26:19 PST
<rdar://problem/15665134>
Comment 3 zalan 2013-12-16 14:31:54 PST
This is the result of clamping float values at LayoutUnit(float) to int when minimumValueForLength() is called.
computed minimum value: 6.8;
subpixel on: LayoutUnit value -> 435 (which eventually gets pixelsnapped to 7px)
subpixel off: LayoutUnit value -> 6 as the result of the clamping.
It mainly (most visibly) effects paddings and margins, but it can push pixels off by 1 at other places too (like with text-indent, width properties)

div {
    font-size: 99%;
    text-indent: 1em;
}


div {
    font-size: 99%;
    width: 1em;
    display: inline-block;
}
Comment 4 Simon Fraser (smfr) 2013-12-18 11:26:11 PST
I think it's OK to have a behavior change with subpixel when authors are using percentages. We should check Firefox behavior.
Comment 5 zalan 2013-12-19 17:00:45 PST
Created attachment 219704 [details]
screenshot(wikipedia)

Rounding these values would also regress some content including wikipedia.

<html>
<head>
<style>
  div {
    margin-top: -1.4em;
    margin-bottom: 1.4em 
  }
</style>
</head>
<body>
<div></div>
foo
</body>
</html>
Comment 6 zalan 2013-12-19 17:01:22 PST
Created attachment 219705 [details]
regressed test case (wikipedia)
Comment 7 zalan 2014-01-14 15:06:30 PST
Created attachment 221209 [details]
Testing FF's rendering.

The new off-by-one rendering matches FF's (v26.0) rendering. (top to bottom: subpixel on, FF, subpixel off)