Changeset 214589 in webkit


Ignore:
Timestamp:
Mar 29, 2017, 6:31:53 PM (9 years ago)
Author:
Simon Fraser
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.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214588 r214589  
     12017-03-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to dump touch event regions for testing
     4        https://bugs.webkit.org/show_bug.cgi?id=170209
     5        <rdar://problem/31309258>
     6
     7        Reviewed by Tim Horton.
     8
     9        Simple test that dumps the regions.
     10
     11        * fast/events/touch/ios/touch-event-regions-expected.txt: Added.
     12        * fast/events/touch/ios/touch-event-regions.html: Added.
     13
    1142017-03-29  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r214588 r214589  
     12017-03-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to dump touch event regions for testing
     4        https://bugs.webkit.org/show_bug.cgi?id=170209
     5        <rdar://problem/31309258>
     6
     7        Reviewed by Tim Horton.
     8
     9        Expose internals.touchEventRectsForEvent() and internals.passiveTouchEventListenerRects(), which
     10        fetch data via Page.
     11
     12        Because the regions are normally updated on a timer, we have to force an eager update via Document::updateTouchEventRegions().
     13
     14        Test: fast/events/touch/ios/touch-event-regions.html
     15
     16        * page/Page.cpp:
     17        (WebCore::Page::nonFastScrollableRects):
     18        (WebCore::Page::touchEventRectsForEvent):
     19        (WebCore::Page::passiveTouchEventListenerRects):
     20        * page/Page.h:
     21        * testing/Internals.cpp:
     22        (WebCore::Internals::touchEventRectsForEvent):
     23        (WebCore::Internals::passiveTouchEventListenerRects):
     24        * testing/Internals.h:
     25        * testing/Internals.idl:
     26
    1272017-03-29  Zalan Bujtas  <zalan@apple.com>
    228
  • trunk/Source/WebCore/page/Page.cpp

    r214129 r214589  
    424424}
    425425
     426Ref<ClientRectList> Page::touchEventRectsForEvent(const String& eventName)
     427{
     428    if (Document* document = m_mainFrame->document()) {
     429        document->updateLayout();
     430#if ENABLE(IOS_TOUCH_EVENTS)
     431        document->updateTouchEventRegions();
     432#endif
     433    }
     434
     435    Vector<IntRect> rects;
     436    if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) {
     437        const EventTrackingRegions& eventTrackingRegions = scrollingCoordinator->absoluteEventTrackingRegions();
     438        const auto& region = eventTrackingRegions.eventSpecificSynchronousDispatchRegions.get(eventName);
     439        rects.appendVector(region.rects());
     440    }
     441
     442    Vector<FloatQuad> quads(rects.size());
     443    for (size_t i = 0; i < rects.size(); ++i)
     444        quads[i] = FloatRect(rects[i]);
     445
     446    return ClientRectList::create(quads);
     447}
     448
     449Ref<ClientRectList> Page::passiveTouchEventListenerRects()
     450{
     451    if (Document* document = m_mainFrame->document()) {
     452        document->updateLayout();
     453#if ENABLE(IOS_TOUCH_EVENTS)
     454        document->updateTouchEventRegions();
     455#endif 
     456    }
     457
     458    Vector<IntRect> rects;
     459    if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
     460        rects.appendVector(scrollingCoordinator->absoluteEventTrackingRegions().asynchronousDispatchRegion.rects());
     461
     462    Vector<FloatQuad> quads(rects.size());
     463    for (size_t i = 0; i < rects.size(); ++i)
     464        quads[i] = FloatRect(rects[i]);
     465
     466    return ClientRectList::create(quads);
     467}
     468
    426469#if ENABLE(VIEW_MODE_CSS_MEDIA)
    427470struct ViewModeInfo {
  • trunk/Source/WebCore/page/Page.h

    r214494 r214589  
    238238    WEBCORE_EXPORT Ref<ClientRectList> nonFastScrollableRects();
    239239
     240    WEBCORE_EXPORT Ref<ClientRectList> touchEventRectsForEvent(const String& eventName);
     241    WEBCORE_EXPORT Ref<ClientRectList> passiveTouchEventListenerRects();
     242
    240243    Settings& settings() const { return *m_settings; }
    241244    ProgressTracker& progress() const { return *m_progress; }
  • trunk/Source/WebCore/testing/Internals.cpp

    r214503 r214589  
    17201720}
    17211721
     1722ExceptionOr<Ref<ClientRectList>> Internals::touchEventRectsForEvent(const String& eventName)
     1723{
     1724    Document* document = contextDocument();
     1725    if (!document || !document->page())
     1726        return Exception { INVALID_ACCESS_ERR };
     1727
     1728    return document->page()->touchEventRectsForEvent(eventName);
     1729}
     1730
     1731ExceptionOr<Ref<ClientRectList>> Internals::passiveTouchEventListenerRects()
     1732{
     1733    Document* document = contextDocument();
     1734    if (!document || !document->page())
     1735        return Exception { INVALID_ACCESS_ERR };
     1736
     1737    return document->page()->passiveTouchEventListenerRects();
     1738}
     1739
    17221740// FIXME: Remove the document argument. It is almost always the same as
    17231741// contextDocument(), with the exception of a few tests that pass a
  • trunk/Source/WebCore/testing/Internals.h

    r214503 r214589  
    235235    ExceptionOr<unsigned> touchEventHandlerCount();
    236236
     237    ExceptionOr<Ref<ClientRectList>> touchEventRectsForEvent(const String&);
     238    ExceptionOr<Ref<ClientRectList>> passiveTouchEventListenerRects();
     239
    237240    ExceptionOr<RefPtr<NodeList>> nodesFromRect(Document&, int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent) const;
    238241
  • trunk/Source/WebCore/testing/Internals.idl

    r214503 r214589  
    214214    [MayThrowException] unsigned long touchEventHandlerCount();
    215215
     216    [MayThrowException] ClientRectList touchEventRectsForEvent(DOMString eventName);
     217    [MayThrowException] ClientRectList passiveTouchEventListenerRects();
     218
    216219    [MayThrowException] NodeList? nodesFromRect(Document document, long x, long y,
    217220        unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding,
Note: See TracChangeset for help on using the changeset viewer.