LayoutUnit should round half consistently, not away from zero
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2013 20:21:57 +0000 (20:21 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2013 20:21:57 +0000 (20:21 +0000)
commit733919703a149e584280b1ce6af5dcd3f8234598
tree7a252bd50b389b16b9e802ce02bbc9510f69e495
parent250968b43d7de3978e43135898616e5d847ccef7
LayoutUnit should round half consistently, not away from zero
https://bugs.webkit.org/show_bug.cgi?id=107208

Reviewed by Eric Seidel.

Source/WebCore:

The current implementation of LayoutUnit::round() always rounds half away from zero. This can result in
a shift of 1 pixel moving an element aligned at a half-pixel by 2. This problem is particularly common with
RenderLayers, which pass the sub-pixel accumulation into their renderers after translating the graphics
context passed in by their rounded location. This changes round() to always round 0.5 up.

Test: fast/sub-pixel/sub-pixel-root-layer.html

* platform/LayoutUnit.h:
(WebCore::LayoutUnit::round): Always round 0.5 up.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintLayerContents): We no longer need to prevent rootLayers from passing in a
sub-pixel offset. This eliminates the shifting of elements when applying translateZ(0) or similar.

Tools:

* TestWebKitAPI/Tests/WebCore/LayoutUnit.cpp: Updating to reflect and
cover this change in rounding behavior.

LayoutTests:

* fast/sub-pixel/sub-pixel-root-layer-expected.html: Added.
* fast/sub-pixel/sub-pixel-root-layer.html: Added.
* platform/chromium-linux/fast/regions/overflow-moving-below-floats-in-variable-width-regions-expected.png:
* platform/chromium-linux/fast/regions/overflow-size-change-in-variable-width-regions-expected.png:
* platform/chromium-linux/fast/regions/overflow-size-change-with-stacking-context-expected.png:
* platform/chromium-win/fast/regions/overflow-moving-below-floats-in-variable-width-regions-expected.txt:
* platform/chromium-win/fast/regions/overflow-size-change-in-variable-width-regions-expected.txt:
* platform/chromium-win/fast/regions/overflow-size-change-with-stacking-context-expected.txt:
* platform/chromium/TestExpectations:
* platform/mac/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/sub-pixel/sub-pixel-root-layer-expected.html [new file with mode: 0644]
LayoutTests/fast/sub-pixel/sub-pixel-root-layer.html [new file with mode: 0644]
LayoutTests/platform/chromium-linux/fast/regions/overflow-moving-below-floats-in-variable-width-regions-expected.png
LayoutTests/platform/chromium-linux/fast/regions/overflow-size-change-in-variable-width-regions-expected.png
LayoutTests/platform/chromium-linux/fast/regions/overflow-size-change-with-stacking-context-expected.png
LayoutTests/platform/chromium-win/fast/regions/overflow-moving-below-floats-in-variable-width-regions-expected.txt
LayoutTests/platform/chromium-win/fast/regions/overflow-size-change-in-variable-width-regions-expected.txt
LayoutTests/platform/chromium-win/fast/regions/overflow-size-change-with-stacking-context-expected.txt
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/LayoutUnit.h
Source/WebCore/rendering/RenderLayer.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/LayoutUnit.cpp