Bug 125963 - Subpixel layout: RenderLineBreak/RenderInline/RenderBlock::baselinePosition return value needs flooring (apple.com).
Summary: Subpixel layout: RenderLineBreak/RenderInline/RenderBlock::baselinePosition r...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
Keywords: InRadar
Depends on:
Blocks: 126283
  Show dependency treegraph
Reported: 2013-12-18 16:44 PST by zalan
Modified: 2014-01-15 10:34 PST (History)
4 users (show)

See Also:

test case (152 bytes, text/html)
2013-12-18 16:44 PST, zalan
no flags Details
screenshots (293.13 KB, image/gif)
2013-12-18 19:36 PST, zalan
no flags Details
screenshot (apple.com) (277.08 KB, image/gif)
2013-12-19 15:35 PST, zalan
no flags Details
test case (apple.com) (273 bytes, text/html)
2013-12-19 15:53 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-18 16:44:29 PST
Created attachment 219589 [details]
test case

In RenderBlock::baselinePosition the baseline value is calculated as follows: font baseline + (lineHeight - fontHeight)/2
  return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;

The font metric values are CSS pixel values, lineHeight() returns LayoutUnit. While calculating the baseline, the CSS pixel values (font metrics) get converted to layout units  and at the end the result gets floored to CSS pixel value (return value). 
The floored return value can end up being different, if the /2 operation results in a negative value with fraction. 
subpixel on: ascent: 9px + offset: -0.5px = 8.5px -> 8px
subpixel off: ascent: 9px + offset: -0.5px -> 0px = 9px  

observed on cnn.com
Comment 1 zalan 2013-12-18 16:46:32 PST
Comment 2 zalan 2013-12-18 19:36:14 PST
Created attachment 219605 [details]

adding anim gif to demonstrate the off-by-one rendering.
Comment 3 zalan 2013-12-19 15:35:00 PST
Created attachment 219692 [details]
screenshot (apple.com)

RenderInline::baselinePosition has the exact same calculation as RenderBlock and the missing rounding shows up on apple.com (screenshot attached)
Comment 4 zalan 2013-12-19 15:53:07 PST
Created attachment 219694 [details]
test case (apple.com)
Comment 5 zalan 2013-12-23 13:38:45 PST
And by flooring, I meant bias vertical centering similar to bug 101848
Comment 6 zalan 2014-01-15 10:34:42 PST
The current subpixel rendering is closer to FF's rendering than it would be with the rounding (supbixel off in practice)