Expand test infrastructure to support scrolling tests
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 00:29:05 +0000 (00:29 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 00:29:05 +0000 (00:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143684
<rdar://problem/20375516>

Reviewed by Simon Fraser.

Source/WebCore:

Tested by various fast/scrolling and platform/mac-wk2/tiled-drawing/scrolling tests.

This series of changes adds a new singleton class, 'WheelEventTestTrigger', which encapsulates a
function object to be fired when scroll events are finished. The object also keeps track of reasons
why the test should not yet fire (e.g., 'rubberbanding' is active) so that tests do not incorrectly
check rendering state in the middle of an animation.

Switch from the original WeakPtr design to ThreadSafeRefPtr, because WeakPtr cannot be shared
across multiple threads.

* page/FrameView.cpp:
(WebCore::FrameView::layout): Make sure ScrollAnimator knows about any active test trigger.
(WebCore::FrameView::setScrollPosition): Ditto.
(WebCore::FrameView::didAddScrollbar): Ditto.
* page/MainFrame.cpp:
(WebCore::MainFrame::testTrigger): Moved to Page.
(WebCore::MainFrame::ensureTestTrigger): Ditto.
* page/MainFrame.h:
* page/Page.cpp:
(WebCore::Page::testTrigger): Moved from MainFrame, and converted to use RefPtr.
(WebCore::Page::ensureTestTrigger): Ditto.
* page/Page.h:
* page/WheelEventTestTrigger.cpp:
(WebCore::WheelEventTestTrigger::WheelEventTestTrigger): Remove WeakPtr code.
(WebCore::WheelEventTestTrigger::createWeakPtr): Deleted.
* page/WheelEventTestTrigger.h:
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::platformPrepareForWheelEvents): Make sure the scroll animator knows about
any active test trigger object.
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll): Notify WheelEventTestTrigger
that the scrolling thread is synced with the main thread.
* platform/ScrollAnimator.h: Hold a RefPtr to the WheelEventTestTrigger.
(WebCore::ScrollAnimator::ScrollAnimator::setWheelEventTestTrigger):
* platform/cocoa/ScrollController.h:
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::startSnapRubberbandTimer): Notify test trigger to hold tests until rubber band
snapping is complete.
(WebCore::ScrollController::stopSnapRubberbandTimer): Notify test trigger that rubber band snapping is done.
(WebCore::ScrollController::startScrollSnapTimer): Notify test trigger to hold tests until scroll snapping
is complete.
(WebCore::ScrollController::stopScrollSnapTimer): Notify test trigger that scroll snapping is done.
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::didBeginScrollGesture): Notify test trigger that a content scroll is in progress.
(WebCore::ScrollAnimatorMac::didEndScrollGesture): Notify test trigger that a content scroll is finished.
(WebCore::ScrollAnimatorMac::sendContentAreaScrolledSoon): Notify test trigger to hold tests until the content
scrolling is complete.
(WebCore::ScrollAnimatorMac::sendContentAreaScrolledTimerFired): Notify test trigger that content scrolling is done.
* rendering/RenderBox.cpp:
(WebCore::connectScrollAnimatorToTestTrigger): Helper function.
(WebCore::RenderBox::setScrollLeft): Call 'connectScrollAnimatorToTestTrigger' to connect the ScrollAnimator
to the WheelEventTestTrigger so that future scroll operations can notify the test infrastructure.
(WebCore::RenderBox::setScrollTop): Ditto.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::createScrollbar): Make sure the ScrollAnimator knows about any active test triggers.
* rendering/RenderListBox.cpp:
(WebCore::connectScrollAnimatorToTestTrigger): Helper function.
(WebCore::RenderListBox::setScrollLeft): Call 'connectScrollAnimatorToTestTrigger' to connect the ScrollAnimator
to the WheelEventTestTrigger so that future scroll operations can notify the test infrastructure.
(WebCore::RenderListBox::setScrollTop): Ditto.
(WebCore::RenderListBox::createScrollbar): Ditto.
* testing/js/WebCoreTestSupport.cpp:
(WebCoreTestSupport::monitorWheelEvents): Look for WheelEventTestTrigger in Page, rather than MainFrame.
(WebCoreTestSupport::setTestCallbackAndStartNotificationTimer): Ditto.

Source/WebKit2:

Update test programs to activate (and deactivate) the new WheelEventTestTrigger logic.

* UIProcess/API/C/WKPage.cpp:
(WKPageClearWheelEventTestTriggers): Added.
* UIProcess/API/C/WKPage.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::clearWheelEventTestTrigger): Added.
* UIProcess/WebPageProxy.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageStartMonitoringScrollOperations): Interact with WheelEventTestTrigger through
the Page, rather than MainFrame.
(WKBundlePageRegisterScrollOperationCompletionCallback): Ditto.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::createScrollbar): Make sure scroll animator knows about any
active test triggers.
* WebPage/EventDispatcher.mm:
(WebKit::EventDispatcher::wheelEvent): If the wheel event was passed to the scrolling thread,
defer tests until a Scrolling Thread Sync has occurred.
* WebPage/WebPage.cpp:
(WebKit::WebPage::clearWheelEventTestTrigger): Added.
* WebPage/WebPage.h:
* WebPage/WebPage.message.in: Added ClearWheelEventTestTrigger message.

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebViewToConsistentStateBeforeTesting): Make sure the WheelEventTestTrigger state is
reset before the next test run.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues): Ditto."

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

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/MainFrame.cpp
Source/WebCore/page/MainFrame.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/WheelEventTestTrigger.cpp
Source/WebCore/page/WheelEventTestTrigger.h
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/platform/ScrollAnimator.h
Source/WebCore/platform/cocoa/ScrollController.h
Source/WebCore/platform/cocoa/ScrollController.mm
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/testing/js/WebCoreTestSupport.cpp
Source/WebCore/testing/js/WebCoreTestSupport.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/TestController.cpp

