Title: [183595] trunk
Revision
183595
Author
[email protected]
Date
2015-04-29 17:29:05 -0700 (Wed, 29 Apr 2015)

Log Message

Expand test infrastructure to support scrolling tests
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."

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183594 => 183595)


--- trunk/Source/WebCore/ChangeLog	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/ChangeLog	2015-04-30 00:29:05 UTC (rev 183595)
@@ -1,3 +1,76 @@
+2015-04-29  Brent Fulgham  <[email protected]>
+
+        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  <[email protected]>
 
         [CSS Box Alignment] Unifying alignment data in a single class

Modified: trunk/Source/WebCore/page/FrameView.cpp (183594 => 183595)


--- trunk/Source/WebCore/page/FrameView.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/FrameView.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
                     // 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 @@
 {
     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::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);
 }

Modified: trunk/Source/WebCore/page/MainFrame.cpp (183594 => 183595)


--- trunk/Source/WebCore/page/MainFrame.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/MainFrame.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
 }
 #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;
-}
-
-}

Modified: trunk/Source/WebCore/page/MainFrame.h (183594 => 183595)


--- trunk/Source/WebCore/page/MainFrame.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/MainFrame.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -37,7 +37,6 @@
 class ScrollLatchingState;
 class ServicesOverlayController;
 class WheelEventDeltaTracker;
-class WheelEventTestTrigger;
 
 class MainFrame final : public Frame {
 public:
@@ -64,10 +63,6 @@
 
     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 @@
     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;

Modified: trunk/Source/WebCore/page/Page.cpp (183594 => 183595)


--- trunk/Source/WebCore/page/Page.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/Page.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
 }
 #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

Modified: trunk/Source/WebCore/page/Page.h (183594 => 183595)


--- trunk/Source/WebCore/page/Page.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/Page.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
     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 @@
     Ref<StorageNamespaceProvider> m_storageNamespaceProvider;
     RefPtr<UserContentController> m_userContentController;
     Ref<VisitedLinkStore> m_visitedLinkStore;
+    RefPtr<WheelEventTestTrigger> m_testTrigger;
 
     HashSet<ViewStateChangeObserver*> m_viewStateChangeObservers;
 

Modified: trunk/Source/WebCore/page/WheelEventTestTrigger.cpp (183594 => 183595)


--- trunk/Source/WebCore/page/WheelEventTestTrigger.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/WheelEventTestTrigger.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -33,15 +33,9 @@
 
 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);

Modified: trunk/Source/WebCore/page/WheelEventTestTrigger.h (183594 => 183595)


--- trunk/Source/WebCore/page/WheelEventTestTrigger.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/WheelEventTestTrigger.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -32,12 +32,13 @@
 #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 @@
         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;
 };
 
 }

Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (183594 => 183595)


--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
         }
     }
     
+    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) {

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (183594 => 183595)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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
@@ -34,12 +34,14 @@
 #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 @@
             }
         }
 
+#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 @@
         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
     }
 }
 

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (183594 => 183595)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 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 @@
 
     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 @@
     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

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (183594 => 183595)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -42,6 +42,7 @@
 
 class PlatformWheelEvent;
 class ScrollableArea;
+class WheelEventTestTrigger;
 
 class ScrollControllerClient {
 protected:
@@ -75,6 +76,8 @@
     // 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;

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (183594 => 183595)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
 {
     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 @@
     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 @@
         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 @@
     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()

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (183594 => 183595)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2015-04-30 00:29:05 UTC (rev 183595)
@@ -889,6 +889,11 @@
         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 @@
         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 @@
 
     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 @@
 {
     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)

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (183594 => 183595)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2005 Allan Sandfeld Jensen ([email protected])
  *           (C) 2005, 2006 Samuel Weinig ([email protected])
- * 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 @@
     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

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (183594 => 183595)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -119,6 +119,7 @@
 #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 @@
     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();

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (183594 => 183595)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -53,11 +53,13 @@
 #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 @@
     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 @@
     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();

Modified: trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp (183594 => 183595)


--- trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 <_javascript_Core/APICast.h>
 #include <_javascript_Core/JSValueRef.h>
@@ -67,18 +67,34 @@
 
 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();
 }
+
+}

