Title: [214589] trunk
Revision
214589
Author
simon.fra...@apple.com
Date
2017-03-29 18:31:53 -0700 (Wed, 29 Mar 2017)

Log Message

Make it possible to dump touch event regions for testing
https://bugs.webkit.org/show_bug.cgi?id=170209
<rdar://problem/31309258>

Reviewed by Tim Horton.

Source/WebCore:

Expose internals.touchEventRectsForEvent() and internals.passiveTouchEventListenerRects(), which
fetch data via Page.

Because the regions are normally updated on a timer, we have to force an eager update via Document::updateTouchEventRegions().

Test: fast/events/touch/ios/touch-event-regions.html

* page/Page.cpp:
(WebCore::Page::nonFastScrollableRects):
(WebCore::Page::touchEventRectsForEvent):
(WebCore::Page::passiveTouchEventListenerRects):
* page/Page.h:
* testing/Internals.cpp:
(WebCore::Internals::touchEventRectsForEvent):
(WebCore::Internals::passiveTouchEventListenerRects):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Simple test that dumps the regions.

* fast/events/touch/ios/touch-event-regions-expected.txt: Added.
* fast/events/touch/ios/touch-event-regions.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (214588 => 214589)


--- trunk/LayoutTests/ChangeLog	2017-03-30 01:25:00 UTC (rev 214588)
+++ trunk/LayoutTests/ChangeLog	2017-03-30 01:31:53 UTC (rev 214589)
@@ -1,3 +1,16 @@
+2017-03-28  Simon Fraser  <simon.fra...@apple.com>
+
+        Make it possible to dump touch event regions for testing
+        https://bugs.webkit.org/show_bug.cgi?id=170209
+        <rdar://problem/31309258>
+
+        Reviewed by Tim Horton.
+
+        Simple test that dumps the regions.
+
+        * fast/events/touch/ios/touch-event-regions-expected.txt: Added.
+        * fast/events/touch/ios/touch-event-regions.html: Added.
+
 2017-03-29  Zalan Bujtas  <za...@apple.com>
 
         RenderBlockFlow::addFloatsToNewParent should check if float is already added to the object list.

Added: trunk/LayoutTests/fast/events/touch/ios/touch-event-regions-expected.txt (0 => 214589)


--- trunk/LayoutTests/fast/events/touch/ios/touch-event-regions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-event-regions-expected.txt	2017-03-30 01:31:53 UTC (rev 214589)
@@ -0,0 +1,20 @@
+touch start touch move touch end touch force change passive
+Overflowing
+touchstart
+250, 50 - 266, 66
+50, 100 - 192, 222
+250, 400 - 392, 522
+touchstart
+250, 50 - 266, 66
+250, 100 - 392, 222
+250, 400 - 392, 522
+touchend
+250, 50 - 266, 66
+50, 250 - 192, 372
+250, 400 - 392, 522
+touchforcechange
+250, 50 - 266, 66
+250, 250 - 392, 372
+250, 400 - 392, 522
+passive
+50, 400 - 192, 522

Added: trunk/LayoutTests/fast/events/touch/ios/touch-event-regions.html (0 => 214589)