index ab9f151..d5efd6b 100644 (file)
@@ -1,3 +1,76 @@
+2015-04-29  Brent Fulgham  <bfulgham@apple.com>
+
+        Expand test infrastructure to support scrolling tests
+        https://bugs.webkit.org/show_bug.cgi?id=143684
+        <rdar://problem/20375516>
+
+        Reviewed by Simon Fraser.
+
+        Tested by various fast/scrolling and platform/mac-wk2/tiled-drawing/scrolling tests.
+
+        This series of changes adds a new singleton class, 'WheelEventTestTrigger', which encapsulates a
+        function object to be fired when scroll events are finished. The object also keeps track of reasons
+        why the test should not yet fire (e.g., 'rubberbanding' is active) so that tests do not incorrectly
+        check rendering state in the middle of an animation.
+
+        Switch from the original WeakPtr design to ThreadSafeRefPtr, because WeakPtr cannot be shared
+        across multiple threads.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout): Make sure ScrollAnimator knows about any active test trigger.
+        (WebCore::FrameView::setScrollPosition): Ditto.
+        (WebCore::FrameView::didAddScrollbar): Ditto.
+        * page/MainFrame.cpp:
+        (WebCore::MainFrame::testTrigger): Moved to Page.
+        (WebCore::MainFrame::ensureTestTrigger): Ditto.
+        * page/MainFrame.h:
+        * page/Page.cpp:
+        (WebCore::Page::testTrigger): Moved from MainFrame, and converted to use RefPtr.
+        (WebCore::Page::ensureTestTrigger): Ditto.
+        * page/Page.h:
+        * page/WheelEventTestTrigger.cpp:
+        (WebCore::WheelEventTestTrigger::WheelEventTestTrigger): Remove WeakPtr code.
+        (WebCore::WheelEventTestTrigger::createWeakPtr): Deleted.
+        * page/WheelEventTestTrigger.h:
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::platformPrepareForWheelEvents): Make sure the scroll animator knows about
+        any active test trigger object.
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll): Notify WheelEventTestTrigger
+        that the scrolling thread is synced with the main thread.
+        * platform/ScrollAnimator.h: Hold a RefPtr to the WheelEventTestTrigger. 
+        (WebCore::ScrollAnimator::ScrollAnimator::setWheelEventTestTrigger):
+        * platform/cocoa/ScrollController.h:
+        * platform/cocoa/ScrollController.mm:
+        (WebCore::ScrollController::startSnapRubberbandTimer): Notify test trigger to hold tests until rubber band
+        snapping is complete.
+        (WebCore::ScrollController::stopSnapRubberbandTimer): Notify test trigger that rubber band snapping is done.
+        (WebCore::ScrollController::startScrollSnapTimer): Notify test trigger to hold tests until scroll snapping
+        is complete.
+        (WebCore::ScrollController::stopScrollSnapTimer): Notify test trigger that scroll snapping is done.
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::didBeginScrollGesture): Notify test trigger that a content scroll is in progress.
+        (WebCore::ScrollAnimatorMac::didEndScrollGesture): Notify test trigger that a content scroll is finished.
+        (WebCore::ScrollAnimatorMac::sendContentAreaScrolledSoon): Notify test trigger to hold tests until the content
+        scrolling is complete.
+        (WebCore::ScrollAnimatorMac::sendContentAreaScrolledTimerFired): Notify test trigger that content scrolling is done.
+        * rendering/RenderBox.cpp:
+        (WebCore::connectScrollAnimatorToTestTrigger): Helper function.
+        (WebCore::RenderBox::setScrollLeft): Call 'connectScrollAnimatorToTestTrigger' to connect the ScrollAnimator
+        to the WheelEventTestTrigger so that future scroll operations can notify the test infrastructure.
+        (WebCore::RenderBox::setScrollTop): Ditto.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::createScrollbar): Make sure the ScrollAnimator knows about any active test triggers.
+        * rendering/RenderListBox.cpp:
+        (WebCore::connectScrollAnimatorToTestTrigger): Helper function.
+        (WebCore::RenderListBox::setScrollLeft): Call 'connectScrollAnimatorToTestTrigger' to connect the ScrollAnimator
+        to the WheelEventTestTrigger so that future scroll operations can notify the test infrastructure.
+        (WebCore::RenderListBox::setScrollTop): Ditto.
+        (WebCore::RenderListBox::createScrollbar): Ditto.
+        * testing/js/WebCoreTestSupport.cpp:
+        (WebCoreTestSupport::monitorWheelEvents): Look for WheelEventTestTrigger in Page, rather than MainFrame.
+        (WebCoreTestSupport::setTestCallbackAndStartNotificationTimer): Ditto.
+
 2015-04-29  Javier Fernandez  <jfernandez@igalia.com>
 
         [CSS Box Alignment] Unifying alignment data in a single class
index 2fa4370..94784e7 100644 (file)
@@ -87,6 +87,7 @@
 #include "TextResourceDecoder.h"
 #include "TextStream.h"
 #include "TiledBacking.h"
+#include "WheelEventTestTrigger.h"
 
 #include <wtf/CurrentTime.h>
 #include <wtf/Ref.h>