Modified: trunk/Source/WebCore/testing/js/WebCoreTestSupport.h (183594 => 183595)


--- trunk/Source/WebCore/testing/js/WebCoreTestSupport.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebCore/testing/js/WebCoreTestSupport.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 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
 

Modified: trunk/Source/WebKit2/ChangeLog (183594 => 183595)


--- trunk/Source/WebKit2/ChangeLog	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-30 00:29:05 UTC (rev 183595)
@@ -1,3 +1,34 @@
+2015-04-29  Brent Fulgham  <[email protected]>
+
+        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  <[email protected]>
 
         Adding the ability to move selection by granularity on iOS.

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (183594 => 183595)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
     return toImpl(page)->isPlayingAudio();
 }
 
+void WKPageClearWheelEventTestTrigger(WKPageRef pageRef)
+{
+    toImpl(pageRef)->clearWheelEventTestTrigger();
+}
+
+
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 // -- DEPRECATED --

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.h (183594 => 183595)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -144,6 +144,7 @@
 
 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);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (183594 => 183595)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -5794,4 +5794,12 @@
     m_pageClient.didChangeBackgroundColor();
 }
 
+void WebPageProxy::clearWheelEventTestTrigger()
+{
+    if (!isValid())
+        return;
+    
+    m_process->send(Messages::WebPage::ClearWheelEventTestTrigger(), m_pageID);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (183594 => 183595)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -1037,6 +1037,8 @@
     void didChangeBackgroundColor();
     void didLayoutForCustomContentProvider();
 
+    void clearWheelEventTestTrigger();
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&);
     void platformInitialize();

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (183594 => 183595)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -582,7 +582,7 @@
     if (!page)
         return;
 
-    page->mainFrame().ensureTestTrigger();
+    page->ensureTestTrigger();
 }
 
 void WKBundlePageRegisterScrollOperationCompletionCallback(WKBundlePageRef pageRef, WKBundlePageTestNotificationCallback callback, void* context)
@@ -592,12 +592,10 @@
     
     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);
     });
 }

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (183594 => 183595)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm	2015-04-30 00:29:05 UTC (rev 183595)
@@ -68,15 +68,18 @@
 #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 @@
         [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();
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp (183594 => 183595)


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -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 @@
     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 @@
         }
 
         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;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (183594 => 183595)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -4903,4 +4903,12 @@
         returnData = webProcess.transformHandlesToObjects(returnUserData.object());
 }
 
+void WebPage::clearWheelEventTestTrigger()
+{
+    if (!m_page)
+        return;
+
+    m_page->clearTrigger();
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (183594 => 183595)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2015-04-30 00:29:05 UTC (rev 183595)
@@ -1118,6 +1118,8 @@
     void setShouldPlayToPlaybackTarget(uint64_t, bool);
 #endif
 
+    void clearWheelEventTestTrigger();
+
     uint64_t m_pageID;
 
     std::unique_ptr<WebCore::Page> m_page;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (183594 => 183595)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2015-04-30 00:29:05 UTC (rev 183595)
@@ -425,4 +425,5 @@
     SetShouldPlayToPlaybackTarget(uint64_t contextId, bool shouldPlay)
 #endif
 
+    ClearWheelEventTestTrigger()
 }

Modified: trunk/Tools/ChangeLog (183594 => 183595)


--- trunk/Tools/ChangeLog	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Tools/ChangeLog	2015-04-30 00:29:05 UTC (rev 183595)
@@ -1,3 +1,17 @@
+2015-04-29  Brent Fulgham  <[email protected]>
+
+        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  <[email protected]>
 
         Run _javascript_core tests on Windows without cygwin

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (183594 => 183595)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2015-04-30 00:29:05 UTC (rev 183595)
@@ -154,6 +154,12 @@
 - (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 @@
     }
 
 #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];

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (183594 => 183595)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2015-04-30 00:28:04 UTC (rev 183594)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2015-04-30 00:29:05 UTC (rev 183595)
@@ -660,6 +660,8 @@
     // 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.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to