--- trunk/LayoutTests/fast/events/touch/ios/touch-event-regions.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-event-regions.html	2017-03-30 01:31:53 UTC (rev 214589)
@@ -0,0 +1,104 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1.0">
+    <style>
+        .box {
+            position: absolute;
+            height: 100px;
+            width: 120px;
+            border: 1px solid black;
+            padding: 10px;
+        }
+        
+        input {
+            display: block;
+            margin: 50px;
+            width: 400px;
+        }
+        
+        .overflow div {
+            height: 500px;
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+        }
+
+        function rectsAsString(rects)
+        {
+            var result = "";
+            for (var i = 0; i < rects.length; ++i) {
+                var rect = rects[i];
+                if (i)
+                    result += '\n';
+                result += rect.left + ', ' + rect.top + ' - ' + rect.right + ', ' + rect.bottom;
+            }
+            return result;
+        }
+
+        function doTest()
+        {
+            document.getElementById('passive').addEventListener('touchstart', function(e) { }, { 'passive': true })
+            
+            if (!window.internals)
+                return;
+                
+            var resultString = 'touchstart\n';
+            var rectList = internals.touchEventRectsForEvent('touchstart');
+            resultString += rectsAsString(rectList);
+
+            rectList = internals.touchEventRectsForEvent('touchmove');
+            resultString += '\ntouchstart\n' + rectsAsString(rectList);
+
+            rectList = internals.touchEventRectsForEvent('touchend');
+            resultString += '\ntouchend\n' + rectsAsString(rectList);
+
+            rectList = internals.touchEventRectsForEvent('touchforcechange');
+            resultString += '\ntouchforcechange\n' + rectsAsString(rectList);
+
+            rectList = internals.passiveTouchEventListenerRects();
+            resultString += '\npassive\n' + rectsAsString(rectList);
+
+            document.getElementById('results').textContent = resultString;
+        }
+
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<input type="range">
+
+<div class="box" style="left: 50px; top: 100px;" _ontouchstart_="(void)0">
+    touch start
+</div>
+
+<div class="box" style="left: 250px; top: 100px;" _ontouchmove_="(void)0">
+    touch move
+</div>
+
+<div class="box" style="left: 50px; top: 250px;" _ontouchend_="(void)0">
+    touch end
+</div>
+
+<div class="box" style="left: 250px; top: 250px;" _ontouchforcechange_="(void)0">
+    touch force change
+</div>
+
+<div id="passive" class="box" style="left: 50px; top: 400px;">
+    passive
+</div>
+
+<div id="passive" class="overflow box" style="left: 250px; top: 400px; overflow: scroll">
+    <div>
+        Overflowing
+    </div>
+</div>
+
+<pre id="results"></pre>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (214588 => 214589)


--- trunk/Source/WebCore/ChangeLog	2017-03-30 01:25:00 UTC (rev 214588)
+++ trunk/Source/WebCore/ChangeLog	2017-03-30 01:31:53 UTC (rev 214589)
@@ -1,3 +1,29 @@
+2017-03-28  Simon Fraser  <simon.fra...@apple.com>
+
+        Make it possible to dump touch event regions for testing
+        https://bugs.webkit.org/show_bug.cgi?id=170209
+        <rdar://problem/31309258>
+
+        Reviewed by Tim Horton.
+
+        Expose internals.touchEventRectsForEvent() and internals.passiveTouchEventListenerRects(), which
+        fetch data via Page.
+
+        Because the regions are normally updated on a timer, we have to force an eager update via Document::updateTouchEventRegions().
+
+        Test: fast/events/touch/ios/touch-event-regions.html
+
+        * page/Page.cpp:
+        (WebCore::Page::nonFastScrollableRects):
+        (WebCore::Page::touchEventRectsForEvent):
+        (WebCore::Page::passiveTouchEventListenerRects):
+        * page/Page.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::touchEventRectsForEvent):
+        (WebCore::Internals::passiveTouchEventListenerRects):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2017-03-29  Zalan Bujtas  <za...@apple.com>
 
         RenderBlockFlow::addFloatsToNewParent should check if float is already added to the object list.

Modified: trunk/Source/WebCore/page/Page.cpp (214588 => 214589)


--- trunk/Source/WebCore/page/Page.cpp	2017-03-30 01:25:00 UTC (rev 214588)
+++ trunk/Source/WebCore/page/Page.cpp	2017-03-30 01:31:53 UTC (rev 214589)
@@ -423,6 +423,49 @@
     return ClientRectList::create(quads);
 }
 
