- Revision
- 138036
- Author
- simon.fra...@apple.com
- Date
- 2012-12-18 10:07:56 -0800 (Tue, 18 Dec 2012)
Log Message
Fix position:-webkit-sticky behavior when zoomed
https://bugs.webkit.org/show_bug.cgi?id=105251
Reviewed by Dean Jackson.
Source/WebCore:
Position sticky elements were misplaced when stickily-constrained, under zooming.
The cause was that some of the functions used to compute sticky position
took page scale into account, and some did not.
Fix by using localToContainerQuad(..., view()) to compute RenderView-relative
quads, which avoids page scale, so all the constraints math is done ignoring
page scale. This also requires that we compute a scale-free viewport rect
in stickyPositionOffset().
Test: fast/css/sticky/sticky-top-zoomed.html
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::computeStickyPositionConstraints):
(WebCore::RenderBoxModelObject::stickyPositionOffset):
LayoutTests:
Ref test for sticky elements in a zoomed page.
This test is marked as failing for WK1, because scrollbars always show on
zoomed pages and cannot be hidden there.
* fast/css/sticky/sticky-top-zoomed-expected.html: Added.
* fast/css/sticky/sticky-top-zoomed.html: Added.
* platform/mac-wk2/TestExpectations:
* platform/mac/TestExpectations:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (138035 => 138036)
--- trunk/LayoutTests/ChangeLog 2012-12-18 18:06:09 UTC (rev 138035)
+++ trunk/LayoutTests/ChangeLog 2012-12-18 18:07:56 UTC (rev 138036)
@@ -1,3 +1,20 @@
+2012-12-17 Simon Fraser <simon.fra...@apple.com>
+
+ Fix position:-webkit-sticky behavior when zoomed
+ https://bugs.webkit.org/show_bug.cgi?id=105251
+
+ Reviewed by Dean Jackson.
+
+ Ref test for sticky elements in a zoomed page.
+
+ This test is marked as failing for WK1, because scrollbars always show on
+ zoomed pages and cannot be hidden there.
+
+ * fast/css/sticky/sticky-top-zoomed-expected.html: Added.
+ * fast/css/sticky/sticky-top-zoomed.html: Added.
+ * platform/mac-wk2/TestExpectations:
+ * platform/mac/TestExpectations:
+
2012-12-18 Thiago Marcos P. Santos <thiago.san...@intel.com>
[EFL] Unreviewed gardening.
Added: trunk/LayoutTests/fast/css/sticky/sticky-top-zoomed-expected.html (0 => 138036)
--- trunk/LayoutTests/fast/css/sticky/sticky-top-zoomed-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/sticky/sticky-top-zoomed-expected.html 2012-12-18 18:07:56 UTC (rev 138036)
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<style>
+ body {
+ margin: 0;
+ height: 2000px;
+ }
+
+ ::-webkit-scrollbar {
+ width: 0px;
+ height: 0px;
+ }
+
+ .group {
+ display: inline-block;
+ position: relative;
+ width: 160px;
+ height: 300px;
+ }
+
+ .container {
+ width: 150px;
+ height: 300px;
+ outline: 2px solid black;
+ }
+
+ .box {
+ width: 150px;
+ height: 150px;
+ }
+
+ .sticky {
+ position: -webkit-sticky;
+ top: 75px;
+ background-color: green;
+ }
+
+ .indicator {
+ position: absolute;
+ top: 0;
+ left: 0;
+ background-color: red;
+ }
+</style>
+<script>
+ function doTest()
+ {
+ if (window.eventSender)
+ eventSender.scalePageBy(1.5);
+ }
+ window.addEventListener('load', doTest, false);
+</script>
+</head>
+<body>
+ <div class="group" style="top: -100px">
+ <div class="indicator box" style="top: 150px;"></div>
+ <div class="container">
+ <div class="sticky box"></div>
+ </div>
+ </div>
+
+ <div class="group" style="top: 0">
+ <div class="indicator box" style="top: 75px;"></div>
+ <div class="container">
+ <div class="sticky box"></div>
+ </div>
+ </div>
+
+ <div class="group" style="top: 100px">
+ <div class="indicator box" style="top: 0;"></div>
+ <div class="container">
+ <div class="sticky box"></div>
+ </div>
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/sticky/sticky-top-zoomed.html (0 => 138036)
--- trunk/LayoutTests/fast/css/sticky/sticky-top-zoomed.html (rev 0)
+++ trunk/LayoutTests/fast/css/sticky/sticky-top-zoomed.html 2012-12-18 18:07:56 UTC (rev 138036)
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<style>
+ body {
+ margin: 0;
+ height: 2000px;
+ }
+
+ ::-webkit-scrollbar {
+ width: 0px;
+ height: 0px;
+ }
+
+ .group {
+ display: inline-block;
+ position: relative;
+ width: 160px;
+ height: 300px;
+ }
+
+ .container {
+ width: 150px;
+ height: 300px;
+ outline: 2px solid black;
+ }
+
+ .box {
+ width: 150px;
+ height: 150px;
+ }
+
+ .sticky {
+ position: -webkit-sticky;
+ top: 75px;
+ background-color: green;
+ }
+
+ .indicator {
+ position: absolute;
+ top: 0;
+ left: 0;
+ background-color: red;
+ }
+</style>
+<script>
+ function doTest()
+ {
+ if (window.eventSender)
+ eventSender.scalePageBy(1.5);
+
+ window.scrollTo(0, 100);
+ }
+ window.addEventListener('load', doTest, false);
+</script>
+</head>
+<body>
+ <div class="group">
+ <div class="indicator box" style="top: 150px;"></div>
+ <div class="container">
+ <div class="sticky box"></div>
+ </div>
+ </div>
+
+ <div class="group" style="top: 100px">
+ <div class="indicator box" style="top: 75px;"></div>
+ <div class="container">
+ <div class="sticky box"></div>
+ </div>
+ </div>
+
+ <div class="group" style="top: 200px">
+ <div class="indicator box" style="top: 0;"></div>
+ <div class="container">
+ <div class="sticky box"></div>
+ </div>
+ </div>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac/TestExpectations (138035 => 138036)
--- trunk/LayoutTests/platform/mac/TestExpectations 2012-12-18 18:06:09 UTC (rev 138035)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2012-12-18 18:07:56 UTC (rev 138036)
@@ -1216,6 +1216,9 @@
# TileCache tests that don't apply to WK1 (they are re-enabled via the WK2 TestExpectations file)
platform/mac/tiled-drawing/ [ Skip ]
+# Can't hide scrollbars in WK1
+fast/css/sticky/sticky-top-zoomed.html [ ImageOnlyFailure ]
+
webkit.org/b/100846 inspector-protocol/debugger-pause-dedicated-worker.html [ Skip ]
webkit.org/b/100846 inspector-protocol/debugger-terminate-dedicated-worker-while-paused.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (138035 => 138036)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2012-12-18 18:06:09 UTC (rev 138035)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2012-12-18 18:07:56 UTC (rev 138036)
@@ -362,6 +362,7 @@
### START OF (5) Features that are not supported in WebKit1, so skipped in mac/TestExpectations then re-enabled here
platform/mac/tiled-drawing/ [ Pass ]
+fast/css/sticky/sticky-top-zoomed.html [ Pass ]
### END OF (5) Features that are not supported in WebKit1, so skipped in mac/TestExpectations then re-enabled here
########################################
Modified: trunk/Source/WebCore/ChangeLog (138035 => 138036)
--- trunk/Source/WebCore/ChangeLog 2012-12-18 18:06:09 UTC (rev 138035)
+++ trunk/Source/WebCore/ChangeLog 2012-12-18 18:07:56 UTC (rev 138036)
@@ -1,3 +1,25 @@
+2012-12-17 Simon Fraser <simon.fra...@apple.com>
+
+ Fix position:-webkit-sticky behavior when zoomed
+ https://bugs.webkit.org/show_bug.cgi?id=105251
+
+ Reviewed by Dean Jackson.
+
+ Position sticky elements were misplaced when stickily-constrained, under zooming.
+ The cause was that some of the functions used to compute sticky position
+ took page scale into account, and some did not.
+
+ Fix by using localToContainerQuad(..., view()) to compute RenderView-relative
+ quads, which avoids page scale, so all the constraints math is done ignoring
+ page scale. This also requires that we compute a scale-free viewport rect
+ in stickyPositionOffset().
+
+ Test: fast/css/sticky/sticky-top-zoomed.html
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::computeStickyPositionConstraints):
+ (WebCore::RenderBoxModelObject::stickyPositionOffset):
+
2012-12-18 Eugene Klyuchnikov <eus...@chromium.org>
Web Inspector: DataGrid cell values are "clipped" in editing mode.
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (138035 => 138036)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2012-12-18 18:06:09 UTC (rev 138035)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2012-12-18 18:07:56 UTC (rev 138036)
@@ -471,7 +471,8 @@
// Compute the container-relative area within which the sticky element is allowed to move.
containerContentRect.move(minLeftMargin, minTopMargin);
containerContentRect.contract(minLeftMargin + minRightMargin, minTopMargin + minBottomMargin);
- constraints.setAbsoluteContainingBlockRect(containingBlock->localToAbsoluteQuad(FloatRect(containerContentRect)).boundingBox());
+ // Map to the view to avoid including page scale factor.
+ constraints.setAbsoluteContainingBlockRect(containingBlock->localToContainerQuad(FloatRect(containerContentRect), view()).boundingBox());
LayoutRect stickyBoxRect = frameRectForStickyPositioning();
LayoutRect flippedStickyBoxRect = stickyBoxRect;
@@ -479,7 +480,9 @@
LayoutPoint stickyLocation = flippedStickyBoxRect.location();
// FIXME: sucks to call localToAbsolute again, but we can't just offset from the previously computed rect if there are transforms.
- FloatRect absContainerFrame = containingBlock->localToAbsoluteQuad(FloatRect(FloatPoint(), containingBlock->size())).boundingBox();
+ // Map to the view to avoid including page scale factor.
+ FloatRect absContainerFrame = containingBlock->localToContainerQuad(FloatRect(FloatPoint(), containingBlock->size()), view()).boundingBox();
+
// We can't call localToAbsolute on |this| because that will recur. FIXME: For now, assume that |this| is not transformed.
FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocation, flippedStickyBoxRect.size());
constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect);
@@ -508,7 +511,12 @@
LayoutSize RenderBoxModelObject::stickyPositionOffset() const
{
LayoutRect viewportRect = view()->frameView()->visibleContentRect();
-
+ float scale = 1;
+ if (Frame* frame = view()->frameView()->frame())
+ scale = frame->frameScaleFactor();
+
+ viewportRect.scale(1 / scale);
+
StickyPositionViewportConstraints constraints;
computeStickyPositionConstraints(constraints, viewportRect);