@@ -1265,7 +1266,9 @@ void FrameView::layout(bool allowSubtree)
                     // Set the initial hMode to AlwaysOff if we're auto.
                     if (hMode == ScrollbarAuto)
                         setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This causes a horizontal scrollbar to disappear.
-
+                    Page* page = frame().page();
+                    if (page && page->expectsWheelEventTriggers())
+                        scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
                     setScrollbarModes(hMode, vMode);
                     setScrollbarsSuppressed(false, true);
                 } else
@@ -2049,6 +2052,9 @@ void FrameView::setScrollPosition(const IntPoint& scrollPoint)
 {
     TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
     m_maintainScrollPositionAnchor = nullptr;
+    Page* page = frame().page();
+    if (page && page->expectsWheelEventTriggers())
+        scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
     ScrollView::setScrollPosition(scrollPoint);
 }
 
@@ -4561,6 +4567,9 @@ void FrameView::setScrollingPerformanceLoggingEnabled(bool flag)
 void FrameView::didAddScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
 {
     ScrollableArea::didAddScrollbar(scrollbar, orientation);
+    Page* page = frame().page();
+    if (page && page->expectsWheelEventTriggers())
+        scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
     if (AXObjectCache* cache = axObjectCache())
         cache->handleScrollbarUpdate(this);
 }
index 4dd2ad5..7b7e003 100644 (file)
@@ -33,7 +33,6 @@
 #include "ScrollLatchingState.h"
 #include "Settings.h"
 #include "WheelEventDeltaTracker.h"
-#include "WheelEventTestTrigger.h"
 #include <wtf/NeverDestroyed.h>
 
 #if PLATFORM(MAC)
@@ -127,22 +126,4 @@ void MainFrame::popLatchingState()
 }
 #endif
 
-WheelEventTestTrigger* MainFrame::testTrigger() const
-{
-    return m_testTrigger.get();
-}
-
-WheelEventTestTrigger* MainFrame::ensureTestTrigger()
-{
-    if (!m_testTrigger)
-        m_testTrigger = std::make_unique<WheelEventTestTrigger>();
-
-    return m_testTrigger.get();
-}
-
-void MainFrame::clearTrigger()
-{
-    m_testTrigger = nullptr;
-}
-
 }
index 4f5d139..9cf8ca5 100644 (file)
@@ -37,7 +37,6 @@ class PageOverlayController;
 class ScrollLatchingState;
 class ServicesOverlayController;
 class WheelEventDeltaTracker;
-class WheelEventTestTrigger;
 
 class MainFrame final : public Frame {
 public:
@@ -64,10 +63,6 @@ public:
 
     WEBCORE_EXPORT DiagnosticLoggingClient& diagnosticLoggingClient() const;
 
-    WEBCORE_EXPORT WheelEventTestTrigger* testTrigger() const;
-    WEBCORE_EXPORT WheelEventTestTrigger* ensureTestTrigger();
-    WEBCORE_EXPORT void clearTrigger();
-
 private:
     MainFrame(Page&, PageConfiguration&);
 
@@ -81,7 +76,6 @@ private:
     std::unique_ptr<ServicesOverlayController> m_servicesOverlayController;
 #endif
 #endif
-    std::unique_ptr<WheelEventTestTrigger> m_testTrigger;
 
     std::unique_ptr<WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
     std::unique_ptr<PageOverlayController> m_pageOverlayController;
index d699eaa..06a0e9b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2006-2015  Apple Inc. All Rights Reserved.
  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  *
  * This library is free software; you can redistribute it and/or
@@ -1724,4 +1724,23 @@ void Page::setShouldPlayToPlaybackTarget(uint64_t clientId, bool shouldPlay)
 }
 #endif
 
+RefPtr<WheelEventTestTrigger> Page::testTrigger() const
+{
+    return m_testTrigger;
+}
+
+WheelEventTestTrigger& Page::ensureTestTrigger()
+{
+    if (!m_testTrigger)
+        m_testTrigger = adoptRef(new WheelEventTestTrigger());
+
+    return *m_testTrigger;
+}
+
+void Page::clearTrigger()
+{
+    m_testTrigger = nullptr;
+}
+    
+
 } // namespace WebCore
index b3a6088..7d7a8df 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2010, 2013, 2015 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  *
  * This library is free software; you can redistribute it and/or
@@ -36,6 +36,7 @@
 #include "Supplementable.h"
 #include "ViewState.h"
 #include "ViewportArguments.h"
+#include "WheelEventTestTrigger.h"
 #include <memory>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
@@ -439,6 +440,11 @@ public:
     WEBCORE_EXPORT void setShouldPlayToPlaybackTarget(uint64_t, bool);
 #endif
 
+    WEBCORE_EXPORT RefPtr<WheelEventTestTrigger> testTrigger() const;
+    WEBCORE_EXPORT WheelEventTestTrigger& ensureTestTrigger();
+    WEBCORE_EXPORT void clearTrigger();
+    WEBCORE_EXPORT bool expectsWheelEventTriggers() const { return !!m_testTrigger; }
+
 private:
     WEBCORE_EXPORT void initGroup();
 
@@ -586,6 +592,7 @@ private:
     Ref<StorageNamespaceProvider> m_storageNamespaceProvider;
     RefPtr<UserContentController> m_userContentController;
     Ref<VisitedLinkStore> m_visitedLinkStore;
+    RefPtr<WheelEventTestTrigger> m_testTrigger;
 
     HashSet<ViewStateChangeObserver*> m_viewStateChangeObservers;
 