+Ref<ClientRectList> Page::touchEventRectsForEvent(const String& eventName)
+{
+    if (Document* document = m_mainFrame->document()) {
+        document->updateLayout();
+#if ENABLE(IOS_TOUCH_EVENTS)
+        document->updateTouchEventRegions();
+#endif
+    }
+
+    Vector<IntRect> rects;
+    if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) {
+        const EventTrackingRegions& eventTrackingRegions = scrollingCoordinator->absoluteEventTrackingRegions();
+        const auto& region = eventTrackingRegions.eventSpecificSynchronousDispatchRegions.get(eventName);
+        rects.appendVector(region.rects());
+    }
+
+    Vector<FloatQuad> quads(rects.size());
+    for (size_t i = 0; i < rects.size(); ++i)
+        quads[i] = FloatRect(rects[i]);
+
+    return ClientRectList::create(quads);
+}
+
+Ref<ClientRectList> Page::passiveTouchEventListenerRects()
+{
+    if (Document* document = m_mainFrame->document()) {
+        document->updateLayout();
+#if ENABLE(IOS_TOUCH_EVENTS)
+        document->updateTouchEventRegions();
+#endif  
+    }
+
+    Vector<IntRect> rects;
+    if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
+        rects.appendVector(scrollingCoordinator->absoluteEventTrackingRegions().asynchronousDispatchRegion.rects());
+
+    Vector<FloatQuad> quads(rects.size());
+    for (size_t i = 0; i < rects.size(); ++i)
+        quads[i] = FloatRect(rects[i]);
+
+    return ClientRectList::create(quads);
+}
+
 #if ENABLE(VIEW_MODE_CSS_MEDIA)
 struct ViewModeInfo {
     const char* name;

Modified: trunk/Source/WebCore/page/Page.h (214588 => 214589)


--- trunk/Source/WebCore/page/Page.h	2017-03-30 01:25:00 UTC (rev 214588)
+++ trunk/Source/WebCore/page/Page.h	2017-03-30 01:31:53 UTC (rev 214589)
@@ -237,6 +237,9 @@
     WEBCORE_EXPORT String synchronousScrollingReasonsAsText();
     WEBCORE_EXPORT Ref<ClientRectList> nonFastScrollableRects();
 
+    WEBCORE_EXPORT Ref<ClientRectList> touchEventRectsForEvent(const String& eventName);
+    WEBCORE_EXPORT Ref<ClientRectList> passiveTouchEventListenerRects();
+
     Settings& settings() const { return *m_settings; }
     ProgressTracker& progress() const { return *m_progress; }
     BackForwardController& backForward() const { return *m_backForwardController; }

Modified: trunk/Source/WebCore/testing/Internals.cpp (214588 => 214589)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-03-30 01:25:00 UTC (rev 214588)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-03-30 01:31:53 UTC (rev 214589)
@@ -1719,6 +1719,24 @@
     return document->touchEventHandlerCount();
 }
 
+ExceptionOr<Ref<ClientRectList>> Internals::touchEventRectsForEvent(const String& eventName)
+{
+    Document* document = contextDocument();
+    if (!document || !document->page())
+        return Exception { INVALID_ACCESS_ERR };
+
+    return document->page()->touchEventRectsForEvent(eventName);
+}
+
+ExceptionOr<Ref<ClientRectList>> Internals::passiveTouchEventListenerRects()
+{
+    Document* document = contextDocument();
+    if (!document || !document->page())
+        return Exception { INVALID_ACCESS_ERR };
+
+    return document->page()->passiveTouchEventListenerRects();
+}
+
 // FIXME: Remove the document argument. It is almost always the same as
 // contextDocument(), with the exception of a few tests that pass a
 // different document, and could just make the call through another Internals

Modified: trunk/Source/WebCore/testing/Internals.h (214588 => 214589)


--- trunk/Source/WebCore/testing/Internals.h	2017-03-30 01:25:00 UTC (rev 214588)
+++ trunk/Source/WebCore/testing/Internals.h	2017-03-30 01:31:53 UTC (rev 214589)
@@ -234,6 +234,9 @@
     ExceptionOr<unsigned> wheelEventHandlerCount();
     ExceptionOr<unsigned> touchEventHandlerCount();
 
+    ExceptionOr<Ref<ClientRectList>> touchEventRectsForEvent(const String&);
+    ExceptionOr<Ref<ClientRectList>> passiveTouchEventListenerRects();
+
     ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent) const;
 
     String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);

Modified: trunk/Source/WebCore/testing/Internals.idl (214588 => 214589)


--- trunk/Source/WebCore/testing/Internals.idl	2017-03-30 01:25:00 UTC (rev 214588)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-03-30 01:31:53 UTC (rev 214589)
@@ -213,6 +213,9 @@
     [MayThrowException] unsigned long wheelEventHandlerCount();
     [MayThrowException] unsigned long touchEventHandlerCount();
 
+    [MayThrowException] ClientRectList touchEventRectsForEvent(DOMString eventName);
+    [MayThrowException] ClientRectList passiveTouchEventListenerRects();
+
     [MayThrowException] NodeList? nodesFromRect(Document document, long x, long y,
         unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding,
         boolean ignoreClipping, boolean allowShadowContent, boolean allowChildFrameContent);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to