haikuwebkit/LayoutTests/compositing/hidpi-box-positioned-off-by...

33 lines
744 B
HTML
Raw Permalink Normal View History

Subpixel rendering: RenderBox is positioned off by one when non-compositing transform is present. https://bugs.webkit.org/show_bug.cgi?id=130430 Reviewed by Simon Fraser. div { position: absolute; top: 10.25px; left: 10.25px; } The <div> with (10.25px, 10.25px) is painted to (10.5px, 10.5px) after device pixel snapping on 2x display. Moving <div> to its own RenderLayer should not change the painting position. div { position: absolute; top: 10.25px; left: 10.25px; -webkit-transform: rotate(0deg); } When we paint the RenderLayer's content, the graphics context is translated by the rounded value of renderer's offset from parent. (10.25px,10.25px) -> rounded to (10.5px,10.5px). When the translate moves the graphics context's origin over the renderer's top-left position, the renderer's relative top-left coordinates end up being negative. Graphics context translated by (10.5px,10.5px) -> pushes renderer's relative top-left coords to (-0.25px,-0.25px) When we round (pixel snap) these negative coordinates, half-way values get translated to the wrong direction. (relative coords (-0.25px,-0.25px) -> pixel snapped to (-0.5px,-0.5px) -> final absolute(painting) coords (10px,10px)) This patch changes the rounding to flooring to ensure that the relative top-left position never gets negative as the result of subpixel shifting. Source/WebCore: Tests: compositing/hidpi-box-positioned-off-by-one-when-non-compositing-transform-is-present.html fast/layers/hidpi-box-positioned-off-by-one-when-transform-is-present.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::computedTransform): * rendering/RenderLayer.cpp: (WebCore::RenderLayer::updateTransform): (WebCore::RenderLayer::currentTransform): (WebCore::RenderLayer::paintLayerByApplyingTransform): * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::updateTransform): * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: * svg/SVGTextElement.cpp: (WebCore::SVGTextElement::animatedLocalTransform): LayoutTests: * TestExpectations: * compositing/hidpi-box-positioned-off-by-one-when-non-compositing-transform-is-present-expected.html: Added. * compositing/hidpi-box-positioned-off-by-one-when-non-compositing-transform-is-present.html: Added. * fast/layers/hidpi-box-positioned-off-by-one-when-transform-is-present-expected.html: Added. * fast/layers/hidpi-box-positioned-off-by-one-when-transform-is-present.html: Added. Canonical link: https://commits.webkit.org/148601@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166060 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-03-21 13:55:40 +00:00
<!DOCTYPE html>
<html>
<head>
<title>This tests if flooring the transformed boxes' coordinates produce the same result as if compositing transform is present.</title>
<head>
<style>
div {
background: green;
width: 5px;
height: 5px;
position: absolute;
-webkit-transform: rotate(0deg);
}
</style>
</head>
<body>
<p id="container"></p>
<script>
var container = document.getElementById("container");
for (i = 0; i < 40; ++i) {
adjustment = 0.25;
for (j = 0; j < 40; ++j) {
var e = document.createElement("div");
e.style.top = (i * 5 + adjustment) + "px";
e.style.left = ( j * 5 + adjustment) + "px";
container.appendChild(e);
adjustment+=0.05;
}
}
</script>
</body>
</html>