index 5f90ae7..cf1eee3 100644 (file)
@@ -33,15 +33,9 @@ namespace WebCore {
 
 WheelEventTestTrigger::WheelEventTestTrigger()
     : m_testTriggerTimer(RunLoop::current(), this, &WheelEventTestTrigger::triggerTestTimerFired)
-    , m_weakPtrFactory(this)
 {
 }
 
-WeakPtr<WheelEventTestTrigger> WheelEventTestTrigger::createWeakPtr()
-{
-    return m_weakPtrFactory.createWeakPtr();
-}
-
 void WheelEventTestTrigger::clearAllTestDeferrals()
 {
     std::lock_guard<std::mutex> lock(m_testTriggerMutex);
index 30b3030..b06da4d 100644 (file)
 #include <mutex>
 #include <set>
 #include <wtf/HashMap.h>
+#include <wtf/RefPtr.h>
 #include <wtf/RunLoop.h>
-#include <wtf/WeakPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
 
 namespace WebCore {
 
-class WheelEventTestTrigger {
+class WheelEventTestTrigger : public ThreadSafeRefCounted<WheelEventTestTrigger> {
     WTF_MAKE_NONCOPYABLE(WheelEventTestTrigger); WTF_MAKE_FAST_ALLOCATED;
 public:
     WheelEventTestTrigger();
@@ -51,20 +52,16 @@ public:
         ScrollingThreadSyncNeeded,
         ContentScrollInProgress
     };
-    typedef void* ScrollableAreaIdentifier;
-    void deferTestsForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
-    void removeTestDeferralForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
+    typedef const void* ScrollableAreaIdentifier;
+    void WEBCORE_EXPORT deferTestsForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
+    void WEBCORE_EXPORT removeTestDeferralForReason(ScrollableAreaIdentifier, DeferTestTriggerReason);
     void triggerTestTimerFired();
 
-    WeakPtr<WheelEventTestTrigger> createWeakPtr();
-
 private:
     std::function<void()> m_testNotificationCallback;
     RunLoop::Timer<WheelEventTestTrigger> m_testTriggerTimer;
     mutable std::mutex m_testTriggerMutex;
-    WTF::HashMap<void*, std::set<DeferTestTriggerReason>> m_deferTestTriggerReasons;
-
-    WeakPtrFactory<WheelEventTestTrigger> m_weakPtrFactory;
+    WTF::HashMap<ScrollableAreaIdentifier, std::set<DeferTestTriggerReason>> m_deferTestTriggerReasons;
 };
 
 }
index 074435d..b1aea26 100644 (file)
@@ -59,6 +59,7 @@
 #include "Settings.h"
 #include "ShadowRoot.h"
 #include "WebCoreSystemInterface.h"
+#include "WheelEventTestTrigger.h"
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/ObjcRuntimeExtras.h>
@@ -882,6 +883,10 @@ void EventHandler::platformPrepareForWheelEvents(const PlatformWheelEvent& wheel
         }
     }
     
+    Page* page = m_frame.page();
+    if (scrollableArea && page && page->expectsWheelEventTriggers())
+        scrollableArea->scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
+
     ScrollLatchingState* latchingState = m_frame.mainFrame().latchingState();
     if (wheelEvent.shouldConsiderLatching()) {
         if (scrollableContainer && scrollableArea) {
index ce94901..1c64aed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "GraphicsLayer.h"
 #include "MainFrame.h"
 #include "Page.h"
+#include "ScrollAnimator.h"
 #include "ScrollingConstraints.h"
 #include "ScrollingStateFixedNode.h"
 #include "ScrollingStateFrameScrollingNode.h"
 #include "ScrollingStateOverflowScrollingNode.h"
 #include "ScrollingStateStickyNode.h"
 #include "ScrollingStateTree.h"
+#include "WheelEventTestTrigger.h"
 
 namespace WebCore {
 
@@ -354,6 +356,14 @@ void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNo
             }
         }
 
+#if PLATFORM(COCOA)
+        if (m_page->expectsWheelEventTriggers()) {
+            frameView.scrollAnimator().setWheelEventTestTrigger(m_page->testTrigger());
+            if (const auto& trigger = m_page->testTrigger())
+                trigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(m_page), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
+        }
+#endif
+        
         return;
     }
 
@@ -364,6 +374,14 @@ void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNo
         scrollableArea->setIsUserScroll(false);
         if (scrollingLayerPositionAction == SetScrollingLayerPosition)
             m_page->editorClient().overflowScrollPositionChanged();
+
+#if PLATFORM(COCOA)
+        if (m_page->expectsWheelEventTriggers()) {
+            frameView.scrollAnimator().setWheelEventTestTrigger(m_page->testTrigger());
+            if (const auto& trigger = m_page->testTrigger())
+                trigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(m_page), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
+        }
+#endif
     }
 }
 
index 5eaa7a9..60374d0 100644 (file)
@@ -36,6 +36,7 @@
 #include "LayoutUnit.h"
 #include "PlatformWheelEvent.h"
 #include "ScrollTypes.h"
+#include "WheelEventTestTrigger.h"
 #include <wtf/FastMalloc.h>
 #include <wtf/Forward.h>
 
@@ -49,6 +50,7 @@ class FloatPoint;
 class PlatformTouchEvent;
 class ScrollableArea;
 class Scrollbar;
