Can't scroll iframe after toggling it to display:none and back
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Jan 2018 01:34:42 +0000 (01:34 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Jan 2018 01:34:42 +0000 (01:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181708
rdar://problem/13234778

Reviewed by Tim Horton.

Source/WebCore:

Nothing updated the FrameView's set of scrollable areas when a subframe came back from display:none.
Mirror the existing virtual removeChild() by making addChild() virtual, and using it to mark
the FrameView's scrollable area set as dirty.

Test: tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html

* page/FrameView.cpp:
(WebCore::FrameView::addChild):
* page/FrameView.h:
* platform/ScrollView.h:

LayoutTests:

* tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt: Added.
* tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt [new file with mode: 0644]
LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.h

index 9568fc9..cc7f99c 100644 (file)
@@ -1,3 +1,14 @@
+2018-01-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Can't scroll iframe after toggling it to display:none and back
+        https://bugs.webkit.org/show_bug.cgi?id=181708
+        rdar://problem/13234778
+
+        Reviewed by Tim Horton.
+
+        * tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt: Added.
+        * tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html: Added.
+
 2018-01-16  Jer Noble  <jer.noble@apple.com>
 
         Reset MediaSourcePrivateAVFObjC's m_sourceBufferWithSelectedVideo when the underlying SourceBufferPrivate is removed.
diff --git a/LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt b/LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt
new file mode 100644 (file)
index 0000000..2d37322
--- /dev/null
@@ -0,0 +1,5 @@
+
+before: 10, 10 - 310, 160
+after hide: 
+after show: 10, 10 - 310, 160
+
diff --git a/LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html b/LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html
new file mode 100644 (file)
index 0000000..32d1bfe
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/wheel-handler-region-helper.js"></script>
+<script>
+    if (window.testRunner)
+        testRunner.waitUntilDone();
+
+    function dumpRegion(prefix)
+    {
+        if (window.internals) {
+            var rects = window.internals.nonFastScrollableRects();
+            document.getElementById('output').textContent += prefix + rectsAsString(rects) + '\n';
+        }
+    }
+
+    function doTest()
+    {
+        var frame = document.getElementById('frame');
+        dumpRegion('before: ');
+        frame.style.display = 'none';
+        dumpRegion('after hide: ');
+        
+        setTimeout(function() {
+            frame.style.display = 'inline';
+            dumpRegion('after show: ');
+
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, 0);
+    }
+    window.addEventListener('load', doTest, false);
+</script>
+</head>
+<body>
+<iframe id="frame" srcdoc="<html><body style='width:1000px;height:1000px;'></body></html>"></iframe>
+<pre id="output"></pre>
+</body>
+</html>
+
index 288acf3..06da33d 100644 (file)
@@ -1,3 +1,22 @@
+2018-01-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Can't scroll iframe after toggling it to display:none and back
+        https://bugs.webkit.org/show_bug.cgi?id=181708
+        rdar://problem/13234778
+
+        Reviewed by Tim Horton.
+
+        Nothing updated the FrameView's set of scrollable areas when a subframe came back from display:none.
+        Mirror the existing virtual removeChild() by making addChild() virtual, and using it to mark
+        the FrameView's scrollable area set as dirty.
+
+        Test: tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::addChild):
+        * page/FrameView.h:
+        * platform/ScrollView.h:
+
 2018-01-16  Chris Dumez  <cdumez@apple.com>
 
         SWServerWorker::m_contextConnectionIdentifier may get out of date
index 8154ae1..211b37b 100644 (file)
@@ -4645,6 +4645,14 @@ void FrameView::sendScrollEvent()
 #endif
 }
 
+void FrameView::addChild(Widget& widget)
+{
+    if (is<FrameView>(widget))
+        addScrollableArea(&downcast<FrameView>(widget));
+
+    ScrollView::addChild(widget);
+}
+
 void FrameView::removeChild(Widget& widget)
 {
     if (is<FrameView>(widget))
index 4b4d639..05325c2 100644 (file)
@@ -521,7 +521,8 @@ public:
     bool containsScrollableArea(ScrollableArea*) const;
     const ScrollableAreaSet* scrollableAreas() const { return m_scrollableAreas.get(); }
 
-    void removeChild(Widget&) final;
+    WEBCORE_EXPORT void addChild(Widget&) final;
+    WEBCORE_EXPORT void removeChild(Widget&) final;
 
     // This function exists for ports that need to handle wheel events manually.
     // On Mac WebKit1 the underlying NSScrollView just does the scrolling, but on most other platforms
index a84bdff..6d1da5b 100644 (file)
@@ -87,8 +87,8 @@ public:
 
     // Functions for child manipulation and inspection.
     const HashSet<Ref<Widget>>& children() const { return m_children; }
-    WEBCORE_EXPORT void addChild(Widget&);
-    virtual void removeChild(Widget&);
+    WEBCORE_EXPORT virtual void addChild(Widget&);
+    WEBCORE_EXPORT virtual void removeChild(Widget&);
 
     // If the scroll view does not use a native widget, then it will have cross-platform Scrollbars. These functions
     // can be used to obtain those scrollbars.