Changeset 269973 in webkit
- Timestamp:
- Nov 18, 2020 12:14:43 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r269972 r269973 1 2020-11-18 Simon Fraser <simon.fraser@apple.com> 2 3 Propagate wheel event handling back to the scrolling thread 4 https://bugs.webkit.org/show_bug.cgi?id=219050 5 6 Reviewed by Chris Dumez. 7 8 * fast/events/wheel/wheel-event-in-passive-region-non-cancelable-expected.txt: Added. 9 * fast/events/wheel/wheel-event-in-passive-region-non-cancelable.html: Added. 10 * platform/mac-wk1/TestExpectations: 11 * platform/win/TestExpectations: 12 1 13 2020-11-18 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r269866 r269973 493 493 fast/scrolling/scroll-animator-overlay-scrollbars-hovered.html [ Skip ] 494 494 495 # Tests that require async scrolling 496 fast/events/wheel/wheel-event-in-passive-region-non-cancelable.html [ Skip ] 497 495 498 # WK1 main frame scrollbars are native widgets whose size is unaffected by webkit-scrollbar. 496 499 fast/visual-viewport/viewport-dimensions-exclude-custom-scrollbars.html [ Skip ] -
trunk/LayoutTests/platform/win/TestExpectations
r269950 r269973 276 276 fast/events/wheel/wheelevent-in-horizontal-scrollbar-in-rtl.html [ Failure ] 277 277 fast/events/wheel/wheelevent-in-vertical-scrollbar-in-rtl.html [ Failure ] 278 279 # Need async scrolling 278 280 fast/events/wheel/wheel-event-listeners-on-body-made-passive.html [ Skip ] 279 281 fast/events/wheel/wheel-event-listeners-on-document-made-passive.html [ Skip ] 280 282 fast/events/wheel/wheel-event-listeners-on-window-left-active.html [ Skip ] 281 283 fast/events/wheel/wheel-event-listeners-on-window-made-passive.html [ Skip ] 284 fast/events/wheel/wheel-event-in-passive-region-non-cancelable.html [ Skip ] 282 285 283 286 scrollbars/scroll-rtl-or-bt-layer.html [ Timeout ] -
trunk/Source/WebCore/ChangeLog
r269963 r269973 1 2020-11-18 Simon Fraser <simon.fraser@apple.com> 2 3 Propagate wheel event handling back to the scrolling thread 4 https://bugs.webkit.org/show_bug.cgi?id=219050 5 6 Reviewed by Chris Dumez. 7 8 Prepare to fix webkit.org/b/218764 by adding a way for the main thread to communicate back 9 to the scrolling thread information about whether the wheel event was dispatched to JS, 10 and whether preventDefault() was called on it. 11 12 The EventHandling enum has bits that are set when the event is dispatched to JS, 13 when it's canceled, and if default handling happened. These values are filled in 14 Element::dispatchWheelEvent(). They propagate back to the scrolling thread via 15 EventHandler::wheelEventWasProcessedByMainThread(), whose macOS implementation 16 calls into the ScrollingCoordinator, which will set state on the ScrollingTree in 17 a future patch. 18 19 WheelEventTestMonitor gains a "reason" flag to track the async propagation of 20 wheelEventWasProcessedByMainThread() back to the scrolling thread. 21 22 This patch also adds infrastructure for the scrolling thread to specify that wheel events 23 sent to the main thread will be uncancelable; WheelEventProcessingSteps gains 24 MainThreadForNonBlockingDOMEventDispatch and MainThreadForBlockingDOMEventDispatch, 25 and if MainThreadForNonBlockingDOMEventDispatch is set, then we create 26 WheelEvents with IsCancelable::No. This will be the case for wheel events in 27 the passive event region. 28 29 Rename ScrollingCoordinator::handleWheelEvent() to performDefaultWheelEventHandling() 30 for clarity, and stop passing the FrameView* which was unused. 31 32 Add a missing lock in ThreadedScrollingTree::handleWheelEventAfterMainThread(). 33 34 * dom/Element.cpp: 35 (WebCore::Element::dispatchWheelEvent): 36 * dom/Element.h: 37 * dom/WheelEvent.cpp: 38 (WebCore::WheelEvent::WheelEvent): 39 (WebCore::WheelEvent::create): 40 * dom/WheelEvent.h: 41 * page/EventHandler.cpp: 42 (WebCore::EventHandler::wheelEventWasProcessedByMainThread): 43 (WebCore::EventHandler::handleWheelEvent): 44 (WebCore::EventHandler::handleWheelEventInternal): 45 * page/EventHandler.h: 46 * page/FrameView.cpp: 47 (WebCore::FrameView::wheelEvent): 48 * page/PointerLockController.cpp: 49 (WebCore::PointerLockController::dispatchLockedWheelEvent): 50 * page/WheelEventTestMonitor.cpp: 51 (WebCore::operator<<): 52 * page/WheelEventTestMonitor.h: 53 * page/ios/EventHandlerIOS.mm: 54 (WebCore::EventHandler::wheelEvent): 55 * page/mac/EventHandlerMac.mm: 56 (WebCore::EventHandler::wheelEvent): 57 (WebCore::EventHandler::wheelEventWasProcessedByMainThread): 58 * page/scrolling/ScrollingCoordinator.h: 59 (WebCore::ScrollingCoordinator::performDefaultWheelEventHandling): 60 (WebCore::ScrollingCoordinator::wheelEventWasProcessedByMainThread): 61 (WebCore::ScrollingCoordinator::handleWheelEvent): Deleted. 62 * page/scrolling/ScrollingTree.cpp: 63 (WebCore::ScrollingTree::determineWheelEventProcessing): 64 (WebCore::ScrollingTree::handleWheelEvent): 65 * page/scrolling/ScrollingTree.h: 66 (WebCore::WheelEventHandlingResult::needsMainThreadProcessing const): 67 * page/scrolling/ScrollingTreeLatchingController.cpp: 68 (WebCore::ScrollingTreeLatchingController::receivedWheelEvent): Send in WheelEventProcessingSteps which 69 a future patch will use. 70 * page/scrolling/ScrollingTreeLatchingController.h: 71 * page/scrolling/ThreadedScrollingTree.cpp: 72 (WebCore::ThreadedScrollingTree::handleWheelEventAfterMainThread): There was a missing lock here. 73 (WebCore::ThreadedScrollingTree::wheelEventWasProcessedByMainThread): 74 * page/scrolling/ThreadedScrollingTree.h: 75 * page/scrolling/mac/ScrollingCoordinatorMac.h: 76 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 77 (WebCore::ScrollingCoordinatorMac::performDefaultWheelEventHandling): 78 (WebCore::nextDeferIdentifier): 79 (WebCore::ScrollingCoordinatorMac::wheelEventWasProcessedByMainThread): 80 (WebCore::ScrollingCoordinatorMac::handleWheelEvent): Deleted. 81 * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm: 82 (WebCore::ScrollingTreeOverflowScrollingNodeMac::handleWheelEvent): 83 * page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp: 84 (WebCore::ScrollingCoordinatorNicosia::performDefaultWheelEventHandling): 85 (WebCore::ScrollingCoordinatorNicosia::wheelEventWasProcessedByMainThread): 86 (WebCore::ScrollingCoordinatorNicosia::handleWheelEvent): Deleted. 87 * page/scrolling/nicosia/ScrollingCoordinatorNicosia.h: 88 * platform/PlatformEvent.h: 89 * platform/PlatformWheelEvent.cpp: 90 (WebCore::operator<<): Add dumping of EventHandling. 91 * platform/PlatformWheelEvent.h: 92 1 93 2020-11-18 Antoine Quint <graouts@webkit.org> 2 94 -
trunk/Source/WebCore/dom/Element.cpp
r269807 r269973 421 421 } 422 422 423 bool Element::dispatchWheelEvent(const PlatformWheelEvent& platformEvent )424 { 425 auto event = WheelEvent::create(platformEvent, document().windowProxy() );423 bool Element::dispatchWheelEvent(const PlatformWheelEvent& platformEvent, OptionSet<EventHandling>& processing, Event::IsCancelable isCancelable) 424 { 425 auto event = WheelEvent::create(platformEvent, document().windowProxy(), isCancelable); 426 426 427 427 // Events with no deltas are important because they convey platform information about scroll gestures … … 431 431 // will prevent the event from being sent to the DOM, but will still call the default event handler. 432 432 // FIXME: Move this logic into WheelEvent::create. 433 if ( !platformEvent.deltaX() && !platformEvent.deltaY())433 if (platformEvent.delta().isZero()) 434 434 event->stopPropagation(); 435 else 436 processing.add(EventHandling::DispatchedToDOM); 435 437 436 438 dispatchEvent(event); 437 439 438 440 LOG_WITH_STREAM(Scrolling, stream << "Element " << *this << " dispatchWheelEvent: defaultPrevented " << event->defaultPrevented() << " defaultHandled " << event->defaultHandled()); 441 442 if (event->defaultPrevented()) 443 processing.add(EventHandling::DefaultPrevented); 444 445 if (event->defaultHandled()) 446 processing.add(EventHandling::DefaultHandled); 447 439 448 return !event->defaultPrevented() && !event->defaultHandled(); 440 449 } -
trunk/Source/WebCore/dom/Element.h
r269587 r269973 67 67 struct ScrollToOptions; 68 68 69 enum class EventProcessing : uint8_t; 70 69 71 #if ENABLE(INTERSECTION_OBSERVER) 70 72 struct IntersectionObserverData; … … 531 533 532 534 bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomString& eventType, int clickCount = 0, Element* relatedTarget = nullptr); 533 bool dispatchWheelEvent(const PlatformWheelEvent& );535 bool dispatchWheelEvent(const PlatformWheelEvent&, OptionSet<EventHandling>&, Event::IsCancelable = Event::IsCancelable::Yes); 534 536 bool dispatchKeyEvent(const PlatformKeyboardEvent&); 535 537 bool dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook); -
trunk/Source/WebCore/dom/WheelEvent.cpp
r254029 r269973 51 51 } 52 52 53 inline WheelEvent::WheelEvent(const PlatformWheelEvent& event, RefPtr<WindowProxy>&& view )54 : MouseEvent(eventNames().wheelEvent, CanBubble::Yes, IsCancelable::Yes, IsComposed::Yes, event.timestamp().approximateMonotonicTime(), WTFMove(view), 0,53 inline WheelEvent::WheelEvent(const PlatformWheelEvent& event, RefPtr<WindowProxy>&& view, IsCancelable isCancelable) 54 : MouseEvent(eventNames().wheelEvent, CanBubble::Yes, isCancelable, IsComposed::Yes, event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, 55 55 event.globalPosition(), event.position() , { }, event.modifiers(), 0, 0, nullptr, 0, 0, IsSimulated::No, IsTrusted::Yes) 56 56 , m_wheelDelta(event.wheelTicksX() * TickMultiplier, event.wheelTicksY() * TickMultiplier) … … 62 62 } 63 63 64 Ref<WheelEvent> WheelEvent::create(const PlatformWheelEvent& event, RefPtr<WindowProxy>&& view )64 Ref<WheelEvent> WheelEvent::create(const PlatformWheelEvent& event, RefPtr<WindowProxy>&& view, IsCancelable isCancelable) 65 65 { 66 return adoptRef(*new WheelEvent(event, WTFMove(view) ));66 return adoptRef(*new WheelEvent(event, WTFMove(view), isCancelable)); 67 67 } 68 68 -
trunk/Source/WebCore/dom/WheelEvent.h
r269659 r269973 41 41 }; 42 42 43 static Ref<WheelEvent> create(const PlatformWheelEvent&, RefPtr<WindowProxy>&& );43 static Ref<WheelEvent> create(const PlatformWheelEvent&, RefPtr<WindowProxy>&&, IsCancelable = IsCancelable::Yes); 44 44 static Ref<WheelEvent> createForBindings(); 45 45 … … 77 77 WheelEvent(); 78 78 WheelEvent(const AtomString&, const Init&); 79 WheelEvent(const PlatformWheelEvent&, RefPtr<WindowProxy>&& );79 WheelEvent(const PlatformWheelEvent&, RefPtr<WindowProxy>&&, IsCancelable); 80 80 81 81 EventInterface eventInterface() const final; -
trunk/Source/WebCore/page/EventHandler.cpp
r269888 r269973 2793 2793 } 2794 2794 2795 void EventHandler::wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) 2796 { 2797 } 2798 2795 2799 bool EventHandler::platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent&, const Widget&, const WeakPtr<ScrollableArea>&) 2796 2800 { … … 2863 2867 2864 2868 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event, OptionSet<WheelEventProcessingSteps> processingSteps) 2869 { 2870 OptionSet<EventHandling> handling; 2871 bool handled = handleWheelEventInternal(event, processingSteps, handling); 2872 wheelEventWasProcessedByMainThread(event, handling); 2873 return handled; 2874 } 2875 2876 bool EventHandler::handleWheelEventInternal(const PlatformWheelEvent& event, OptionSet<WheelEventProcessingSteps> processingSteps, OptionSet<EventHandling>& handling) 2865 2877 { 2866 2878 auto* document = m_frame.document(); … … 2925 2937 } 2926 2938 2927 if (!element->dispatchWheelEvent(event)) { 2939 auto isCancelable = processingSteps.contains(WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch) ? Event::IsCancelable::Yes : Event::IsCancelable::No; 2940 if (!element->dispatchWheelEvent(event, handling, isCancelable)) { 2928 2941 m_isHandlingWheelEvent = false; 2929 2942 if (scrollableArea && scrollableArea->scrollShouldClearLatchedState()) { … … 2955 2968 processWheelEventForScrollSnap(event, scrollableArea); 2956 2969 } 2970 2957 2971 return handledEvent; 2958 2972 } -
trunk/Source/WebCore/page/EventHandler.h
r268417 r269973 209 209 WEBCORE_EXPORT bool handleMouseReleaseEvent(const PlatformMouseEvent&); 210 210 bool handleMouseForceEvent(const PlatformMouseEvent&); 211 211 212 WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&, OptionSet<WheelEventProcessingSteps>); 212 213 void defaultWheelEventHandler(Node*, WheelEvent&); 214 void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>); 215 213 216 bool handlePasteGlobalSelection(const PlatformMouseEvent&); 214 217 … … 453 456 bool passMouseDownEventToWidget(Widget*); 454 457 458 bool handleWheelEventInternal(const PlatformWheelEvent&, OptionSet<WheelEventProcessingSteps>, OptionSet<EventHandling>&); 455 459 bool passWheelEventToWidget(const PlatformWheelEvent&, Widget&, OptionSet<WheelEventProcessingSteps>); 456 460 void determineWheelEventTarget(const PlatformWheelEvent&, RefPtr<Element>& eventTarget, WeakPtr<ScrollableArea>&, bool& isOverWidget); -
trunk/Source/WebCore/page/FrameView.cpp
r269953 r269973 5129 5129 if (auto scrollingCoordinator = this->scrollingCoordinator()) { 5130 5130 if (scrollingCoordinator->coordinatesScrollingForFrameView(*this)) 5131 return scrollingCoordinator-> handleWheelEvent(*this,wheelEvent, scrollingNodeID());5131 return scrollingCoordinator->performDefaultWheelEventHandling(wheelEvent, scrollingNodeID()); 5132 5132 } 5133 5133 #endif -
trunk/Source/WebCore/page/PointerLockController.cpp
r258148 r269973 194 194 return; 195 195 196 m_element->dispatchWheelEvent(event); 196 OptionSet<EventHandling> defaultHandling; 197 m_element->dispatchWheelEvent(event, defaultHandling); 197 198 } 198 199 -
trunk/Source/WebCore/page/WheelEventTestMonitor.cpp
r269659 r269973 171 171 case WheelEventTestMonitor::HandlingWheelEvent: ts << "handling wheel event"; break; 172 172 case WheelEventTestMonitor::HandlingWheelEventOnMainThread: ts << "handling wheel event on main thread"; break; 173 case WheelEventTestMonitor::ReportDOMEventHandling: ts << "report DOM event handling"; break; 173 174 case WheelEventTestMonitor::RubberbandInProgress: ts << "rubberbanding"; break; 174 175 case WheelEventTestMonitor::ScrollSnapInProgress: ts << "scroll-snapping"; break; -
trunk/Source/WebCore/page/WheelEventTestMonitor.h
r258805 r269973 51 51 HandlingWheelEvent = 1 << 0, 52 52 HandlingWheelEventOnMainThread = 1 << 1, 53 RubberbandInProgress = 1 << 2, 54 ScrollSnapInProgress = 1 << 3, 55 ScrollingThreadSyncNeeded = 1 << 4, 56 ContentScrollInProgress = 1 << 5, 57 RequestedScrollPosition = 1 << 6, 53 ReportDOMEventHandling = 1 << 2, 54 RubberbandInProgress = 1 << 3, 55 ScrollSnapInProgress = 1 << 4, 56 ScrollingThreadSyncNeeded = 1 << 5, 57 ContentScrollInProgress = 1 << 6, 58 RequestedScrollPosition = 1 << 7, 58 59 }; 59 60 typedef const void* ScrollableAreaIdentifier; -
trunk/Source/WebCore/page/ios/EventHandlerIOS.mm
r268417 r269973 108 108 CurrentEventScope scope(event); 109 109 110 bool eventWasHandled = handleWheelEvent(PlatformEventFactory::createPlatformWheelEvent(event), { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch });110 bool eventWasHandled = handleWheelEvent(PlatformEventFactory::createPlatformWheelEvent(event), { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }); 111 111 event.wasHandled = eventWasHandled; 112 112 return eventWasHandled; -
trunk/Source/WebCore/page/mac/EventHandlerMac.mm
r269659 r269973 64 64 #import "ScrollableArea.h" 65 65 #import "Scrollbar.h" 66 #import "ScrollingCoordinator.h" 66 67 #import "Settings.h" 67 68 #import "ShadowRoot.h" … … 147 148 148 149 CurrentEventScope scope(event, nil); 149 return handleWheelEvent(PlatformEventFactory::createPlatformWheelEvent(event, page->chrome().platformPageClient()), { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch });150 return handleWheelEvent(PlatformEventFactory::createPlatformWheelEvent(event, page->chrome().platformPageClient()), { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }); 150 151 } 151 152 … … 953 954 } 954 955 956 void EventHandler::wheelEventWasProcessedByMainThread(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> eventHandling) 957 { 958 #if ENABLE(ASYNC_SCROLLING) 959 if (!m_frame.page()) 960 return; 961 962 FrameView* view = m_frame.view(); 963 if (!view) 964 return; 965 966 if (auto scrollingCoordinator = m_frame.page()->scrollingCoordinator()) { 967 if (scrollingCoordinator->coordinatesScrollingForFrameView(*view)) 968 scrollingCoordinator->wheelEventWasProcessedByMainThread(wheelEvent, eventHandling); 969 } 970 #else 971 UNUSED_PARAM(wheelEvent); 972 UNUSED_PARAM(eventHandling); 973 #endif 974 } 975 955 976 bool EventHandler::platformCompletePlatformWidgetWheelEvent(const PlatformWheelEvent& wheelEvent, const Widget& widget, const WeakPtr<ScrollableArea>& scrollableArea) 956 977 { -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r267002 r269973 128 128 virtual void commitTreeStateIfNeeded() { } 129 129 virtual bool requestScrollPositionUpdate(ScrollableArea&, const IntPoint&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped) { return false; } 130 virtual bool handleWheelEvent(FrameView&, const PlatformWheelEvent&, ScrollingNodeID) { return false; } 130 virtual bool performDefaultWheelEventHandling(const PlatformWheelEvent&, ScrollingNodeID) { return false; } 131 virtual void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) { } 131 132 132 133 // Create an unparented node. -
trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp
r269659 r269973 75 75 } 76 76 77 m_latchingController.receivedWheelEvent(wheelEvent, m_allowLatching);78 79 77 auto processingSteps = [&]() -> OptionSet<WheelEventProcessingSteps> { 80 78 if (!m_rootNode) … … 94 92 95 93 if (isSynchronousDispatchRegion) 96 return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch };94 return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }; 97 95 } 98 96 … … 100 98 auto eventListenerTypes = eventListenerRegionTypesForPoint(position); 101 99 if (eventListenerTypes.contains(EventListenerRegionType::NonPassiveWheel)) 102 return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch };100 return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }; 103 101 104 102 if (eventListenerTypes.contains(EventListenerRegionType::Wheel)) 105 return { WheelEventProcessingSteps::ScrollingThread, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch };103 return { WheelEventProcessingSteps::ScrollingThread, WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch }; 106 104 #endif 107 105 return { WheelEventProcessingSteps::ScrollingThread }; 108 106 }(); 109 107 108 m_latchingController.receivedWheelEvent(wheelEvent, processingSteps, m_allowLatching); 109 110 110 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::determineWheelEventProcessing: processingSteps " << processingSteps); 111 111 … … 122 122 receivedWheelEvent(wheelEvent); 123 123 124 m_latchingController.receivedWheelEvent(wheelEvent, m_allowLatching);124 m_latchingController.receivedWheelEvent(wheelEvent, processingSteps, m_allowLatching); 125 125 126 126 auto result = [&] { … … 164 164 }(); 165 165 166 result.steps.add(processingSteps & WheelEventProcessingSteps::MainThreadForDOMEventDispatch); 166 static constexpr OptionSet<WheelEventProcessingSteps> mainThreadSteps = { WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }; 167 result.steps.add(processingSteps & mainThreadSteps); 167 168 return result; 168 169 } -
trunk/Source/WebCore/page/scrolling/ScrollingTree.h
r269312 r269973 60 60 OptionSet<WheelEventProcessingSteps> steps; 61 61 bool wasHandled { false }; 62 bool needsMainThreadProcessing() const { return steps.containsAny({ WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch }); }62 bool needsMainThreadProcessing() const { return steps.containsAny({ WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }); } 63 63 64 64 static WheelEventHandlingResult handled(OptionSet<WheelEventProcessingSteps> steps = { }) -
trunk/Source/WebCore/page/scrolling/ScrollingTreeLatchingController.cpp
r268544 r269973 42 42 ScrollingTreeLatchingController::ScrollingTreeLatchingController() = default; 43 43 44 void ScrollingTreeLatchingController::receivedWheelEvent(const PlatformWheelEvent& wheelEvent, bool allowLatching)44 void ScrollingTreeLatchingController::receivedWheelEvent(const PlatformWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps>, bool allowLatching) 45 45 { 46 46 if (!allowLatching) -
trunk/Source/WebCore/page/scrolling/ScrollingTreeLatchingController.h
r268895 r269973 49 49 ScrollingTreeLatchingController(); 50 50 51 void receivedWheelEvent(const PlatformWheelEvent&, bool allowLatching);51 void receivedWheelEvent(const PlatformWheelEvent&, OptionSet<WheelEventProcessingSteps>, bool allowLatching); 52 52 53 53 Optional<ScrollingNodeAndProcessingSteps> latchingDataForEvent(const PlatformWheelEvent&, bool allowLatching) const; -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
r269312 r269973 68 68 { 69 69 LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::handleWheelEventAfterMainThread " << wheelEvent); 70 71 LockHolder locker(m_treeMutex); 72 70 73 SetForScope<bool> disallowLatchingScope(m_allowLatching, false); 71 72 74 RefPtr<ScrollingTreeNode> targetNode = nodeForID(targetNodeID); 73 75 auto result = handleWheelEventWithNode(wheelEvent, { }, targetNode.get()); 74 76 return result.wasHandled; 77 } 78 79 void ThreadedScrollingTree::wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) 80 { 81 // FIXME: Set state based on EventHandling flags. 75 82 } 76 83 -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
r269579 r269973 49 49 50 50 bool handleWheelEventAfterMainThread(const PlatformWheelEvent&, ScrollingNodeID); 51 void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>); 51 52 52 53 void invalidate() override; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
r266292 r269973 42 42 43 43 // Handle the wheel event on the scrolling thread. Returns whether the event was handled or not. 44 bool handleWheelEvent(FrameView&, const PlatformWheelEvent&, ScrollingNodeID) override; 44 bool performDefaultWheelEventHandling(const PlatformWheelEvent&, ScrollingNodeID) final; 45 void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) final; 45 46 46 47 private: -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
r268075 r269973 74 74 } 75 75 76 bool ScrollingCoordinatorMac:: handleWheelEvent(FrameView&,const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNode)76 bool ScrollingCoordinatorMac::performDefaultWheelEventHandling(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNode) 77 77 { 78 78 ASSERT(isMainThread()); … … 84 84 LOG_WITH_STREAM(Scrolling, stream << "ScrollingCoordinatorMac::handleWheelEvent - sending event to scrolling thread"); 85 85 86 // FIXME: Over on the scrolling thread, we'll hit-test the layers and possibly send the event to a node87 // which we've already discounted on the main thread. This needs to target a specific node.88 89 86 RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree()); 90 87 ScrollingThread::dispatch([threadedScrollingTree, wheelEvent, targetNode] { … … 92 89 }); 93 90 return true; 91 } 92 93 static uint64_t nextDeferIdentifier() 94 { 95 static uint64_t deferIdentifier; 96 return ++deferIdentifier; 97 } 98 99 void ScrollingCoordinatorMac::wheelEventWasProcessedByMainThread(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> defaultHandling) 100 { 101 uint64_t deferIdentifier = 0; 102 if (m_page && m_page->isMonitoringWheelEvents()) { 103 deferIdentifier = nextDeferIdentifier(); 104 m_page->wheelEventTestMonitor()->deferForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(deferIdentifier), WheelEventTestMonitor::ReportDOMEventHandling); 105 } 106 107 RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree()); 108 ScrollingThread::dispatch([threadedScrollingTree, wheelEvent, defaultHandling, deferIdentifier] { 109 threadedScrollingTree->wheelEventWasProcessedByMainThread(wheelEvent, defaultHandling); 110 111 if (threadedScrollingTree->isMonitoringWheelEvents()) 112 threadedScrollingTree->removeWheelEventTestCompletionDeferralForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(deferIdentifier), WheelEventTestMonitor::ReportDOMEventHandling); 113 }); 94 114 } 95 115 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm
r269559 r269973 78 78 #if ENABLE(SCROLLING_THREAD) 79 79 if (hasSynchronousScrollingReasons()) 80 return { { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch }, false };80 return { { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch }, false }; 81 81 #endif 82 82 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp
r266292 r269973 70 70 } 71 71 72 bool ScrollingCoordinatorNicosia:: handleWheelEvent(FrameView&,const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNode)72 bool ScrollingCoordinatorNicosia::performDefaultWheelEventHandling(const PlatformWheelEvent& wheelEvent, ScrollingNodeID targetNode) 73 73 { 74 74 ASSERT(isMainThread()); … … 80 80 }); 81 81 return true; 82 } 83 84 void ScrollingCoordinatorNicosia::wheelEventWasProcessedByMainThread(const PlatformWheelEvent& wheelEvent, OptionSet<EventHandling> defaultHandling) 85 { 86 ScrollingThread::dispatch([threadedScrollingTree = makeRef(downcast<ThreadedScrollingTree>(*scrollingTree())), wheelEvent, defaultHandling] { 87 threadedScrollingTree->wheelEventWasProcessedByMainThread(wheelEvent, defaultHandling); 88 }); 82 89 } 83 90 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h
r266292 r269973 45 45 void commitTreeStateIfNeeded() override; 46 46 47 bool handleWheelEvent(FrameView&, const PlatformWheelEvent&, ScrollingNodeID) override; 47 bool performDefaultWheelEventHandling(const PlatformWheelEvent&, ScrollingNodeID) override; 48 void wheelEventWasProcessedByMainThread(const PlatformWheelEvent&, OptionSet<EventHandling>) override; 48 49 49 50 private: -
trunk/Source/WebCore/platform/PlatformEvent.h
r263208 r269973 30 30 31 31 namespace WebCore { 32 33 enum class EventHandling : uint8_t { 34 DispatchedToDOM = 1 << 0, 35 DefaultPrevented = 1 << 1, 36 DefaultHandled = 1 << 2, 37 }; 32 38 33 39 class PlatformEvent { -
trunk/Source/WebCore/platform/PlatformWheelEvent.cpp
r269659 r269973 65 65 case WheelEventProcessingSteps::ScrollingThread: ts << "scrolling thread"; break; 66 66 case WheelEventProcessingSteps::MainThreadForScrolling: ts << "main thread scrolling"; break; 67 case WheelEventProcessingSteps::MainThreadForDOMEventDispatch: ts << "main thread DOM event dispatch"; break; 67 case WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch: ts << "main thread non-blocking DOM event dispatch"; break; 68 case WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch: ts << "main thread blocking DOM event dispatch"; break; 69 } 70 return ts; 71 } 72 73 TextStream& operator<<(TextStream& ts, EventHandling steps) 74 { 75 switch (steps) { 76 case EventHandling::DispatchedToDOM: ts << "dispatched to DOM"; break; 77 case EventHandling::DefaultPrevented: ts << "default prevented"; break; 78 case EventHandling::DefaultHandled: ts << "default handled"; break; 68 79 } 69 80 return ts; -
trunk/Source/WebCore/platform/PlatformWheelEvent.h
r269659 r269973 38 38 39 39 enum class WheelEventProcessingSteps : uint8_t { 40 ScrollingThread = 1 << 0, 41 MainThreadForScrolling = 1 << 1, 42 MainThreadForDOMEventDispatch = 1 << 2, 40 ScrollingThread = 1 << 0, 41 MainThreadForScrolling = 1 << 1, 42 MainThreadForNonBlockingDOMEventDispatch = 1 << 2, 43 MainThreadForBlockingDOMEventDispatch = 1 << 3, 43 44 }; 44 45 … … 266 267 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const PlatformWheelEvent&); 267 268 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, WheelEventProcessingSteps); 269 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, EventHandling); 268 270 269 271 } // namespace WebCore -
trunk/Source/WebKit/ChangeLog
r269969 r269973 1 2020-11-18 Simon Fraser <simon.fraser@apple.com> 2 3 Propagate wheel event handling back to the scrolling thread 4 https://bugs.webkit.org/show_bug.cgi?id=219050 5 6 Reviewed by Chris Dumez. 7 8 For now, use MainThreadForBlockingDOMEventDispatch for the default steps (used by non-macOS platforms). 9 10 * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: 11 (WebKit::RemoteScrollingCoordinatorProxy::handleWheelEvent): 12 * WebProcess/WebPage/EventDispatcher.cpp: 13 (WebKit::EventDispatcher::wheelEvent): 14 1 15 2020-11-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 16 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
r269184 r269973 181 181 182 182 auto processingSteps = m_scrollingTree->determineWheelEventProcessing(wheelEvent); 183 if (processingSteps.containsAny({ WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch }))183 if (processingSteps.containsAny({ WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch })) 184 184 return false; 185 185 -
trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
r269659 r269973 122 122 #endif 123 123 124 auto processingSteps = OptionSet<WebCore::WheelEventProcessingSteps> { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch };124 auto processingSteps = OptionSet<WebCore::WheelEventProcessingSteps> { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }; 125 125 #if ENABLE(SCROLLING_THREAD) 126 126 processingSteps = [&]() -> OptionSet<WheelEventProcessingSteps> { … … 129 129 auto scrollingTree = m_scrollingTrees.get(pageID); 130 130 if (!scrollingTree) 131 return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch };131 return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }; 132 132 133 133 // FIXME: It's pretty horrible that we're updating the back/forward state here. -
trunk/Source/WebKitLegacy/win/ChangeLog
r269704 r269973 1 2020-11-18 Simon Fraser <simon.fraser@apple.com> 2 3 Propagate wheel event handling back to the scrolling thread 4 https://bugs.webkit.org/show_bug.cgi?id=219050 5 6 Reviewed by Chris Dumez. 7 8 Use MainThreadForBlockingDOMEventDispatch. 9 10 * WebView.cpp: 11 (WebView::mouseWheel): 12 1 13 2020-11-11 Sam Weinig <weinig@apple.com> 2 14 -
trunk/Source/WebKitLegacy/win/WebView.cpp
r269704 r269973 2138 2138 return false; 2139 2139 2140 return coreFrame->eventHandler().handleWheelEvent(wheelEvent, { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadFor DOMEventDispatch });2140 return coreFrame->eventHandler().handleWheelEvent(wheelEvent, { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch }); 2141 2141 } 2142 2142
Note: See TracChangeset
for help on using the changeset viewer.