Log Message
localToAbsolute() does incorrect conversion for elements inside position:fixed with zooming https://bugs.webkit.org/show_bug.cgi?id=165244
Reviewed by Zalan Bujtas. Source/WebCore: RenderView::mapLocalToContainer() and RenderView::mapAbsoluteToLocalPoint() handle the coordinate mapping through the RenderView's transform (when zoomed), and apply the scroll offset for position:fixed elements. They did this in the wrong order; "local to absolute" applied the zoom scale, and then adjusted for the scroll position, and "absolute to local" applied the scroll position and then the transform. However that scroll position adjustment should be in unzoomed coordinates, since it's accounting for the layout adjustment that position:fixed receives (which actually occurs via the localToAbsolute() call in RenderLayer's accumulateOffsetTowardsAncestor()). "local to absolute" should therefore apply the scroll adjustment first before the transform, and "absolute to local" the reverse. In both visual viewport mode, and legacy drifty fixed mode FrameView::scrollPositionForFixedPosition() returns a scroll offset that is unaffected by zoom, which is correct and confirms this change. [Confusingly, ScrollView scroll positions _are_ affected by zoom, as the entire document gets bigger.] RenderGeometryMap::mapToContainer(), which is an optimization on top of RenderView::mapLocalToContainer(), gets a similar fix. Test: fast/zooming/client-rect-in-fixed-zoomed.html * rendering/RenderGeometryMap.cpp: (WebCore::RenderGeometryMap::mapToContainer): * rendering/RenderView.cpp: (WebCore::RenderView::mapLocalToContainer): (WebCore::RenderView::mapAbsoluteToLocalPoint): LayoutTests: Test getBoundingClientRect() (which internally calls localToAbsolute()) for an element inside position:fixed after zooming. * fast/visual-viewport/zoomed-fixed-expected.txt: Rebaseline * fast/zooming/client-rect-in-fixed-zoomed-expected.txt: Added. * fast/zooming/client-rect-in-fixed-zoomed.html: Added. * platform/ios-simulator/TestExpectations: Skip new test on iOS; test requires window.scrollTo to be synchronous.
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt
- trunk/LayoutTests/platform/ios-simulator/TestExpectations
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/rendering/RenderGeometryMap.cpp
- trunk/Source/WebCore/rendering/RenderView.cpp
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (209296 => 209297)
--- trunk/LayoutTests/ChangeLog 2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/LayoutTests/ChangeLog 2016-12-03 16:36:14 UTC (rev 209297)
@@ -1,3 +1,19 @@
+2016-11-30 Simon Fraser <[email protected]>
+
+ localToAbsolute() does incorrect conversion for elements inside position:fixed with zooming
+ https://bugs.webkit.org/show_bug.cgi?id=165244
+
+ Reviewed by Zalan Bujtas.
+
+ Test getBoundingClientRect() (which internally calls localToAbsolute())
+ for an element inside position:fixed after zooming.
+
+ * fast/visual-viewport/zoomed-fixed-expected.txt: Rebaseline
+ * fast/zooming/client-rect-in-fixed-zoomed-expected.txt: Added.
+ * fast/zooming/client-rect-in-fixed-zoomed.html: Added.
+ * platform/ios-simulator/TestExpectations: Skip new test on iOS; test requires window.scrollTo to be synchronous.
+
+
2016-12-02 Antoine Quint <[email protected]>
[Modern Media Controls] Update the media controls size as the media element is resized
Modified: trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt (209296 => 209297)
--- trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt 2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt 2016-12-03 16:36:14 UTC (rev 209297)
@@ -18,37 +18,37 @@
JSON.stringify(internals.layoutViewportRect()) is {"top":232.5,"right":867.5,"bottom":817.5,"left":82.5,"width":785,"height":585}
JSON.stringify(internals.visualViewportRect()) is {"top":525,"right":867.5,"bottom":817.5,"left":475,"width":392.5,"height":292.5}
client rect of top:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-408.75,"right":351.25,"bottom":-308.75,"left":-433.75,"width":785,"height":100}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-292.5,"right":392.5,"bottom":-192.5,"left":-392.5,"width":785,"height":100}
client rect of bottom:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":76.25,"right":351.25,"bottom":176.25,"left":-433.75,"width":785,"height":100}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":192.5,"right":392.5,"bottom":292.5,"left":-392.5,"width":785,"height":100}
client rect of left:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-408.75,"right":-333.75,"bottom":176.25,"left":-433.75,"width":100,"height":585}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-292.5,"right":-292.5,"bottom":292.5,"left":-392.5,"width":100,"height":585}
client rect of right:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-408.75,"right":351.25,"bottom":176.25,"left":251.25,"width":100,"height":585}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-292.5,"right":392.5,"bottom":292.5,"left":292.5,"width":100,"height":585}
Scrolled to 100, 776
JSON.stringify(internals.layoutViewportRect()) is {"top":483.5,"right":867.5,"bottom":1068.5,"left":82.5,"width":785,"height":585}
JSON.stringify(internals.visualViewportRect()) is {"top":776,"right":492.5,"bottom":1068.5,"left":100,"width":392.5,"height":292.5}
client rect of top:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-534.25,"right":726.25,"bottom":-434.25,"left":-58.75,"width":785,"height":100}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-292.5,"right":767.5,"bottom":-192.5,"left":-17.5,"width":785,"height":100}
client rect of bottom:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-49.25,"right":726.25,"bottom":50.75,"left":-58.75,"width":785,"height":100}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":192.5,"right":767.5,"bottom":292.5,"left":-17.5,"width":785,"height":100}
client rect of left:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-534.25,"right":41.25,"bottom":50.75,"left":-58.75,"width":100,"height":585}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-292.5,"right":82.5,"bottom":292.5,"left":-17.5,"width":100,"height":585}
client rect of right:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-534.25,"right":726.25,"bottom":50.75,"left":626.25,"width":100,"height":585}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-292.5,"right":767.5,"bottom":292.5,"left":667.5,"width":100,"height":585}
Scrolled to 50, 300
JSON.stringify(internals.layoutViewportRect()) is {"top":300,"right":835,"bottom":885,"left":50,"width":785,"height":585}
JSON.stringify(internals.visualViewportRect()) is {"top":300,"right":442.5,"bottom":592.5,"left":50,"width":392.5,"height":292.5}
client rect of top:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-150,"right":760,"bottom":-50,"left":-25,"width":785,"height":100}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":785,"bottom":100,"left":0,"width":785,"height":100}
client rect of bottom:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":335,"right":760,"bottom":435,"left":-25,"width":785,"height":100}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":485,"right":785,"bottom":585,"left":0,"width":785,"height":100}
client rect of left:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-150,"right":75,"bottom":435,"left":-25,"width":100,"height":585}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":100,"bottom":585,"left":0,"width":100,"height":585}
client rect of right:
-JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":-150,"right":760,"bottom":435,"left":660,"width":100,"height":585}
+JSON.stringify(fixedElement.getBoundingClientRect()) is {"top":0,"right":785,"bottom":585,"left":685,"width":100,"height":585}
PASS successfullyParsed is true
TEST COMPLETE
Added: trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed-expected.txt (0 => 209297)
--- trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed-expected.txt 2016-12-03 16:36:14 UTC (rev 209297)
@@ -0,0 +1,11 @@
+Tests localToAbsolute coordinate conversion for an element inside position:fixed after zoom.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.pageScaleFactor() is 2
+PASS JSON.stringify(clientRect) is JSON.stringify({top: 9.515625, right: 42, bottom: 19.515625, left: 22, width: 20, height: 10})
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed.html (0 => 209297)
--- trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed.html (rev 0)
+++ trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed.html 2016-12-03 16:36:14 UTC (rev 209297)
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+
+ .container {
+ position: fixed;
+ top: 20px;
+ left: 10px;
+ width: 200px;
+ height: 100px;
+ background-color: silver;
+ }
+ #box {
+ width: 20px;
+ height: 10px;
+ margin: 12px;
+ background-color: blue;
+ }
+
+ </style>
+ <script src=""
+ <script>
+ description("Tests localToAbsolute coordinate conversion for an element inside position:fixed after zoom.");
+
+ window.jsTestIsAsync = true;
+
+ var clientRect;
+ function doAfterZooming()
+ {
+ window.scrollTo(0, 140);
+
+ shouldBe('internals.pageScaleFactor()', '2');
+
+ var box = document.getElementById('box');
+ clientRect = box.getBoundingClientRect();
+
+ shouldBe('JSON.stringify(clientRect)', 'JSON.stringify({top: 9.515625, right: 42, bottom: 19.515625, left: 22, width: 20, height: 10})');
+
+ finishJSTest();
+ }
+
+ function getUIScript()
+ {
+ return `(function() {
+ uiController.zoomToScale(2, function() {
+ uiController.uiScriptComplete(uiController.zoomScale);
+ });
+ })();`;
+ }
+
+ function doTest()
+ {
+ if (window.testRunner) {
+ testRunner.runUIScript(getUIScript(), function(zoomScale) {
+ doAfterZooming();
+ })
+ } else
+ window.setTimeout(doAfterZooming, 1000);
+ }
+
+ window.addEventListener('load', doTest, false);
+ </script>
+</head>
+<body>
+ <div class="container">
+ <div id="box"></div>
+ </div>
+ <script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (209296 => 209297)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2016-12-03 16:36:14 UTC (rev 209297)
@@ -2764,3 +2764,6 @@
webkit.org/b/164594 http/tests/cache/disk-cache/disk-cache-request-headers.html [ Pass Timeout ]
webkit.org/b/163046 js/regress-141098.html [ Pass Failure ]
+
+# Test relies on window.scrollTo
+fast/zooming/client-rect-in-fixed-zoomed.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (209296 => 209297)
--- trunk/Source/WebCore/ChangeLog 2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/Source/WebCore/ChangeLog 2016-12-03 16:36:14 UTC (rev 209297)
@@ -1,3 +1,38 @@
+2016-11-30 Simon Fraser <[email protected]>
+
+ localToAbsolute() does incorrect conversion for elements inside position:fixed with zooming
+ https://bugs.webkit.org/show_bug.cgi?id=165244
+
+ Reviewed by Zalan Bujtas.
+
+ RenderView::mapLocalToContainer() and RenderView::mapAbsoluteToLocalPoint() handle the coordinate
+ mapping through the RenderView's transform (when zoomed), and apply the scroll offset for position:fixed
+ elements.
+
+ They did this in the wrong order; "local to absolute" applied the zoom scale, and then adjusted for the scroll position,
+ and "absolute to local" applied the scroll position and then the transform.
+
+ However that scroll position adjustment should be in unzoomed coordinates, since it's accounting for the
+ layout adjustment that position:fixed receives (which actually occurs via the localToAbsolute() call
+ in RenderLayer's accumulateOffsetTowardsAncestor()). "local to absolute" should therefore apply the scroll
+ adjustment first before the transform, and "absolute to local" the reverse.
+
+ In both visual viewport mode, and legacy drifty fixed mode FrameView::scrollPositionForFixedPosition()
+ returns a scroll offset that is unaffected by zoom, which is correct and confirms this change.
+
+ [Confusingly, ScrollView scroll positions _are_ affected by zoom, as the entire document gets bigger.]
+
+ RenderGeometryMap::mapToContainer(), which is an optimization on top of RenderView::mapLocalToContainer(),
+ gets a similar fix.
+
+ Test: fast/zooming/client-rect-in-fixed-zoomed.html
+
+ * rendering/RenderGeometryMap.cpp:
+ (WebCore::RenderGeometryMap::mapToContainer):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::mapLocalToContainer):
+ (WebCore::RenderView::mapAbsoluteToLocalPoint):
+
2016-12-02 Simon Fraser <[email protected]>
Put names on layers in release builds
Modified: trunk/Source/WebCore/rendering/RenderGeometryMap.cpp (209296 => 209297)
--- trunk/Source/WebCore/rendering/RenderGeometryMap.cpp 2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/Source/WebCore/rendering/RenderGeometryMap.cpp 2016-12-03 16:36:14 UTC (rev 209297)
@@ -81,13 +81,13 @@
inFixed = true;
if (!i) {
+ // The root gets special treatment for fixed position
+ if (inFixed)
+ transformState.move(currentStep.m_offset.width(), currentStep.m_offset.height());
+
// A null container indicates mapping through the RenderView, so including its transform (the page scale).
if (!container && currentStep.m_transform)
transformState.applyTransform(*currentStep.m_transform.get());
-
- // The root gets special treatment for fixed position
- if (inFixed)
- transformState.move(currentStep.m_offset.width(), currentStep.m_offset.height());
} else {
TransformState::TransformAccumulation accumulate = currentStep.m_accumulatingTransform ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
if (currentStep.m_transform)
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (209296 => 209297)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2016-12-03 16:36:14 UTC (rev 209297)
@@ -437,14 +437,14 @@
ASSERT_ARG(repaintContainer, !repaintContainer || repaintContainer == this);
ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == (mode & IsFixed));
+ if (mode & IsFixed)
+ transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
+
if (!repaintContainer && mode & UseTransforms && shouldUseTransformFromContainer(nullptr)) {
TransformationMatrix t;
getTransformFromContainer(nullptr, LayoutSize(), t);
transformState.applyTransform(t);
}
-
- if (mode & IsFixed)
- transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
}
const RenderObject* RenderView::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
@@ -467,14 +467,14 @@
void RenderView::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState& transformState) const
{
- if (mode & IsFixed)
- transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
-
if (mode & UseTransforms && shouldUseTransformFromContainer(nullptr)) {
TransformationMatrix t;
getTransformFromContainer(nullptr, LayoutSize(), t);
transformState.applyTransform(t);
}
+
+ if (mode & IsFixed)
+ transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
}
bool RenderView::requiresColumns(int) const
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
