Scrollbars are left in the wrong position when resizing a fixed layout view
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Apr 2015 06:37:15 +0000 (06:37 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Apr 2015 06:37:15 +0000 (06:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143360

Reviewed by Beth Dakin.

Test: fast/fixed-layout/fixed-layout.html

* platform/ScrollView.cpp:
(WebCore::ScrollView::setFrameRect):
Update scrollbars when the ScrollView frameRect changes. We were previously
depending on the layout that always happens after this to update scrollbars,
but with fixed layout mode, there won't be a layout! Also, FrameView's
setFrameRect override will sync this scrollbar update with the scrollbar
layers (via RenderLayerCompositor::frameViewDidChangeSize) immediately afterwards.

* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
Turn off fixed layout when resetting state.

(WebCore::Internals::setUseFixedLayout):
(WebCore::Internals::setFixedLayoutSize):
* testing/Internals.h:
* testing/Internals.idl:
Add internals functions to set the fixed layout size and to turn on fixed layout.

* fast/fixed-layout/fixed-layout-expected.png: Added.
* fast/fixed-layout/fixed-layout-expected.txt: Added.
* fast/fixed-layout/fixed-layout.html: Added.
Add a simple fixed layout test. We can add more (or recover some from
when the Qt tests were purged) now that it's testable again.

This test also happens to test the aforementioned setFrameRect change,
because without it, the RenderView's layer would be left at the wrong
size (800x600) because the scrollbars would be left behind in the resize.

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

LayoutTests/ChangeLog
LayoutTests/fast/fixed-layout/fixed-layout-expected.png [new file with mode: 0644]
LayoutTests/fast/fixed-layout/fixed-layout-expected.txt [new file with mode: 0644]
LayoutTests/fast/fixed-layout/fixed-layout.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index 5bd619d6229914e97324df30da41a1eb67cefae0..5ae0922bb929be5249391c5cb36913a88bff641c 100644 (file)
@@ -1,3 +1,20 @@
+2015-04-02  Timothy Horton  <timothy_horton@apple.com>
+
+        Scrollbars are left in the wrong position when resizing a fixed layout view
+        https://bugs.webkit.org/show_bug.cgi?id=143360
+
+        Reviewed by Beth Dakin.
+
+        * fast/fixed-layout/fixed-layout-expected.png: Added.
+        * fast/fixed-layout/fixed-layout-expected.txt: Added.
+        * fast/fixed-layout/fixed-layout.html: Added.
+        Add a simple fixed layout test. We can add more (or recover some from
+        when the Qt tests were purged) now that it's testable again.
+
+        This test also happens to test the aforementioned setFrameRect change,
+        because without it, the RenderView's layer would be left at the wrong
+        size (800x600) because the scrollbars would be left behind in the resize.
+
 2015-04-02  Brent Fulgham  <bfulgham@apple.com>
 
         New ruby tests are failing on all non-Mac platforms.
diff --git a/LayoutTests/fast/fixed-layout/fixed-layout-expected.png b/LayoutTests/fast/fixed-layout/fixed-layout-expected.png
new file mode 100644 (file)
index 0000000..783573b
Binary files /dev/null and b/LayoutTests/fast/fixed-layout/fixed-layout-expected.png differ
diff --git a/LayoutTests/fast/fixed-layout/fixed-layout-expected.txt b/LayoutTests/fast/fixed-layout/fixed-layout-expected.txt
new file mode 100644 (file)
index 0000000..183ccf4
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 400x400
+  RenderView at (0,0) size 400x400
+layer at (0,0) size 400x400
+  RenderBlock {HTML} at (0,0) size 400x400
+    RenderBody {BODY} at (0,0) size 400x400
+layer at (0,0) size 400x400
+  RenderBlock (positioned) {DIV} at (0,0) size 400x400 [bgcolor=#008000]
+layer at (0,0) size 100x100
+  RenderBlock (positioned) {DIV} at (0,0) size 100x100 [bgcolor=#0000FF]
diff --git a/LayoutTests/fast/fixed-layout/fixed-layout.html b/LayoutTests/fast/fixed-layout/fixed-layout.html
new file mode 100644 (file)
index 0000000..37a0414
--- /dev/null
@@ -0,0 +1,25 @@
+<head>
+<script>
+window.onload = function () {
+    if (!window.testRunner) {
+        document.write("Test cannot be run manually.");
+        return;
+    }
+
+    testRunner.waitUntilDone();
+
+    window.resizeTo(200, 200);
+
+    internals.setUseFixedLayout(true);
+    internals.setFixedLayoutSize(400, 400);
+
+    setTimeout(function () {
+        testRunner.notifyDone();
+    }, 0);
+}
+</script>
+</head>
+<body style="margin: 0;">
+<div style="width: 100%; height: 100%; position: absolute; background-color: green;"></div>
+<div style="width: 50vw; height: 50vh; position: absolute; background-color: blue;"></div>
+</body>
\ No newline at end of file
index c8496a834eca29c66482f01d5116ff6da36ec8eb..2408319ad2523202e6eae0f742a955db9e2c1b9d 100644 (file)
@@ -1,3 +1,30 @@
+2015-04-02  Timothy Horton  <timothy_horton@apple.com>
+
+        Scrollbars are left in the wrong position when resizing a fixed layout view
+        https://bugs.webkit.org/show_bug.cgi?id=143360
+
+        Reviewed by Beth Dakin.
+
+        Test: fast/fixed-layout/fixed-layout.html
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::setFrameRect):
+        Update scrollbars when the ScrollView frameRect changes. We were previously
+        depending on the layout that always happens after this to update scrollbars,
+        but with fixed layout mode, there won't be a layout! Also, FrameView's
+        setFrameRect override will sync this scrollbar update with the scrollbar
+        layers (via RenderLayerCompositor::frameViewDidChangeSize) immediately afterwards.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        Turn off fixed layout when resetting state.
+
+        (WebCore::Internals::setUseFixedLayout):
+        (WebCore::Internals::setFixedLayoutSize):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        Add internals functions to set the fixed layout size and to turn on fixed layout.
+
 2015-04-02  Brady Eidson  <beidson@apple.com>
 
         Unreviewed: Reapplied Change after rollout.
index 6bdc90e73f5e7cdec3d3bb6b3c0d899f29dada61..f97fb61487a65f33835161326438e33c75625249 100644 (file)
@@ -1053,6 +1053,8 @@ void ScrollView::setFrameRect(const IntRect& newRect)
 
     Widget::setFrameRect(newRect);
     frameRectsChanged();
+
+    updateScrollbars(scrollOffset());
     
     if (!m_useFixedLayout && oldRect.size() != newRect.size())
         availableContentSizeChanged(AvailableSizeChangeReason::AreaSizeChanged);
index 34b6845eb8936436f2bdc527b32d712559d3e898..30377faa88028fe7804bd3f80c55c4531b98b1eb 100644 (file)
@@ -294,6 +294,8 @@ void Internals::resetToConsistentState(Page* page)
         mainFrameView->setHeaderHeight(0);
         mainFrameView->setFooterHeight(0);
         page->setTopContentInset(0);
+        mainFrameView->setUseFixedLayout(false);
+        mainFrameView->setFixedLayoutSize(IntSize());
     }
 
     TextRun::setAllowsRoundingHacks(false);
@@ -1918,6 +1920,28 @@ void Internals::setPageZoomFactor(float zoomFactor, ExceptionCode& ec)
     frame->setPageZoomFactor(zoomFactor);
 }
 
+void Internals::setUseFixedLayout(bool useFixedLayout, ExceptionCode& ec)
+{
+    Document* document = contextDocument();
+    if (!document || !document->view()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+    FrameView* frameView = document->view();
+    frameView->setUseFixedLayout(useFixedLayout);
+}
+
+void Internals::setFixedLayoutSize(int width, int height, ExceptionCode& ec)
+{
+    Document* document = contextDocument();
+    if (!document || !document->view()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+    FrameView* frameView = document->view();
+    frameView->setFixedLayoutSize(IntSize(width, height));
+}
+
 void Internals::setHeaderHeight(float height)
 {
     Document* document = contextDocument();
index 71ff42e397c8955c4eca7833c0076d6a21958627..40c0ff6008cebb2bc8656b24644c65b722e98e31 100644 (file)
@@ -267,6 +267,9 @@ public:
     void setPageScaleFactor(float scaleFactor, int x, int y, ExceptionCode&);
     void setPageZoomFactor(float zoomFactor, ExceptionCode&);
 
+    void setUseFixedLayout(bool useFixedLayout, ExceptionCode&);
+    void setFixedLayoutSize(int width, int height, ExceptionCode&);
+
     void setHeaderHeight(float);
     void setFooterHeight(float);
 
index 11884f0f3fa0ccd6ba54eaed550811e4c5fc6f59..3834a5c124a53d2b30fc72669d582780b4c0db54 100644 (file)
@@ -241,6 +241,9 @@ enum ResourceLoadPriority {
     [RaisesException] void setPageScaleFactor(unrestricted float scaleFactor, long x, long y);
     [RaisesException] void setPageZoomFactor(unrestricted float zoomFactor);
 
+    [RaisesException] void setUseFixedLayout(boolean useFixedLayout);
+    [RaisesException] void setFixedLayoutSize(long width, long height);
+
     void setHeaderHeight(unrestricted float height);
     void setFooterHeight(unrestricted float height);