Bug 125757

Summary: Subpixel layout: Rounding padding vales pushes the content 1px off.
Product: WebKit Reporter: zalan <zalan>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED INVALID    
Severity: Normal CC: hyatt, jonlee, koivisto, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 126283    
Attachments:
Description Flags
test case
none
screenshot(wikipedia)
none
regressed test case (wikipedia)
none
Testing FF's rendering. none

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)