Diff
Modified: trunk/Source/WebCore/ChangeLog (262293 => 262294)
--- trunk/Source/WebCore/ChangeLog 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/ChangeLog 2020-05-29 14:56:21 UTC (rev 262294)
@@ -1,3 +1,57 @@
+2020-05-29 Simon Fraser <[email protected]>
+
+ Prepare for async scrolling in passive wheel event handler regions
+ https://bugs.webkit.org/show_bug.cgi?id=212455
+
+ Reviewed by Tim Horton.
+
+ Clarify the processing for wheel events by adding OptionSet<WheelEventProcessingSteps>,
+ which will, in future, allow us to describe the processing for an event in the passive
+ event handler region which does scrolling on the scrolling thread, and is then sent
+ to the main thread for DOM event dispatch.
+
+ Removed ScrollingEventResult, which conflated "handled" with "send to another thread".
+ The thread sending behavior is now encoded in the WheelEventProcessingSteps, and we can just
+ use a bool for handled.
+
+ Scrolling tree and node handleWheelEvent() functions return a WheelEventHandlingResult, which
+ is a tuple of OptionSet<WheelEventProcessingSteps> and 'handled', allowing for a node with
+ background-attachment:fixed to add the "send to main thread" processing step.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::wheelEvent):
+ * page/scrolling/ScrollingCoordinator.h:
+ (WebCore::ScrollingCoordinator::handleWheelEvent):
+ * page/scrolling/ScrollingCoordinatorTypes.h:
+ * page/scrolling/ScrollingTree.cpp:
+ (WebCore::ScrollingTree::determineWheelEventProcessing):
+ (WebCore::ScrollingTree::handleWheelEvent):
+ (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously): Deleted.
+ * page/scrolling/ScrollingTree.h:
+ (WebCore::WheelEventHandlingResult::needsMainThreadProcessing const):
+ (WebCore::WheelEventHandlingResult::handled):
+ (WebCore::WheelEventHandlingResult::unhandled):
+ (WebCore::WheelEventHandlingResult::result):
+ * page/scrolling/ScrollingTreeScrollingNode.cpp:
+ (WebCore::ScrollingTreeScrollingNode::handleWheelEvent):
+ * page/scrolling/ScrollingTreeScrollingNode.h:
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::handleWheelEvent):
+ (WebCore::ThreadedScrollingTree::handleWheelEventAfterMainThread):
+ * page/scrolling/ThreadedScrollingTree.h:
+ * page/scrolling/mac/ScrollingCoordinatorMac.h:
+ * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+ (WebCore::ScrollingCoordinatorMac::handleWheelEvent):
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent):
+ * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h:
+ * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeOverflowScrollingNodeMac::handleWheelEvent):
+ * platform/PlatformWheelEvent.cpp:
+ (WebCore::operator<<):
+ * platform/PlatformWheelEvent.h:
+
2020-05-29 Sergio Villar Senin <[email protected]>
[WebXR] ActiveDOMObjects must call suspendIfNeeded() upon creation
Modified: trunk/Source/WebCore/page/FrameView.cpp (262293 => 262294)
--- trunk/Source/WebCore/page/FrameView.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/FrameView.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -5091,7 +5091,7 @@
#if ENABLE(ASYNC_SCROLLING)
if (auto scrollingCoordinator = this->scrollingCoordinator()) {
if (scrollingCoordinator->coordinatesScrollingForFrameView(*this))
- return scrollingCoordinator->handleWheelEvent(*this, wheelEvent) != ScrollingEventResult::DidNotHandleEvent;
+ return scrollingCoordinator->handleWheelEvent(*this, wheelEvent);
}
#endif
Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -127,7 +127,7 @@
// These virtual functions are currently unique to the threaded scrolling architecture.
virtual void commitTreeStateIfNeeded() { }
virtual bool requestScrollPositionUpdate(ScrollableArea&, const IntPoint&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped) { return false; }
- virtual ScrollingEventResult handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return ScrollingEventResult::DidNotHandleEvent; }
+ virtual bool handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return false; }
// Create an unparented node.
virtual ScrollingNodeID createNode(ScrollingNodeType, ScrollingNodeID newNodeID) { return newNodeID; }
Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -95,13 +95,6 @@
}
};
-enum class ScrollingEventResult {
- DidNotHandleEvent,
- DidHandleEvent,
- SendToScrollingThread,
- SendToMainThread,
-};
-
enum class ViewportRectStability {
Stable,
Unstable,
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -63,7 +63,7 @@
ScrollingTree::~ScrollingTree() = default;
-bool ScrollingTree::shouldHandleWheelEventSynchronously(const PlatformWheelEvent& wheelEvent)
+OptionSet<WheelEventProcessingSteps> ScrollingTree::determineWheelEventProcessing(const PlatformWheelEvent& wheelEvent)
{
// This method is invoked by the event handling thread
LockHolder lock(m_treeStateMutex);
@@ -70,10 +70,10 @@
LOG_WITH_STREAM(ScrollLatching, stream << "ScrollingTree::shouldHandleWheelEventSynchronously " << wheelEvent << " have latched node " << m_latchingController.latchedNodeForEvent(wheelEvent, m_allowLatching));
if (m_latchingController.latchedNodeForEvent(wheelEvent, m_allowLatching))
- return false;
+ return { WheelEventProcessingSteps::ScrollingThread };
m_latchingController.receivedWheelEvent(wheelEvent, m_allowLatching);
-
+
if (!m_treeState.eventTrackingRegions.isEmpty() && m_rootNode) {
FloatPoint position = wheelEvent.position();
position.move(m_rootNode->viewToContentsOffset(m_treeState.mainFrameScrollPosition));
@@ -87,12 +87,12 @@
LOG_WITH_STREAM(Scrolling, stream << "\n\nScrollingTree::shouldHandleWheelEventSynchronously: wheelEvent " << wheelEvent << " mapped to content point " << position << ", in non-fast region " << isSynchronousDispatchRegion);
if (isSynchronousDispatchRegion)
- return true;
+ return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForDOMEventDispatch };
}
- return false;
+ return { WheelEventProcessingSteps::ScrollingThread };
}
-ScrollingEventResult ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
LOG_WITH_STREAM(Scrolling, stream << "\nScrollingTree " << this << " handleWheelEvent " << wheelEvent);
@@ -105,13 +105,13 @@
auto result = [&] {
if (!m_rootNode)
- return ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::unhandled();
if (!asyncFrameOrOverflowScrollingEnabled())
return m_rootNode->handleWheelEvent(wheelEvent);
if (m_gestureState.handleGestureCancel(wheelEvent))
- return ScrollingEventResult::DidHandleEvent;
+ return WheelEventHandlingResult::handled();
m_gestureState.receivedWheelEvent(wheelEvent);
@@ -120,12 +120,12 @@
auto* node = nodeForID(*latchedNodeID);
if (is<ScrollingTreeScrollingNode>(node)) {
auto result = downcast<ScrollingTreeScrollingNode>(*node).handleWheelEvent(wheelEvent);
- if (result == ScrollingEventResult::DidHandleEvent)
+ if (result.wasHandled)
m_gestureState.nodeDidHandleEvent(*latchedNodeID, wheelEvent);
return result;
}
}
-
+
FloatPoint position = wheelEvent.position();
position.move(m_rootNode->viewToContentsOffset(m_treeState.mainFrameScrollPosition));
auto node = scrollingNodeForPoint(position);
@@ -137,12 +137,13 @@
auto& scrollingNode = downcast<ScrollingTreeScrollingNode>(*node);
auto result = scrollingNode.handleWheelEvent(wheelEvent);
- if (result == ScrollingEventResult::DidHandleEvent) {
+ if (result.wasHandled) {
m_latchingController.nodeDidHandleEvent(scrollingNode.scrollingNodeID(), wheelEvent, m_allowLatching);
m_gestureState.nodeDidHandleEvent(scrollingNode.scrollingNodeID(), wheelEvent);
+ return result;
}
- if (result != ScrollingEventResult::DidNotHandleEvent)
+ if (result.needsMainThreadProcessing())
return result;
}
@@ -155,7 +156,7 @@
node = node->parent();
}
- return ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::unhandled();
}();
return result;
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -56,6 +56,25 @@
enum class EventListenerRegionType : uint8_t;
using PlatformDisplayID = uint32_t;
+struct WheelEventHandlingResult {
+ OptionSet<WheelEventProcessingSteps> steps;
+ bool wasHandled { false };
+ bool needsMainThreadProcessing() const { return steps.containsAny({ WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForDOMEventDispatch }); }
+
+ static WheelEventHandlingResult handled()
+ {
+ return { { }, true };
+ }
+ static WheelEventHandlingResult unhandled()
+ {
+ return { { }, false };
+ }
+ static WheelEventHandlingResult result(bool handled)
+ {
+ return { { }, handled };
+ }
+};
+
class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
friend class ScrollingTreeLatchingController;
public:
@@ -70,8 +89,8 @@
bool asyncFrameOrOverflowScrollingEnabled() const { return m_asyncFrameOrOverflowScrollingEnabled; }
void setAsyncFrameOrOverflowScrollingEnabled(bool);
- WEBCORE_EXPORT bool shouldHandleWheelEventSynchronously(const PlatformWheelEvent&);
- WEBCORE_EXPORT virtual ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&);
+ WEBCORE_EXPORT OptionSet<WheelEventProcessingSteps> determineWheelEventProcessing(const PlatformWheelEvent&);
+ WEBCORE_EXPORT virtual WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&);
void setMainFrameIsRubberBanding(bool);
bool isRubberBandInProgress();
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -150,9 +150,9 @@
return eventCanScrollContents(wheelEvent);
}
-ScrollingEventResult ScrollingTreeScrollingNode::handleWheelEvent(const PlatformWheelEvent&)
+WheelEventHandlingResult ScrollingTreeScrollingNode::handleWheelEvent(const PlatformWheelEvent&)
{
- return ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::unhandled();
}
FloatPoint ScrollingTreeScrollingNode::clampScrollPosition(const FloatPoint& scrollPosition) const
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -39,6 +39,7 @@
class ScrollingTree;
class ScrollingStateScrollingNode;
+struct WheelEventHandlingResult;
class WEBCORE_EXPORT ScrollingTreeScrollingNode : public ScrollingTreeNode {
friend class ScrollingTreeScrollingNodeDelegate;
@@ -55,7 +56,7 @@
void didCompleteCommitForNode() final;
virtual bool canHandleWheelEvent(const PlatformWheelEvent&) const;
- virtual ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&);
+ virtual WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&);
FloatPoint currentScrollPosition() const { return m_currentScrollPosition; }
FloatPoint currentScrollOffset() const { return ScrollableArea::scrollOffsetFromPosition(m_currentScrollPosition, toFloatSize(m_scrollOrigin)); }
Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -55,16 +55,17 @@
ASSERT(!m_scrollingCoordinator);
}
-ScrollingEventResult ThreadedScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ThreadedScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
ASSERT(ScrollingThread::isCurrentThread());
return ScrollingTree::handleWheelEvent(wheelEvent);
}
-ScrollingEventResult ThreadedScrollingTree::handleWheelEventAfterMainThread(const PlatformWheelEvent& wheelEvent)
+bool ThreadedScrollingTree::handleWheelEventAfterMainThread(const PlatformWheelEvent& wheelEvent)
{
SetForScope<bool> disallowLatchingScope(m_allowLatching, false);
- return handleWheelEvent(wheelEvent);
+ auto result = handleWheelEvent(wheelEvent);
+ return result.wasHandled;
}
void ThreadedScrollingTree::invalidate()
Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -45,9 +45,9 @@
public:
virtual ~ThreadedScrollingTree();
- ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
+ WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&) override;
- ScrollingEventResult handleWheelEventAfterMainThread(const PlatformWheelEvent&);
+ bool handleWheelEventAfterMainThread(const PlatformWheelEvent&);
void invalidate() override;
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -41,7 +41,7 @@
void commitTreeStateIfNeeded() final;
// Handle the wheel event on the scrolling thread. Returns whether the event was handled or not.
- ScrollingEventResult handleWheelEvent(FrameView&, const PlatformWheelEvent&) override;
+ bool handleWheelEvent(FrameView&, const PlatformWheelEvent&) override;
private:
void scheduleTreeStateCommit() final;
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2020-05-29 14:56:21 UTC (rev 262294)
@@ -73,19 +73,19 @@
});
}
-ScrollingEventResult ScrollingCoordinatorMac::handleWheelEvent(FrameView&, const PlatformWheelEvent& wheelEvent)
+bool ScrollingCoordinatorMac::handleWheelEvent(FrameView&, const PlatformWheelEvent& wheelEvent)
{
ASSERT(isMainThread());
ASSERT(m_page);
if (scrollingTree()->willWheelEventStartSwipeGesture(wheelEvent))
- return ScrollingEventResult::DidNotHandleEvent;
+ return false;
RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree());
ScrollingThread::dispatch([threadedScrollingTree, wheelEvent] {
threadedScrollingTree->handleWheelEventAfterMainThread(wheelEvent);
});
- return ScrollingEventResult::DidHandleEvent;
+ return true;
}
void ScrollingCoordinatorMac::scheduleTreeStateCommit()
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -51,7 +51,7 @@
void commitStateBeforeChildren(const ScrollingStateNode&) override;
void commitStateAfterChildren(const ScrollingStateNode&) override;
- ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
+ WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&) override;
WEBCORE_EXPORT void repositionRelatedLayers() override;
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm 2020-05-29 14:56:21 UTC (rev 262294)
@@ -116,10 +116,10 @@
updateMainFramePinAndRubberbandState();
}
-ScrollingEventResult ScrollingTreeFrameScrollingNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ScrollingTreeFrameScrollingNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
if (!canHandleWheelEvent(wheelEvent))
- return ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::unhandled();
bool handled = m_delegate.handleWheelEvent(wheelEvent);
@@ -130,7 +130,7 @@
if (m_delegate.activeScrollSnapIndexDidChange())
scrollingTree().setActiveScrollSnapIndices(scrollingNodeID(), m_delegate.activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal), m_delegate.activeScrollSnapIndexForAxis(ScrollEventAxis::Vertical));
#endif
- return handled ? ScrollingEventResult::DidHandleEvent : ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::result(handled);
}
FloatPoint ScrollingTreeFrameScrollingNodeMac::adjustedScrollPosition(const FloatPoint& position, ScrollClamping clamp) const
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -50,7 +50,7 @@
void repositionScrollingLayers() override;
void repositionRelatedLayers() override;
- ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
+ WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&) override;
private:
void willBeDestroyed() final;
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm 2020-05-29 14:56:21 UTC (rev 262294)
@@ -72,18 +72,17 @@
}
}
-ScrollingEventResult ScrollingTreeOverflowScrollingNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ScrollingTreeOverflowScrollingNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
#if ENABLE(SCROLLING_THREAD)
if (hasSynchronousScrollingReasons())
- return ScrollingEventResult::SendToMainThread;
+ return { { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForDOMEventDispatch }, false };
#endif
if (!canHandleWheelEvent(wheelEvent))
- return ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::unhandled();
- bool handled = m_delegate.handleWheelEvent(wheelEvent);
- return handled ? ScrollingEventResult::DidHandleEvent : ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::result(m_delegate.handleWheelEvent(wheelEvent));
}
FloatPoint ScrollingTreeOverflowScrollingNodeMac::adjustedScrollPosition(const FloatPoint& position, ScrollClamping clamp) const
Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -69,7 +69,7 @@
m_scrollingStateTreeCommitterTimer.stop();
}
-ScrollingEventResult ScrollingCoordinatorNicosia::handleWheelEvent(FrameView&, const PlatformWheelEvent& wheelEvent)
+bool ScrollingCoordinatorNicosia::handleWheelEvent(FrameView&, const PlatformWheelEvent& wheelEvent)
{
ASSERT(isMainThread());
ASSERT(m_page);
@@ -78,7 +78,7 @@
ScrollingThread::dispatch([threadedScrollingTree = makeRef(downcast<ThreadedScrollingTree>(*scrollingTree())), wheelEvent] {
threadedScrollingTree->handleWheelEvent(wheelEvent);
});
- return ScrollingEventResult::DidHandleEvent;
+ return true;
}
void ScrollingCoordinatorNicosia::scheduleTreeStateCommit()
Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -44,7 +44,7 @@
void commitTreeStateIfNeeded() override;
- ScrollingEventResult handleWheelEvent(FrameView&, const PlatformWheelEvent&) override;
+ bool handleWheelEvent(FrameView&, const PlatformWheelEvent&) override;
private:
void scheduleTreeStateCommit() override;
Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -114,10 +114,10 @@
}
}
-ScrollingEventResult ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
if (!canHandleWheelEvent(wheelEvent))
- return ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::unhandled();
if (wheelEvent.deltaX() || wheelEvent.deltaY()) {
auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer());
@@ -145,7 +145,7 @@
#endif
// FIXME: This needs to return whether the event was handled.
- return ScrollingEventResult::DidHandleEvent;
+ return WheelEventHandlingResult::handled();
}
void ScrollingTreeFrameScrollingNodeNicosia::stopScrollAnimations()
Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -52,7 +52,7 @@
void commitStateBeforeChildren(const ScrollingStateNode&) override;
void commitStateAfterChildren(const ScrollingStateNode&) override;
- ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
+ WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&) override;
void stopScrollAnimations() override;
Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -99,10 +99,10 @@
});
}
-ScrollingEventResult ScrollingTreeOverflowScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ScrollingTreeOverflowScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
if (!canHandleWheelEvent(wheelEvent))
- return ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::unhandled();
if (wheelEvent.deltaX() || wheelEvent.deltaY()) {
auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrollContainerLayer());
@@ -129,7 +129,7 @@
}
#endif
- return ScrollingEventResult::DidHandleEvent;
+ return WheelEventHandlingResult::handled();
}
void ScrollingTreeOverflowScrollingNodeNicosia::stopScrollAnimations()
Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h (262293 => 262294)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -49,7 +49,7 @@
void repositionScrollingLayers() override;
- ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
+ WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&) override;
void stopScrollAnimations() override;
Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.cpp (262293 => 262294)
--- trunk/Source/WebCore/platform/PlatformWheelEvent.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -59,4 +59,14 @@
return ts;
}
+TextStream& operator<<(TextStream& ts, WheelEventProcessingSteps steps)
+{
+ switch (steps) {
+ case WheelEventProcessingSteps::ScrollingThread: ts << "scrolling thread"; break;
+ case WheelEventProcessingSteps::MainThreadForScrolling: ts << "main thread scrolling"; break;
+ case WheelEventProcessingSteps::MainThreadForDOMEventDispatch: ts << "main thread DOM evnet dispatch"; break;
+ }
+ return ts;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (262293 => 262294)
--- trunk/Source/WebCore/platform/PlatformWheelEvent.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -40,6 +40,12 @@
namespace WebCore {
+enum class WheelEventProcessingSteps : uint8_t {
+ ScrollingThread = 1 << 0,
+ MainThreadForScrolling = 1 << 1,
+ MainThreadForDOMEventDispatch = 1 << 2,
+};
+
// The ScrollByPixelWheelEvent is a fine-grained event that specifies the precise number of pixels to scroll.
// It is sent directly by touch pads on macOS, or synthesized when platforms generate line-by-line scrolling events.
//
@@ -254,5 +260,6 @@
#endif // ENABLE(KINETIC_SCROLLING)
WTF::TextStream& operator<<(WTF::TextStream&, const PlatformWheelEvent&);
+WTF::TextStream& operator<<(WTF::TextStream&, WheelEventProcessingSteps);
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (262293 => 262294)
--- trunk/Source/WebKit/ChangeLog 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebKit/ChangeLog 2020-05-29 14:56:21 UTC (rev 262294)
@@ -1,3 +1,34 @@
+2020-05-29 Simon Fraser <[email protected]>
+
+ Prepare for async scrolling in passive wheel event handler regions
+ https://bugs.webkit.org/show_bug.cgi?id=212455
+
+ Reviewed by Tim Horton.
+
+ Clarify the processing for wheel events by adding OptionSet<WheelEventProcessingSteps>,
+ which will, in future, allow us to describe the processing for an event in the passive
+ event handler region which does scrolling on the scrolling thread, and is then sent
+ to the main thread for DOM event dispatch.
+
+ Removed ScrollingEventResult, which conflated "handled" with "send to another thread".
+ The thread sending behavior is now encoded in the WheelEventProcessingSteps, and we can just
+ use a bool for handled.
+
+ Scrolling tree and node handleWheelEvent() functions return a WheelEventHandlingResult, which
+ is a tuple of OptionSet<WheelEventProcessingSteps> and 'handled', allowing for a node with
+ background-attachment:fixed to add the "send to main thread" processing step.
+
+ * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
+ (WebKit::RemoteScrollingCoordinatorProxy::handleWheelEvent):
+ * UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp:
+ (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::handleWheelEvent):
+ * UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h:
+ * UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp:
+ (WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::handleWheelEvent):
+ * UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h:
+ * WebProcess/WebPage/EventDispatcher.cpp:
+ (WebKit::EventDispatcher::wheelEvent):
+
2020-05-29 Carlos Garcia Campos <[email protected]>
[GTK4] Implement HTTP auth dialog
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (262293 => 262294)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -181,13 +181,15 @@
if (!m_scrollingTree)
return false;
- if (m_scrollingTree->shouldHandleWheelEventSynchronously(wheelEvent))
+ auto processingSteps = m_scrollingTree->determineWheelEventProcessing(wheelEvent);
+ if (processingSteps.containsAny({ WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForDOMEventDispatch }))
return false;
if (m_scrollingTree->willWheelEventStartSwipeGesture(wheelEvent))
return false;
- return m_scrollingTree->handleWheelEvent(wheelEvent) == ScrollingEventResult::DidHandleEvent;
+ auto result = m_scrollingTree->handleWheelEvent(wheelEvent);
+ return result.wasHandled;
}
void RemoteScrollingCoordinatorProxy::handleMouseEvent(const WebCore::PlatformMouseEvent& event)
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp (262293 => 262294)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -72,11 +72,11 @@
m_scrollerPair->updateValues();
}
-ScrollingEventResult ScrollingTreeFrameScrollingNodeRemoteMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ScrollingTreeFrameScrollingNodeRemoteMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
ScrollingTreeFrameScrollingNodeMac::handleWheelEvent(wheelEvent);
- return m_scrollerPair->handleWheelEvent(wheelEvent) ? ScrollingEventResult::DidHandleEvent : ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::result(m_scrollerPair->handleWheelEvent(wheelEvent));
}
bool ScrollingTreeFrameScrollingNodeRemoteMac::handleMouseEvent(const PlatformMouseEvent& mouseEvent)
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h (262293 => 262294)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -44,7 +44,7 @@
ScrollingTreeFrameScrollingNodeRemoteMac(WebCore::ScrollingTree&, WebCore::ScrollingNodeType, WebCore::ScrollingNodeID);
void commitStateBeforeChildren(const WebCore::ScrollingStateNode&) override;
- WebCore::ScrollingEventResult handleWheelEvent(const WebCore::PlatformWheelEvent&) override;
+ WebCore::WheelEventHandlingResult handleWheelEvent(const WebCore::PlatformWheelEvent&) override;
void repositionRelatedLayers() override;
std::unique_ptr<ScrollerPairMac> m_scrollerPair;
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp (262293 => 262294)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -72,11 +72,11 @@
m_scrollerPair->updateValues();
}
-ScrollingEventResult ScrollingTreeOverflowScrollingNodeRemoteMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+WheelEventHandlingResult ScrollingTreeOverflowScrollingNodeRemoteMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
ScrollingTreeOverflowScrollingNodeMac::handleWheelEvent(wheelEvent);
- return m_scrollerPair->handleWheelEvent(wheelEvent) ? ScrollingEventResult::DidHandleEvent : ScrollingEventResult::DidNotHandleEvent;
+ return WheelEventHandlingResult::result(m_scrollerPair->handleWheelEvent(wheelEvent));
}
bool ScrollingTreeOverflowScrollingNodeRemoteMac::handleMouseEvent(const PlatformMouseEvent& mouseEvent)
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h (262293 => 262294)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h 2020-05-29 14:56:21 UTC (rev 262294)
@@ -44,7 +44,7 @@
ScrollingTreeOverflowScrollingNodeRemoteMac(WebCore::ScrollingTree&, WebCore::ScrollingNodeID);
void commitStateBeforeChildren(const WebCore::ScrollingStateNode&) override;
- WebCore::ScrollingEventResult handleWheelEvent(const WebCore::PlatformWheelEvent&) override;
+ WebCore::WheelEventHandlingResult handleWheelEvent(const WebCore::PlatformWheelEvent&) override;
void repositionRelatedLayers() override;
std::unique_ptr<ScrollerPairMac> m_scrollerPair;
Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (262293 => 262294)
--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2020-05-29 13:58:01 UTC (rev 262293)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp 2020-05-29 14:56:21 UTC (rev 262294)
@@ -135,18 +135,19 @@
if (platformWheelEvent.phase() == PlatformWheelEventPhaseBegan)
scrollingTree->setMainFrameCanRubberBand({ canRubberBandAtTop, canRubberBandAtRight, canRubberBandAtBottom, canRubberBandAtLeft });
- if (scrollingTree->shouldHandleWheelEventSynchronously(platformWheelEvent))
+ auto processingSteps = scrollingTree->determineWheelEventProcessing(platformWheelEvent);
+ if (!processingSteps.contains(WheelEventProcessingSteps::ScrollingThread))
return false;
ScrollingThread::dispatch([scrollingTree, wheelEvent, platformWheelEvent, pageID, protectedThis = makeRef(*this)] {
auto result = scrollingTree->handleWheelEvent(platformWheelEvent);
- if (result == ScrollingEventResult::SendToMainThread) {
+ if (result.needsMainThreadProcessing()) {
protectedThis->dispatchWheelEventViaMainThread(pageID, wheelEvent);
return;
}
- protectedThis->sendDidReceiveEvent(pageID, wheelEvent.type(), result == ScrollingEventResult::DidHandleEvent);
+ protectedThis->sendDidReceiveEvent(pageID, wheelEvent.type(), result.wasHandled);
});
return true;