+class WheelEventTestTrigger;
 
 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
 class ScrollAnimator : private ScrollControllerClient {
@@ -117,6 +119,11 @@ public:
 
     virtual bool isRubberBandInProgress() const { return false; }
 
+    void setWheelEventTestTrigger(RefPtr<WheelEventTestTrigger>&& testTrigger) { m_wheelEventTestTrigger = testTrigger; }
+#if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
+    WheelEventTestTrigger* testTrigger() const override { return m_wheelEventTestTrigger.get(); }
+#endif
+    
 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
     void updateScrollAnimatorsAndTimers();
@@ -128,6 +135,7 @@ protected:
     virtual void notifyPositionChanged(const FloatSize& delta);
 
     ScrollableArea& m_scrollableArea;
+    RefPtr<WheelEventTestTrigger> m_wheelEventTestTrigger;
 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
     ScrollController m_scrollController;
 #endif
index 7d5816d..7c1e15e 100644 (file)
@@ -42,6 +42,7 @@ namespace WebCore {
 
 class PlatformWheelEvent;
 class ScrollableArea;
+class WheelEventTestTrigger;
 
 class ScrollControllerClient {
 protected:
@@ -75,6 +76,8 @@ public:
     // the page to scroll to the nearest boundary point.
     virtual void adjustScrollPositionToBoundsIfNecessary() = 0;
 
+    virtual WheelEventTestTrigger* testTrigger() const { return nullptr; }
+
 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const = 0;
     virtual void immediateScrollOnAxis(ScrollEventAxis, float delta) = 0;
index 5d42b6e..43cc37c 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "PlatformWheelEvent.h"
 #include "WebCoreSystemInterface.h"
+#include "WheelEventTestTrigger.h"
 #include <sys/sysctl.h>
 #include <sys/time.h>
 
@@ -411,6 +412,9 @@ void ScrollController::startSnapRubberbandTimer()
 {
     m_client.startSnapRubberbandTimer();
     m_snapRubberbandTimer.startRepeating(1.0 / 60.0);
+
+    if (auto* trigger = m_client.testTrigger())
+        trigger->deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::RubberbandInProgress);
 }
 
 void ScrollController::stopSnapRubberbandTimer()
@@ -418,6 +422,9 @@ void ScrollController::stopSnapRubberbandTimer()
     m_client.stopSnapRubberbandTimer();
     m_snapRubberbandTimer.stop();
     m_snapRubberbandTimerIsActive = false;
+    
+    if (auto* trigger = m_client.testTrigger())
+        trigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::RubberbandInProgress);
 }
 
 void ScrollController::snapRubberBand()
@@ -613,6 +620,12 @@ void ScrollController::startScrollSnapTimer(ScrollEventAxis axis)
         m_client.startScrollSnapTimer(axis);
         scrollSnapTimer.startRepeating(1.0 / 60.0);
     }
+
+    if (!m_horizontalScrollSnapTimer.isActive() && !m_verticalScrollSnapTimer.isActive())
+        return;
+
+    if (auto* trigger = m_client.testTrigger())
+        trigger->deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::ScrollSnapInProgress);
 }
 
 void ScrollController::stopScrollSnapTimer(ScrollEventAxis axis)
@@ -620,6 +633,12 @@ void ScrollController::stopScrollSnapTimer(ScrollEventAxis axis)
     m_client.stopScrollSnapTimer(axis);
     RunLoop::Timer<ScrollController>& scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer : m_verticalScrollSnapTimer;
     scrollSnapTimer.stop();
+    
+    if (m_horizontalScrollSnapTimer.isActive() || m_verticalScrollSnapTimer.isActive())
+        return;
+
+    if (auto* trigger = m_client.testTrigger())
+        trigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::ScrollSnapInProgress);
 }
 
 void ScrollController::horizontalScrollSnapTimerFired()
index 8c5c76b..d17f6a5 100644 (file)
@@ -889,6 +889,11 @@ void ScrollAnimatorMac::didBeginScrollGesture() const
         return;
 
     [m_scrollbarPainterController beginScrollGesture];
+
+#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
+    if (m_wheelEventTestTrigger)
+        m_wheelEventTestTrigger->deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::ContentScrollInProgress);
+#endif
 }
 
 void ScrollAnimatorMac::didEndScrollGesture() const
@@ -897,6 +902,11 @@ void ScrollAnimatorMac::didEndScrollGesture() const
         return;
 
     [m_scrollbarPainterController endScrollGesture];
+
+#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
+    if (m_wheelEventTestTrigger)
+        m_wheelEventTestTrigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::ContentScrollInProgress);
+#endif
 }
 
 void ScrollAnimatorMac::mayBeginScrollGesture() const
@@ -1349,6 +1359,9 @@ void ScrollAnimatorMac::sendContentAreaScrolledSoon(const FloatSize& delta)
 
     if (!m_sendContentAreaScrolledTimer.isActive())
         m_sendContentAreaScrolledTimer.startOneShot(0);
+
+    if (m_wheelEventTestTrigger)
+        m_wheelEventTestTrigger->deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::ContentScrollInProgress);
 }
 
 void ScrollAnimatorMac::sendContentAreaScrolled(const FloatSize& delta)
@@ -1363,6 +1376,9 @@ void ScrollAnimatorMac::sendContentAreaScrolledTimerFired()
 {
     sendContentAreaScrolled(m_contentAreaScrolledTimerScrollDelta);
     m_contentAreaScrolledTimerScrollDelta = FloatSize();
+
+    if (m_wheelEventTestTrigger)
+        m_wheelEventTestTrigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(this), WheelEventTestTrigger::ContentScrollInProgress);
 }
 
 void ScrollAnimatorMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
