Ignore:
Timestamp:
Apr 29, 2015, 5:29:05 PM (10 years ago)
Author:
Brent Fulgham
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."

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp

    r181485 r183595  
    11/*
    2  * Copyright (C) 2011, 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011, 2014-2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434#include "WebProcess.h"
    3535#include <WebCore/Page.h>
     36#include <WebCore/WheelEventTestTrigger.h>
    3637#include <wtf/MainThread.h>
    3738#include <wtf/RunLoop.h>
     
    8687{
    8788    connection->addWorkQueueMessageReceiver(Messages::EventDispatcher::messageReceiverName(), &m_queue.get(), this);
     89}
     90
     91static void updateWheelEventTestTriggersIfNeeded(uint64_t pageID)
     92{
     93    WebPage* webPage = WebProcess::singleton().webPage(pageID);
     94    Page* page = webPage ? webPage->corePage() : nullptr;
     95
     96    if (!page || !page->expectsWheelEventTriggers())
     97        return;
     98
     99    page->testTrigger()->deferTestsForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(page), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
    88100}
    89101
     
    132144
    133145        ScrollingTree::EventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent);
     146
     147#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
     148        if (result == ScrollingTree::DidHandleEvent)
     149            updateWheelEventTestTriggersIfNeeded(pageID);
     150#endif
     151
    134152        if (result == ScrollingTree::DidHandleEvent || result == ScrollingTree::DidNotHandleEvent) {
    135153            sendDidReceiveEvent(pageID, wheelEvent, result == ScrollingTree::DidHandleEvent);
Note: See TracChangeset for help on using the changeset viewer.