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)
commit7e77da42343242f48ac6df3da1319fc565793c25
treed96ff6dd9921b345f518c2d95a9c7426b406db2c
parent235c077c13074c5b921bd24ec645b8d639fede82
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."

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