Need to re-layout fixed position elements after scale when using settings()->fixedEle...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 05:04:24 +0000 (05:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 05:04:24 +0000 (05:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105486

Patch by Tien-Ren Chen <trchen@chromium.org> on 2013-02-27
Reviewed by James Robinson.

In settings()->fixedElementsLayoutRelativeToFrame() mode, fixed-position
elements are layout relative to the current visible viewport, which can
be different from the layout viewport when using fixed-layout mode.
We need to re-layout fixed-position elements in case of visible content
size changes.

The test is currently chromium-specific due to difficulties to make this
test works on Mac. The mac port seems to work very differently with
visible content size when a page is scaled. And there is no reliable way
to hide scrollbars in mac-wk1 that doesn't cause a side effect.

Source/WebCore:

Test: platform/chromium/fast/repaint/relayout-fixed-position-after-scale.html

* page/FrameView.h:
(FrameView):
* page/Page.cpp:
(WebCore::Page::setPageScaleFactor):

LayoutTests:

* platform/chromium/fast/repaint/relayout-fixed-position-after-scale-expected.html: Added.
* platform/chromium/fast/repaint/relayout-fixed-position-after-scale.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144260 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/chromium/fast/repaint/relayout-fixed-position-after-scale-expected.html [new file with mode: 0644]
LayoutTests/platform/chromium/fast/repaint/relayout-fixed-position-after-scale.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.h
Source/WebCore/page/Page.cpp

index 1d64ca8..c9078f1 100644 (file)
@@ -1,3 +1,24 @@
+2013-02-27  Tien-Ren Chen  <trchen@chromium.org>
+
+        Need to re-layout fixed position elements after scale when using settings()->fixedElementsLayoutRelativeToFrame()
+        https://bugs.webkit.org/show_bug.cgi?id=105486
+
+        Reviewed by James Robinson.
+
+        In settings()->fixedElementsLayoutRelativeToFrame() mode, fixed-position
+        elements are layout relative to the current visible viewport, which can
+        be different from the layout viewport when using fixed-layout mode.
+        We need to re-layout fixed-position elements in case of visible content
+        size changes.
+
+        The test is currently chromium-specific due to difficulties to make this
+        test works on Mac. The mac port seems to work very differently with
+        visible content size when a page is scaled. And there is no reliable way
+        to hide scrollbars in mac-wk1 that doesn't cause a side effect.
+
+        * platform/chromium/fast/repaint/relayout-fixed-position-after-scale-expected.html: Added.
+        * platform/chromium/fast/repaint/relayout-fixed-position-after-scale.html: Added.
+
 2013-02-27  Hans Muller  <hmuller@adobe.com>
 
         [CSS Exclusions] Enable shape-inside rectangle support for shape-padding
diff --git a/LayoutTests/platform/chromium/fast/repaint/relayout-fixed-position-after-scale-expected.html b/LayoutTests/platform/chromium/fast/repaint/relayout-fixed-position-after-scale-expected.html
new file mode 100644 (file)
index 0000000..8b5b803
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.fixed_size {
+    position:absolute;
+    background-color:#ccffcc;
+    width:25px;
+    height:25px;
+}
+.percentage_size {
+    position:absolute;
+    background-color:#ccccff;
+    width:10%;
+    height:10%;
+}
+</style>
+</head>
+<body style="width:800px;height:600px;margin:0;">
+<div class="fixed_size" style="left:5px;top:10px"></div>
+<div class="fixed_size" style="right:15px;top:20px"></div>
+<div class="fixed_size" style="left:25px;bottom:30px"></div>
+<div class="fixed_size" style="right:35px;bottom:40px"></div>
+<div class="percentage_size" style="left:40%;top:35%"></div>
+<div class="percentage_size" style="right:30%;top:25%"></div>
+<div class="percentage_size" style="left:20%;bottom:15%"></div>
+<div class="percentage_size" style="right:10%;bottom:5%"></div>
+</body>
+</html>
diff --git a/LayoutTests/platform/chromium/fast/repaint/relayout-fixed-position-after-scale.html b/LayoutTests/platform/chromium/fast/repaint/relayout-fixed-position-after-scale.html
new file mode 100644 (file)
index 0000000..024ec65
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This test is successful if fixed position elements re-layout correctly on page scale changes</title>
+<style>
+.fixed_size {
+    position:fixed;
+    background-color:#ccffcc;
+    width:50px;
+    height:50px;
+}
+.percentage_size {
+    position:fixed;
+    background-color:#ccccff;
+    width:10%;
+    height:10%;
+}
+</style>
+</head>
+<body onload="runTest();" style="width:1600px;height:1200px;margin:0;">
+<div class="fixed_size" style="left:10px;top:20px"></div>
+<div class="fixed_size" style="right:30px;top:40px"></div>
+<div class="fixed_size" style="left:50px;bottom:60px"></div>
+<div class="fixed_size" style="right:70px;bottom:80px"></div>
+<div class="percentage_size" style="left:40%;top:35%"></div>
+<div class="percentage_size" style="right:30%;top:25%"></div>
+<div class="percentage_size" style="left:20%;bottom:15%"></div>
+<div class="percentage_size" style="right:10%;bottom:5%"></div>
+<script>
+function runTest() {
+    if (window.internals) {
+        window.internals.settings.setFixedElementsLayoutRelativeToFrame(true);
+
+        // Force scrollbar to hide and re-layout immediately.
+        window.internals.setPageScaleFactor(0.1, 0, 0);
+        document.body.offsetTop;
+
+        window.internals.setPageScaleFactor(0.5, 0, 0);
+    }
+}
+</script>
+</body>
+</html>
index 4b8f0b9..9725521 100644 (file)
@@ -1,3 +1,28 @@
+2013-02-27  Tien-Ren Chen  <trchen@chromium.org>
+
+        Need to re-layout fixed position elements after scale when using settings()->fixedElementsLayoutRelativeToFrame()
+        https://bugs.webkit.org/show_bug.cgi?id=105486
+
+        Reviewed by James Robinson.
+
+        In settings()->fixedElementsLayoutRelativeToFrame() mode, fixed-position
+        elements are layout relative to the current visible viewport, which can
+        be different from the layout viewport when using fixed-layout mode.
+        We need to re-layout fixed-position elements in case of visible content
+        size changes.
+
+        The test is currently chromium-specific due to difficulties to make this
+        test works on Mac. The mac port seems to work very differently with
+        visible content size when a page is scaled. And there is no reliable way
+        to hide scrollbars in mac-wk1 that doesn't cause a side effect.
+
+        Test: platform/chromium/fast/repaint/relayout-fixed-position-after-scale.html
+
+        * page/FrameView.h:
+        (FrameView):
+        * page/Page.cpp:
+        (WebCore::Page::setPageScaleFactor):
+
 2013-02-27  Hans Muller  <hmuller@adobe.com>
 
         [CSS Exclusions] Enable shape-inside rectangle support for shape-padding
index cc9f1a8..c061838 100644 (file)
@@ -111,6 +111,7 @@ public:
 
     bool needsLayout() const;
     void setNeedsLayout();
+    void setViewportConstrainedObjectsNeedLayout();
 
     bool needsFullRepaint() const { return m_doFullRepaint; }
 
@@ -486,8 +487,6 @@ private:
 
     bool doLayoutWithFrameFlattening(bool allowSubtree);
 
-    void setViewportConstrainedObjectsNeedLayout();
-
     virtual AXObjectCache* axObjectCache() const;
     void notifyWidgetsInAllFrames(WidgetNotification);
     void removeFromAXObjectCache();
index bff8dcd..c4afff8 100644 (file)
@@ -749,6 +749,9 @@ void Page::setPageScaleFactor(float scale, const IntPoint& origin)
     mainFrame()->deviceOrPageScaleFactorChanged();
 #endif
 
+    if (view && view->fixedElementsLayoutRelativeToFrame())
+        view->setViewportConstrainedObjectsNeedLayout();
+
     if (view && view->scrollPosition() != origin) {
         if (!m_settings->applyPageScaleFactorInCompositor() && document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
             view->layout();