index b5e9f1f..e8a0421 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
  *           (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2010, 2015 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -59,6 +59,7 @@
 #include "RenderTableCell.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "ScrollAnimator.h"
 #include "ScrollbarTheme.h"
 #include "TransformState.h"
 #include "htmlediting.h"
@@ -593,16 +594,32 @@ int RenderBox::scrollTop() const
     return hasOverflowClip() ? layer()->scrollYOffset() : 0;
 }
 
+static void setupWheelEventTestTrigger(RenderLayer& layer, Frame* frame)
+{
+    if (!frame)
+        return;
+
+    Page* page = frame->page();
+    if (!page || !page->expectsWheelEventTriggers())
+        return;
+
+    layer.scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
+}
+
 void RenderBox::setScrollLeft(int newLeft)
 {
-    if (hasOverflowClip())
+    if (hasOverflowClip()) {
+        setupWheelEventTestTrigger(*layer(), document().frame());
         layer()->scrollToXOffset(newLeft, RenderLayer::ScrollOffsetClamped);
+    }
 }
 
 void RenderBox::setScrollTop(int newTop)
 {
-    if (hasOverflowClip())
+    if (hasOverflowClip()) {
+        setupWheelEventTestTrigger(*layer(), document().frame());
         layer()->scrollToYOffset(newTop, RenderLayer::ScrollOffsetClamped);
+    }
 }
 
 void RenderBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
index 26ab956..97f7ed1 100644 (file)
 #include "TextStream.h"
 #include "TransformationMatrix.h"
 #include "TranslateTransformOperation.h"
+#include "WheelEventTestTrigger.h"
 #include <stdio.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
@@ -3075,6 +3076,10 @@ PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientat
     else {
         widget = Scrollbar::createNativeScrollbar(*this, orientation, RegularScrollbar);
         didAddScrollbar(widget.get(), orientation);
+        if (Page* page = renderer().frame().page()) {
+            if (page->expectsWheelEventTriggers())
+                scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
+        }
     }
     renderer().view().frameView().addChild(widget.get());
     return widget.release();
index c09f7b0..27c5ed5 100644 (file)
 #include "RenderText.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
+#include "ScrollAnimator.h"
 #include "Scrollbar.h"
 #include "ScrollbarTheme.h"
 #include "Settings.h"
 #include "SpatialNavigation.h"
 #include "StyleResolver.h"
+#include "WheelEventTestTrigger.h"
 #include <math.h>
 #include <wtf/StackStats.h>
 
@@ -661,13 +663,25 @@ int RenderListBox::scrollTop() const
     return m_indexOffset * itemHeight();
 }
 
+static void setupWheelEventTestTrigger(RenderListBox& renderer, Frame* frame)
+{
+    if (!frame)
+        return;
+
+    Page* page = frame->page();
+    if (!page || !page->expectsWheelEventTriggers())
+        return;
+
+    renderer.scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
+}
+
 void RenderListBox::setScrollTop(int newTop)
 {
     // Determine an index and scroll to it.    
     int index = newTop / itemHeight();
     if (index < 0 || index >= numItems() || index == m_indexOffset)
         return;
-    
+    setupWheelEventTestTrigger(*this, document().frame());
     scrollToOffsetWithoutAnimation(VerticalScrollbar, index);
 }
 
@@ -806,6 +820,10 @@ PassRefPtr<Scrollbar> RenderListBox::createScrollbar()
     else {
         widget = Scrollbar::createNativeScrollbar(*this, VerticalScrollbar, theme().scrollbarControlSizeForPart(ListboxPart));
         didAddScrollbar(widget.get(), VerticalScrollbar);
+        if (Page* page = frame().page()) {
+            if (page->expectsWheelEventTriggers())
+                scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
+        }
     }
     view().frameView().addChild(widget.get());
     return widget.release();
index 623ed99..f7c971c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,7 +31,7 @@
 #include "Internals.h"
 #include "JSDocument.h"
 #include "JSInternals.h"
-#include "MainFrame.h"
+#include "Page.h"
 #include "WheelEventTestTrigger.h"
 #include <JavaScriptCore/APICast.h>
 #include <JavaScriptCore/JSValueRef.h>
@@ -67,18 +67,34 @@ void resetInternalsObject(JSContextRef context)
 
 void monitorWheelEvents(WebCore::Frame& frame)
 {
-    frame.mainFrame().ensureTestTrigger();
+    Page* page = frame.page();
+    if (!page)
+        return;
+
+    page->ensureTestTrigger();
 }
 
 void setTestCallbackAndStartNotificationTimer(WebCore::Frame& frame, JSContextRef context, JSObjectRef jsCallbackFunction)
 {
-    WheelEventTestTrigger* trigger = frame.mainFrame().ensureTestTrigger();
+    Page* page = frame.page();
+    if (!page || !page->expectsWheelEventTriggers())
+        return;
+
     JSValueProtect(context, jsCallbackFunction);
     
-    trigger->setTestCallbackAndStartNotificationTimer([=](void) {
+    page->ensureTestTrigger().setTestCallbackAndStartNotificationTimer([=](void) {
         JSObjectCallAsFunction(context, jsCallbackFunction, nullptr, 0, nullptr, nullptr);
         JSValueUnprotect(context, jsCallbackFunction);
     });
 }
 
+void clearWheelEventTestTrigger(WebCore::Frame& frame)
+{
+    Page* page = frame.page();
+    if (!page)
+        return;
+    
+    page->clearTrigger();
+}
+
 }
index 30e2bd2..1dc8333 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,6 +45,7 @@ void injectInternalsObject(JSContextRef) TEST_SUPPORT_EXPORT;
 void resetInternalsObject(JSContextRef) TEST_SUPPORT_EXPORT;
 void monitorWheelEvents(WebCore::Frame&) TEST_SUPPORT_EXPORT;
 void setTestCallbackAndStartNotificationTimer(WebCore::Frame&, JSContextRef, JSObjectRef) TEST_SUPPORT_EXPORT;
+void clearWheelEventTestTrigger(WebCore::Frame&) TEST_SUPPORT_EXPORT;
 
 } // namespace WebCore
 
