Title: [240249] trunk
Revision
240249
Author
an...@apple.com
Date
2019-01-21 22:50:49 -0800 (Mon, 21 Jan 2019)

Log Message

[iOS] Handle hit testing for subframes
https://bugs.webkit.org/show_bug.cgi?id=192303

Reviewed by Frédéric Wang.

Source/WebCore:

Don't set delegatesScrolling bit for subframes on iOS. It is meant for top level application
controlled scrolling. This fixes coordinate conversions for subframes and makes events work.

Test by Frederic Wang.

Test: fast/scrolling/ios/hit-testing-iframe.html

* platform/ScrollView.cpp:
(WebCore::ScrollView::managesScrollbars const):

Add a function that tells if the scrollview should deal with scrollbars at all
This is always false on iOS and not connected to delegatesScrolling bit.

(WebCore::ScrollView::updateScrollbars):
* platform/ScrollView.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::shouldCompositeOverflowControls const):

Source/WebKit:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):

Only set delegatesScrolling for the main frame.

LayoutTests:

Test by Frederic Wang.

* fast/scrolling/ios/hit-testing-iframe-expected.html: Added.
* fast/scrolling/ios/hit-testing-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (240248 => 240249)


--- trunk/LayoutTests/ChangeLog	2019-01-22 05:28:35 UTC (rev 240248)
+++ trunk/LayoutTests/ChangeLog	2019-01-22 06:50:49 UTC (rev 240249)
@@ -1,3 +1,15 @@
+2019-01-21  Antti Koivisto  <an...@apple.com>
+
+        [iOS] Handle hit testing for subframes
+        https://bugs.webkit.org/show_bug.cgi?id=192303
+
+        Reviewed by Frédéric Wang.
+
+        Test by Frederic Wang.
+
+        * fast/scrolling/ios/hit-testing-iframe-expected.html: Added.
+        * fast/scrolling/ios/hit-testing-iframe.html: Added.
+
 2019-01-21  Zalan Bujtas  <za...@apple.com>
 
         [LFC][Floats] Take float top position into account when computing containing block height.

Added: trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-expected.html (0 => 240249)


--- trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-expected.html	2019-01-22 06:50:49 UTC (rev 240249)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html
+  <head>
+    <title>Hit testing of iframe</title>
+  </head>
+  <body>
+    <p>This test passes if you see a green rectangle.</p>
+    <div style="position: absolute; top: 3em; width: 300px; height: 200px; background: green;">
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe.html (0 => 240249)


--- trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe.html	2019-01-22 06:50:49 UTC (rev 240249)
@@ -0,0 +1,108 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Hit testing of iframe</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <script src=""
+    <script type="text/_javascript_">
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+        if (window.internals)
+            internals.settings.setAsyncFrameScrollingEnabled(true);
+
+      function frameBox(id)
+      {
+          return document.getElementById(id).getBoundingClientRect();
+      }
+
+      function waitPromise(delay)
+      {
+          return new Promise((resolve) => { setTimeout(resolve, delay); });
+      }
+
+      async function runTest() {
+         if (!window.testRunner || !testRunner.runUIScript)
+             return;
+
+         // This verifies whether the iframe handles clicks inside or ouside its content box.
+         var p = frameBox("clickInContentBox");
+         await tapAtPoint(p.left + 7, p.top + 7);
+         p = frameBox("clickInPaddingBoxOutOfContentBox");
+         await tapAtPoint(p.left + 3, p.top + 3);
+
+         // This verifies that a click event is consumed by the element on top the frame.
+         p = frameBox("clickElementAboveFrame");
+         await tapAtPoint(p.left + 50, p.top + 50);
+
+         // This verifies that a click event is consumed by an element inside the frame.
+         p = frameBox("clickElementInsideFrame");
+         await tapAtPoint(p.left + 7 + 10, p.top + 7 + 10);
+
+         // This verifies that a click event is consumed by an element inside the frame, after a user scroll.
+         p = frameBox("clickElementInsideFrameAfterUserScroll");
+         await touchAndDragFromPointToPoint(p.left + 7, p.top + 7, p.left + 7, p.top - 150);
+         await liftUpAtPoint(p.left + 7, p.top - 150);
+         await waitPromise(1500); // Wait for scrolling to stabilize and for scrollbars to disappear.
+         await tapAtPoint(p.left + 7 + 10, p.bottom - 7);
+         await waitPromise(100);
+
+         testRunner.notifyDone();
+       }
+
+       var frameToLoadCount = 5;
+       function newFrameLoaded() {
+           frameToLoadCount--;
+           if (frameToLoadCount == 0)
+               runTest();
+       }
+    </script>
+    <style>
+        iframe {
+            position: absolute;
+            height: 90px;
+            width: 90px;
+            overflow: none;
+            margin: 0;
+            border: 0;
+            padding: 5px;
+        }
+    </style>
+  </head>
+  <body>
+    <p>This test passes if you see a green rectangle.</p>
+    <div style="position: absolute; top: 3em; width: 300px; height: 200px; background: green;">
+      <iframe id="clickInContentBox" style="left: 0px; top: 0px;" scrolling="yes" _onclick_="this.style.background=''" srcdoc="
+          <body style='margin: 0; width: 200px; height: 200px'>
+              <div style='position: absolute; width: 100px; height: 100px; background: red;'
+                   _onclick_='this.style.background=""
+          </body>" _onload_="newFrameLoaded()">
+      </iframe>
+      <iframe id="clickInPaddingBoxOutOfContentBox" style="left: 100px; top: 0px; background: red;" _onclick_="this.style.background=''" scrolling="yes" srcdoc="
+          <body style='margin: 0; width: 200px; height: 200px'>
+              <div style='position: absolute; width: 100px; height: 100px; background: green;'
+                   _onclick_='this.style.background=""
+          </body>" _onload_="newFrameLoaded()">
+      </iframe>
+      <iframe id="clickElementAboveFrame" style="left: 200px; top: 0px;" scrolling="yes" _onclick_="this.style.background=''" srcdoc="
+          <body style='margin: 0; width: 200px; height: 200px; background: green;'>
+              <div style='position: absolute; width: 100px; height: 100px; background: green;'
+                   _onclick_='this.style.background=""
+          </body>" _onload_="newFrameLoaded()">
+      </iframe>
+      <div style="position: absolute; width: 50px; height: 50px; left: 225px; top: 25px; background: red" _onclick_="this.style.background='';"></div>
+      <iframe id="clickElementInsideFrame" style="left: 0px; top: 100px;" scrolling="yes" _onclick_="this.style.background=''" srcdoc="
+          <body style='margin: 0; width: 200px; height: 200px; background: green;'>
+              <div style='position: absolute; left: 10px; top: 10px; width: 50px; height: 50px; background: red;'
+                   _onclick_='this.style.background=""
+          </body>" _onload_="newFrameLoaded()">
+      </iframe>
+      <iframe id="clickElementInsideFrameAfterUserScroll" style="left: 100px; top: 100px;" scrolling="yes" _onclick_="this.style.background=''" srcdoc="
+          <body style='margin: 0; width: 200px; height: 200px; background: green;'>
+             <div style='position: absolute; width: 75px; height: 75px; background: red;'></div>
+              <div style='position: absolute; left: 0px; top: 150px; width: 50px; height: 50px; background: red;'
+                   _onclick_='this.style.background=""
+          </body>" _onload_="newFrameLoaded()">
+      </iframe>
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (240248 => 240249)


--- trunk/Source/WebCore/ChangeLog	2019-01-22 05:28:35 UTC (rev 240248)
+++ trunk/Source/WebCore/ChangeLog	2019-01-22 06:50:49 UTC (rev 240249)
@@ -1,3 +1,28 @@
+2019-01-21  Antti Koivisto  <an...@apple.com>
+
+        [iOS] Handle hit testing for subframes
+        https://bugs.webkit.org/show_bug.cgi?id=192303
+
+        Reviewed by Frédéric Wang.
+
+        Don't set delegatesScrolling bit for subframes on iOS. It is meant for top level application
+        controlled scrolling. This fixes coordinate conversions for subframes and makes events work.
+
+        Test by Frederic Wang.
+
+        Test: fast/scrolling/ios/hit-testing-iframe.html
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::managesScrollbars const):
+
+        Add a function that tells if the scrollview should deal with scrollbars at all
+        This is always false on iOS and not connected to delegatesScrolling bit.
+
+        (WebCore::ScrollView::updateScrollbars):
+        * platform/ScrollView.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::shouldCompositeOverflowControls const):
+
 2019-01-21  Brent Fulgham  <bfulg...@apple.com>
 
         Implement message handlers for NetworkProcess-based ResourceLoadStatistics

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (240248 => 240249)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2019-01-22 05:28:35 UTC (rev 240248)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2019-01-22 06:50:49 UTC (rev 240249)
@@ -542,6 +542,19 @@
     return stretch;
 }
 