index da178e2..9252dae 100644 (file)
@@ -1,3 +1,34 @@
+2015-04-29  Brent Fulgham  <bfulgham@apple.com>
+
+        Expand test infrastructure to support scrolling tests
+        https://bugs.webkit.org/show_bug.cgi?id=143684
+        <rdar://problem/20375516>
+
+        Reviewed by Simon Fraser.
+
+        Update test programs to activate (and deactivate) the new WheelEventTestTrigger logic.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageClearWheelEventTestTriggers): Added.
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::clearWheelEventTestTrigger): Added.
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageStartMonitoringScrollOperations): Interact with WheelEventTestTrigger through
+        the Page, rather than MainFrame.
+        (WKBundlePageRegisterScrollOperationCompletionCallback): Ditto.
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::createScrollbar): Make sure scroll animator knows about any
+        active test triggers.
+        * WebPage/EventDispatcher.mm:
+        (WebKit::EventDispatcher::wheelEvent): If the wheel event was passed to the scrolling thread,
+        defer tests until a Scrolling Thread Sync has occurred.
+        * WebPage/WebPage.cpp:
+        (WebKit::WebPage::clearWheelEventTestTrigger): Added.
+        * WebPage/WebPage.h:
+        * WebPage/WebPage.message.in: Added ClearWheelEventTestTrigger message.
+
 2015-04-29  Enrica Casucci  <enrica@apple.com>
 
         Adding the ability to move selection by granularity on iOS.
index 9db513d..a7ae2d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -2201,6 +2201,12 @@ bool WKPageIsPlayingAudio(WKPageRef page)
     return toImpl(page)->isPlayingAudio();
 }
 
+void WKPageClearWheelEventTestTrigger(WKPageRef pageRef)
+{
+    toImpl(pageRef)->clearWheelEventTestTrigger();
+}
+
+
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 // -- DEPRECATED --
index f6a1970..34d40c1 100644 (file)
@@ -144,6 +144,7 @@ WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKTypeRef sessionSt
 
 WK_EXPORT double WKPageGetBackingScaleFactor(WKPageRef page);
 WK_EXPORT void WKPageSetCustomBackingScaleFactor(WKPageRef page, double customScaleFactor);
+WK_EXPORT void WKPageClearWheelEventTestTrigger(WKPageRef page);
 
 WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page);
 WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page);
index 9f430ba..3210970 100644 (file)
@@ -5794,4 +5794,12 @@ void WebPageProxy::didChangeBackgroundColor()
     m_pageClient.didChangeBackgroundColor();
 }
 
+void WebPageProxy::clearWheelEventTestTrigger()
+{
+    if (!isValid())
+        return;
+    
+    m_process->send(Messages::WebPage::ClearWheelEventTestTrigger(), m_pageID);
+}
+
 } // namespace WebKit
index 390f3ba..b49bb72 100644 (file)
@@ -1037,6 +1037,8 @@ public:
     void didChangeBackgroundColor();
     void didLayoutForCustomContentProvider();
 
+    void clearWheelEventTestTrigger();
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&);
     void platformInitialize();
index 9639125..6b0e627 100644 (file)
@@ -582,7 +582,7 @@ void WKBundlePageStartMonitoringScrollOperations(WKBundlePageRef pageRef)
     if (!page)
         return;
 
-    page->mainFrame().ensureTestTrigger();
+    page->ensureTestTrigger();
 }
 
 void WKBundlePageRegisterScrollOperationCompletionCallback(WKBundlePageRef pageRef, WKBundlePageTestNotificationCallback callback, void* context)
@@ -592,12 +592,10 @@ void WKBundlePageRegisterScrollOperationCompletionCallback(WKBundlePageRef pageR
     
     WebKit::WebPage* webPage = toImpl(pageRef);
     WebCore::Page* page = webPage ? webPage->corePage() : nullptr;
-    
-    if (!page)
+    if (!page || !page->expectsWheelEventTriggers())
         return;
     
-    WebCore::WheelEventTestTrigger* trigger = page->mainFrame().ensureTestTrigger();
-    trigger->setTestCallbackAndStartNotificationTimer([=]() {
+    page->ensureTestTrigger().setTestCallbackAndStartNotificationTimer([=]() {
         callback(context);
     });
 }
index 9487732..c7a5e7e 100644 (file)
 #import <WebCore/HTMLFormElement.h>
 #import <WebCore/HTMLPlugInElement.h>
 #import <WebCore/LocalizedStrings.h>
+#import <WebCore/MainFrame.h>
 #import <WebCore/MouseEvent.h>
 #import <WebCore/Page.h>
 #import <WebCore/Pasteboard.h>
 #import <WebCore/PluginData.h>
 #import <WebCore/PluginDocument.h>
 #import <WebCore/RenderBoxModelObject.h>
+#import <WebCore/ScrollAnimator.h>
 #import <WebCore/ScrollbarTheme.h>
 #import <WebCore/Settings.h>
 #import <WebCore/UUID.h>
+#import <WebCore/WheelEventTestTrigger.h>
 #import <WebKitSystemInterface.h>
 #import <wtf/CurrentTime.h>
 
@@ -660,6 +663,12 @@ PassRefPtr<Scrollbar> PDFPlugin::createScrollbar(ScrollbarOrientation orientatio
         [m_containerLayer addSublayer:m_verticalScrollbarLayer.get()];
     }
     didAddScrollbar(widget.get(), orientation);
+    if (Frame* frame = webFrame()->coreFrame()) {
+        if (Page* page = frame->page()) {
+            if (page->expectsWheelEventTriggers())
+                scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
+        }
+    }
     pluginView()->frame()->view()->addChild(widget.get());
     return widget.release();
 }
index 87cb5cc..b2c9d89 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2014-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,6 +33,7 @@
 #include "WebPageProxyMessages.h"
 #include "WebProcess.h"
 #include <WebCore/Page.h>
+#include <WebCore/WheelEventTestTrigger.h>
 #include <wtf/MainThread.h>
 #include <wtf/RunLoop.h>
 
@@ -87,6 +88,17 @@ void EventDispatcher::initializeConnection(IPC::Connection* connection)
     connection->addWorkQueueMessageReceiver(Messages::EventDispatcher::messageReceiverName(), &m_queue.get(), this);
 }
 