+bool ScrollView::managesScrollbars() const
+{
+#if PLATFORM(IOS_FAMILY)
+    return false;
+#else
+    if (platformWidget())
+        return false;
+    if (delegatesScrolling())
+        return false;
+    return true;
+#endif
+}
+
 void ScrollView::updateScrollbars(const ScrollPosition& desiredPosition)
 {
     LOG_WITH_STREAM(Scrolling, stream << "ScrollView::updateScrollbars " << desiredPosition);
@@ -549,7 +562,7 @@
     if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget())
         return;
     
-    if (delegatesScrolling()) {
+    if (!managesScrollbars()) {
         if (scrollOriginChanged()) {
             ScrollableArea::scrollToOffsetWithoutAnimation(scrollOffsetFromPosition(desiredPosition));
             resetScrollOriginChanged();

Modified: trunk/Source/WebCore/platform/ScrollView.h (240248 => 240249)


--- trunk/Source/WebCore/platform/ScrollView.h	2019-01-22 05:28:35 UTC (rev 240248)
+++ trunk/Source/WebCore/platform/ScrollView.h	2019-01-22 06:50:49 UTC (rev 240249)
@@ -378,6 +378,8 @@
     void setAllowsUnclampedScrollPositionForTesting(bool allowsUnclampedScrollPosition) { m_allowsUnclampedScrollPosition = allowsUnclampedScrollPosition; }
     bool allowsUnclampedScrollPosition() const { return m_allowsUnclampedScrollPosition; }
 
+    bool managesScrollbars() const;
+
 protected:
     ScrollView();
 

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (240248 => 240249)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2019-01-22 05:28:35 UTC (rev 240248)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2019-01-22 06:50:49 UTC (rev 240249)
@@ -3007,12 +3007,9 @@
 {
     auto& frameView = m_renderView.frameView();
 
-    if (frameView.platformWidget())
+    if (!frameView.managesScrollbars())
         return false;
 
-    if (frameView.delegatesScrolling())
-        return false;
-
     if (documentUsesTiledBacking())
         return true;
 

Modified: trunk/Source/WebKit/ChangeLog (240248 => 240249)


--- trunk/Source/WebKit/ChangeLog	2019-01-22 05:28:35 UTC (rev 240248)
+++ trunk/Source/WebKit/ChangeLog	2019-01-22 06:50:49 UTC (rev 240249)
@@ -1,3 +1,15 @@
+2019-01-21  Antti Koivisto  <an...@apple.com>
+
+        [iOS] Handle hit testing for subframes
+        https://bugs.webkit.org/show_bug.cgi?id=192303
+
+        Reviewed by Frédéric Wang.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
+
+        Only set delegatesScrolling for the main frame.
+
 2019-01-21  Brent Fulgham  <bfulg...@apple.com>
 
         Unreviewed test fix after r240243

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (240248 => 240249)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2019-01-22 05:28:35 UTC (rev 240248)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2019-01-22 06:50:49 UTC (rev 240249)
@@ -1439,7 +1439,8 @@
     m_frame->coreFrame()->view()->setViewExposedRect(webPage->drawingArea()->viewExposedRect());
 #endif
 #if PLATFORM(IOS_FAMILY)
-    m_frame->coreFrame()->view()->setDelegatesScrolling(true);
+    if (isMainFrame)
+        m_frame->coreFrame()->view()->setDelegatesScrolling(true);
 #endif
 
     if (webPage->scrollPinningBehavior() != DoNotPin)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to