+static void updateWheelEventTestTriggersIfNeeded(uint64_t pageID)
+{
+    WebPage* webPage = WebProcess::singleton().webPage(pageID);
+    Page* page = webPage ? webPage->corePage() : nullptr;
+
+    if (!page || !page->expectsWheelEventTriggers())
+        return;
+
+    page->testTrigger()->deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(page), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
+}
+
 void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEvent, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
 {
     PlatformWheelEvent platformWheelEvent = platform(wheelEvent);
@@ -131,6 +143,12 @@ void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEven
         }
 
         ScrollingTree::EventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent);
+
+#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
+        if (result == ScrollingTree::DidHandleEvent)
+            updateWheelEventTestTriggersIfNeeded(pageID);
+#endif
+
         if (result == ScrollingTree::DidHandleEvent || result == ScrollingTree::DidNotHandleEvent) {
             sendDidReceiveEvent(pageID, wheelEvent, result == ScrollingTree::DidHandleEvent);
             return;
index e472ffc..2042075 100644 (file)
@@ -4903,4 +4903,12 @@ void WebPage::postSynchronousMessage(const String& messageName, API::Object* mes
         returnData = webProcess.transformHandlesToObjects(returnUserData.object());
 }
 
+void WebPage::clearWheelEventTestTrigger()
+{
+    if (!m_page)
+        return;
+
+    m_page->clearTrigger();
+}
+
 } // namespace WebKit
index 72c8319..5062994 100644 (file)
@@ -1118,6 +1118,8 @@ private:
     void setShouldPlayToPlaybackTarget(uint64_t, bool);
 #endif
 
+    void clearWheelEventTestTrigger();
+
     uint64_t m_pageID;
 
     std::unique_ptr<WebCore::Page> m_page;
index e3b3834..ea60253 100644 (file)
@@ -425,4 +425,5 @@ messages -> WebPage LegacyReceiver {
     SetShouldPlayToPlaybackTarget(uint64_t contextId, bool shouldPlay)
 #endif
 
+    ClearWheelEventTestTrigger()
 }
index 5bf9661..1ac4438 100644 (file)
@@ -1,3 +1,17 @@
+2015-04-29  Brent Fulgham  <bfulgham@apple.com>
+
+        Expand test infrastructure to support scrolling tests
+        https://bugs.webkit.org/show_bug.cgi?id=143684
+        <rdar://problem/20375516>
+
+        Reviewed by Simon Fraser.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebViewToConsistentStateBeforeTesting): Make sure the WheelEventTestTrigger state is
+        reset before the next test run.
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues): Ditto."
+
 2015-04-29  Alex Christensen  <achristensen@webkit.org>
 
         Run javascriptcore tests on Windows without cygwin
index be91ece..2ea5a56 100644 (file)
@@ -154,6 +154,12 @@ using namespace std;
 - (BOOL)_flushCompositingChanges;
 @end
 
+#if !PLATFORM(IOS)
+@interface WebView (WebViewInternalForTesting)
+- (WebCore::Frame*)_mainCoreFrame;
+@end
+#endif
+
 static void runTest(const string& testURL);
 
 // Deciding when it's OK to dump out the state is a bit tricky.  All these must be true:
@@ -1824,6 +1830,11 @@ static void resetWebViewToConsistentStateBeforeTesting()
     }
 
 #if !PLATFORM(IOS)
+    if (WebCore::Frame* frame = [webView _mainCoreFrame])
+        WebCoreTestSupport::clearWheelEventTestTrigger(*frame);
+#endif
+
+#if !PLATFORM(IOS)
     [webView setContinuousSpellCheckingEnabled:YES];
     [webView setAutomaticQuoteSubstitutionEnabled:NO];
     [webView setAutomaticLinkDetectionEnabled:NO];
index eb126d1..971c911 100644 (file)
@@ -660,6 +660,8 @@ bool TestController::resetStateToConsistentValues()
     // Re-set to the default backing scale factor by setting the custom scale factor to 0.
     WKPageSetCustomBackingScaleFactor(m_mainWebView->page(), 0);
 
+    WKPageClearWheelEventTestTrigger(m_mainWebView->page());
+
 #if PLATFORM(EFL)
     // EFL use a real window while other ports such as Qt don't.
     // In EFL, we need to resize the window to the original size after calls to window.resizeTo.