Changeset 259112 in webkit
- Timestamp:
- Mar 27, 2020 5:54:38 AM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r259110 r259112 1 2020-03-27 Chris Lord <clord@igalia.com> 2 3 [GTK][WPE] Enable kinetic scrolling with async rendering 4 https://bugs.webkit.org/show_bug.cgi?id=209230 5 6 Reviewed by Žan Doberšek. 7 8 Refactor ScrollAnimationKinetic so that it no longer depends on 9 ScrollableArea, uses RunLoop::Timer and is responsible for tracking 10 the history of scroll events. This allows it to be used in 11 ScrollingTree*ScrollingNodeNicosia to provide kinetic scrolling when 12 async scrolling is enabled, on GTK and WPE. 13 14 No new tests, this just enables existing functionality in more situations. 15 16 * page/scrolling/ScrollingTreeScrollingNode.cpp: 17 (WebCore::ScrollingTreeScrollingNode::scrollTo): 18 * page/scrolling/ScrollingTreeScrollingNode.h: 19 * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp: 20 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::ScrollingTreeFrameScrollingNodeNicosia): 21 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent): 22 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::stopScrollAnimations): 23 * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h: 24 * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp: 25 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::ScrollingTreeOverflowScrollingNodeNicosia): 26 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::handleWheelEvent): 27 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::stopScrollAnimations): 28 * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h: 29 * platform/ScrollAnimationKinetic.cpp: 30 (WebCore::ScrollAnimationKinetic::ScrollAnimationKinetic): 31 (WebCore::ScrollAnimationKinetic::appendToScrollHistory): 32 (WebCore::ScrollAnimationKinetic::clearScrollHistory): 33 (WebCore::ScrollAnimationKinetic::computeVelocity): 34 (WebCore::ScrollAnimationKinetic::start): 35 * platform/ScrollAnimationKinetic.h: 36 * platform/generic/ScrollAnimatorGeneric.cpp: 37 (WebCore::ScrollAnimatorGeneric::ScrollAnimatorGeneric): 38 (WebCore::ScrollAnimatorGeneric::scrollToOffsetWithoutAnimation): 39 (WebCore::ScrollAnimatorGeneric::handleWheelEvent): 40 (WebCore::ScrollAnimatorGeneric::willEndLiveResize): 41 (WebCore::ScrollAnimatorGeneric::didAddVerticalScrollbar): 42 (WebCore::ScrollAnimatorGeneric::didAddHorizontalScrollbar): 43 * platform/generic/ScrollAnimatorGeneric.h: 44 1 45 2020-03-27 Michael Catanzaro <mcatanzaro@gnome.org> 2 46 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
r258238 r259112 170 170 return; 171 171 172 if (scrollType == ScrollType::Programmatic) 173 stopScrollAnimations(); 174 172 175 scrollingTree().setIsHandlingProgrammaticScroll(scrollType == ScrollType::Programmatic); 173 176 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
r258012 r259112 64 64 void scrollBy(const FloatSize&, ScrollClamping = ScrollClamping::Clamped); 65 65 66 virtual void stopScrollAnimations() { }; 67 66 68 void wasScrolledByDelegatedScrolling(const FloatPoint& position, Optional<FloatRect> overrideLayoutViewport = { }, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync); 67 69 … … 76 78 bool horizontalScrollbarHiddenByStyle() const { return m_scrollableAreaParameters.horizontalScrollbarHiddenByStyle; } 77 79 bool verticalScrollbarHiddenByStyle() const { return m_scrollableAreaParameters.verticalScrollbarHiddenByStyle; } 80 bool canHaveHorizontalScrollbar() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff; } 81 bool canHaveVerticalScrollbar() const { return m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; } 78 82 bool canHaveScrollbars() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff || m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; } 79 83 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp
r258831 r259112 38 38 #include "ScrollingTree.h" 39 39 40 #if ENABLE(KINETIC_SCROLLING) 41 #include "ScrollAnimationKinetic.h" 42 #endif 43 40 44 namespace WebCore { 41 45 … … 48 52 : ScrollingTreeFrameScrollingNode(scrollingTree, nodeType, nodeID) 49 53 { 54 #if ENABLE(KINETIC_SCROLLING) 55 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 56 [this]() -> ScrollAnimationKinetic::ScrollExtents { 57 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()) }; 58 }, 59 [this](FloatPoint&& position) { 60 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 61 ASSERT(scrollLayer); 62 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 63 64 auto updateScope = compositionLayer.createUpdateScope(); 65 scrollTo(position); 66 }); 67 #endif 50 68 } 51 69 … … 109 127 auto updateScope = compositionLayer.createUpdateScope(); 110 128 scrollBy({ -wheelEvent.deltaX(), -wheelEvent.deltaY() }); 111 } 129 130 #if ENABLE(KINETIC_SCROLLING) 131 m_kineticAnimation->appendToScrollHistory(wheelEvent); 132 #endif 133 } 134 135 #if ENABLE(KINETIC_SCROLLING) 136 m_kineticAnimation->stop(); 137 if (wheelEvent.isEndOfNonMomentumScroll()) { 138 m_kineticAnimation->start(currentScrollPosition(), m_kineticAnimation->computeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 139 m_kineticAnimation->clearScrollHistory(); 140 } 141 if (wheelEvent.isTransitioningToMomentumScroll()) { 142 m_kineticAnimation->start(currentScrollPosition(), wheelEvent.swipeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 143 m_kineticAnimation->clearScrollHistory(); 144 } 145 #endif 112 146 113 147 scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID()); … … 115 149 // FIXME: This needs to return whether the event was handled. 116 150 return ScrollingEventResult::DidHandleEvent; 151 } 152 153 void ScrollingTreeFrameScrollingNodeNicosia::stopScrollAnimations() 154 { 155 #if ENABLE(KINETIC_SCROLLING) 156 m_kineticAnimation->stop(); 157 m_kineticAnimation->clearScrollHistory(); 158 #endif 117 159 } 118 160 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h
r255037 r259112 40 40 41 41 namespace WebCore { 42 class ScrollAnimationKinetic; 42 43 43 44 class ScrollingTreeFrameScrollingNodeNicosia final : public ScrollingTreeFrameScrollingNode { … … 54 55 ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override; 55 56 57 void stopScrollAnimations() override; 58 56 59 FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollClamping) const override; 57 60 … … 67 70 RefPtr<Nicosia::CompositionLayer> m_headerLayer; 68 71 RefPtr<Nicosia::CompositionLayer> m_footerLayer; 72 73 #if ENABLE(KINETIC_SCROLLING) 74 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; 75 #endif 69 76 }; 70 77 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
r258831 r259112 33 33 34 34 #include "NicosiaPlatformLayer.h" 35 #if ENABLE(KINETIC_SCROLLING) 36 #include "ScrollAnimationKinetic.h" 37 #endif 35 38 #include "ScrollingStateOverflowScrollingNode.h" 36 39 #include "ScrollingTree.h" … … 46 49 : ScrollingTreeOverflowScrollingNode(scrollingTree, nodeID) 47 50 { 51 #if ENABLE(KINETIC_SCROLLING) 52 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 53 [this]() -> ScrollAnimationKinetic::ScrollExtents { 54 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()) }; 55 }, 56 [this](FloatPoint&& position) { 57 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 58 ASSERT(scrollLayer); 59 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 60 61 auto updateScope = compositionLayer.createUpdateScope(); 62 scrollTo(position); 63 }); 64 #endif 48 65 } 49 66 … … 95 112 auto updateScope = compositionLayer.createUpdateScope(); 96 113 scrollBy({ -wheelEvent.deltaX(), -wheelEvent.deltaY() }); 114 115 #if ENABLE(KINETIC_SCROLLING) 116 m_kineticAnimation->appendToScrollHistory(wheelEvent); 117 #endif 97 118 } 119 120 #if ENABLE(KINETIC_SCROLLING) 121 m_kineticAnimation->stop(); 122 if (wheelEvent.isEndOfNonMomentumScroll()) { 123 m_kineticAnimation->start(currentScrollPosition(), m_kineticAnimation->computeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 124 m_kineticAnimation->clearScrollHistory(); 125 } 126 if (wheelEvent.isTransitioningToMomentumScroll()) { 127 m_kineticAnimation->start(currentScrollPosition(), wheelEvent.swipeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 128 m_kineticAnimation->clearScrollHistory(); 129 } 130 #endif 98 131 99 132 scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID()); … … 102 135 } 103 136 137 void ScrollingTreeOverflowScrollingNodeNicosia::stopScrollAnimations() 138 { 139 #if ENABLE(KINETIC_SCROLLING) 140 m_kineticAnimation->stop(); 141 m_kineticAnimation->clearScrollHistory(); 142 #endif 143 } 144 104 145 } // namespace WebCore 105 146 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h
r255037 r259112 34 34 35 35 namespace WebCore { 36 class ScrollAnimationKinetic; 36 37 37 38 class ScrollingTreeOverflowScrollingNodeNicosia final : public ScrollingTreeOverflowScrollingNode { … … 50 51 51 52 ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override; 53 54 void stopScrollAnimations() override; 55 56 #if ENABLE(KINETIC_SCROLLING) 57 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; 58 #endif 52 59 }; 53 60 -
trunk/Source/WebCore/platform/ScrollAnimationKinetic.cpp
r240789 r259112 27 27 #include "ScrollAnimationKinetic.h" 28 28 29 #include "ScrollableArea.h" 29 #include "PlatformWheelEvent.h" 30 #include <wtf/glib/RunLoopSourcePriority.h> 30 31 31 32 /* … … 66 67 static const Seconds tickTime = 1_s / frameRate; 67 68 static const Seconds minimumTimerInterval { 1_ms }; 69 static const Seconds scrollCaptureThreshold { 150_ms }; 68 70 69 71 namespace WebCore { … … 105 107 } 106 108 107 ScrollAnimationKinetic::ScrollAnimationKinetic(Scroll ableArea& scrollableArea, std::function<void(FloatPoint&&)>&& notifyPositionChangedFunction)108 : ScrollAnimation(scrollableArea)109 ScrollAnimationKinetic::ScrollAnimationKinetic(ScrollExtentsCallback&& scrollExtentsFunction, NotifyPositionChangedCallback&& notifyPositionChangedFunction) 110 : m_scrollExtentsFunction(WTFMove(scrollExtentsFunction)) 109 111 , m_notifyPositionChangedFunction(WTFMove(notifyPositionChangedFunction)) 110 , m_animationTimer(*this, &ScrollAnimationKinetic::animationTimerFired) 111 { 112 , m_animationTimer(RunLoop::current(), this, &ScrollAnimationKinetic::animationTimerFired) 113 { 114 m_animationTimer.setPriority(WTF::RunLoopSourcePriority::DisplayRefreshMonitorTimer); 112 115 } 113 116 … … 121 124 } 122 125 126 void ScrollAnimationKinetic::appendToScrollHistory(const PlatformWheelEvent& event) 127 { 128 m_scrollHistory.removeAllMatching([&event] (PlatformWheelEvent& otherEvent) -> bool { 129 return (event.timestamp() - otherEvent.timestamp()) > scrollCaptureThreshold; 130 }); 131 132 m_scrollHistory.append(event); 133 } 134 135 void ScrollAnimationKinetic::clearScrollHistory() 136 { 137 m_scrollHistory.clear(); 138 } 139 140 FloatPoint ScrollAnimationKinetic::computeVelocity() 141 { 142 if (m_scrollHistory.isEmpty()) 143 return { }; 144 145 auto first = m_scrollHistory[0].timestamp(); 146 auto last = m_scrollHistory.rbegin()->timestamp(); 147 148 if (last == first) 149 return { }; 150 151 FloatPoint accumDelta; 152 for (const auto& scrollEvent : m_scrollHistory) 153 accumDelta += FloatPoint(scrollEvent.deltaX(), scrollEvent.deltaY()); 154 155 m_scrollHistory.clear(); 156 157 return FloatPoint(accumDelta.x() * -1 / (last - first).value(), accumDelta.y() * -1 / (last - first).value()); 158 } 159 123 160 void ScrollAnimationKinetic::start(const FloatPoint& initialPosition, const FloatPoint& velocity, bool mayHScroll, bool mayVScroll) 124 161 { … … 130 167 return; 131 168 169 auto extents = m_scrollExtentsFunction(); 132 170 if (mayHScroll) { 133 m_horizontalData = PerAxisData( m_scrollableArea.minimumScrollPosition().x(),134 m_scrollableArea.maximumScrollPosition().x(),171 m_horizontalData = PerAxisData(extents.minimumScrollPosition.x(), 172 extents.maximumScrollPosition.x(), 135 173 initialPosition.x(), velocity.x()); 136 174 } 137 175 if (mayVScroll) { 138 m_verticalData = PerAxisData( m_scrollableArea.minimumScrollPosition().y(),139 m_scrollableArea.maximumScrollPosition().y(),176 m_verticalData = PerAxisData(extents.minimumScrollPosition.y(), 177 extents.maximumScrollPosition.y(), 140 178 initialPosition.y(), velocity.y()); 141 179 } -
trunk/Source/WebCore/platform/ScrollAnimationKinetic.h
r239427 r259112 28 28 #include "FloatPoint.h" 29 29 #include "ScrollAnimation.h" 30 #include "Timer.h"31 30 32 31 #include <wtf/Optional.h> 32 #include <wtf/RunLoop.h> 33 33 34 34 namespace WebCore { 35 35 36 class ScrollableArea;36 class PlatformWheelEvent; 37 37 38 class ScrollAnimationKinetic final: public ScrollAnimation { 38 class ScrollAnimationKinetic final { 39 WTF_MAKE_FAST_ALLOCATED; 39 40 private: 40 41 class PerAxisData { … … 59 60 60 61 public: 61 ScrollAnimationKinetic(ScrollableArea&, std::function<void(FloatPoint&&)>&& notifyPositionChangedFunction); 62 struct ScrollExtents { 63 IntPoint minimumScrollPosition; 64 IntPoint maximumScrollPosition; 65 }; 66 67 using ScrollExtentsCallback = WTF::Function<ScrollExtents(void)>; 68 using NotifyPositionChangedCallback = WTF::Function<void(FloatPoint&&)>; 69 70 ScrollAnimationKinetic(ScrollExtentsCallback&&, NotifyPositionChangedCallback&&); 62 71 virtual ~ScrollAnimationKinetic(); 63 72 73 void appendToScrollHistory(const PlatformWheelEvent&); 74 void clearScrollHistory(); 75 FloatPoint computeVelocity(); 76 64 77 void start(const FloatPoint& initialPosition, const FloatPoint& velocity, bool mayHScroll, bool mayVScroll); 78 void stop(); 65 79 66 80 private: 67 void stop() override;68 81 void animationTimerFired(); 69 82 70 std::function<void(FloatPoint&&)> m_notifyPositionChangedFunction; 83 ScrollExtentsCallback m_scrollExtentsFunction; 84 NotifyPositionChangedCallback m_notifyPositionChangedFunction; 71 85 72 86 Optional<PerAxisData> m_horizontalData; … … 74 88 75 89 MonotonicTime m_startTime; 76 Timerm_animationTimer;90 RunLoop::Timer<ScrollAnimationKinetic> m_animationTimer; 77 91 FloatPoint m_position; 92 Vector<PlatformWheelEvent> m_scrollHistory; 78 93 }; 79 94 -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp
r254890 r259112 41 41 static const Seconds overflowScrollbarsAnimationDuration { 1_s }; 42 42 static const Seconds overflowScrollbarsAnimationHideDelay { 2_s }; 43 static const Seconds scrollCaptureThreshold { 150_ms };44 43 45 44 std::unique_ptr<ScrollAnimator> ScrollAnimator::create(ScrollableArea& scrollableArea) … … 52 51 , m_overlayScrollbarAnimationTimer(*this, &ScrollAnimatorGeneric::overlayScrollbarAnimationTimerFired) 53 52 { 54 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>(m_scrollableArea, [this](FloatPoint&& position) { 55 #if ENABLE(SMOOTH_SCROLLING) 56 if (m_smoothAnimation) 57 m_smoothAnimation->setCurrentPosition(position); 58 #endif 59 updatePosition(WTFMove(position)); 60 }); 53 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 54 [this]() -> ScrollAnimationKinetic::ScrollExtents { 55 return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition() }; 56 }, 57 [this](FloatPoint&& position) { 58 #if ENABLE(SMOOTH_SCROLLING) 59 if (m_smoothAnimation) 60 m_smoothAnimation->setCurrentPosition(position); 61 #endif 62 updatePosition(WTFMove(position)); 63 }); 61 64 62 65 #if ENABLE(SMOOTH_SCROLLING) … … 95 98 FloatPoint position = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); 96 99 m_kineticAnimation->stop(); 97 m_ scrollHistory.clear();100 m_kineticAnimation->clearScrollHistory(); 98 101 99 102 #if ENABLE(SMOOTH_SCROLLING) … … 105 108 } 106 109 107 FloatPoint ScrollAnimatorGeneric::computeVelocity()108 {109 if (m_scrollHistory.isEmpty())110 return { };111 112 auto first = m_scrollHistory[0].timestamp();113 auto last = m_scrollHistory.rbegin()->timestamp();114 115 if (last == first)116 return { };117 118 FloatPoint accumDelta;119 for (const auto& scrollEvent : m_scrollHistory)120 accumDelta += FloatPoint(scrollEvent.deltaX(), scrollEvent.deltaY());121 122 m_scrollHistory.clear();123 124 return FloatPoint(accumDelta.x() * -1 / (last - first).value(), accumDelta.y() * -1 / (last - first).value());125 }126 127 110 bool ScrollAnimatorGeneric::handleWheelEvent(const PlatformWheelEvent& event) 128 111 { 129 112 m_kineticAnimation->stop(); 130 131 m_scrollHistory.removeAllMatching([&event] (PlatformWheelEvent& otherEvent) -> bool {132 return (event.timestamp() - otherEvent.timestamp()) > scrollCaptureThreshold;133 });134 113 135 114 #if ENABLE(KINETIC_SCROLLING) 136 115 if (event.isEndOfNonMomentumScroll()) { 137 116 // We don't need to add the event to the history as its delta will be (0, 0). 138 static_cast<ScrollAnimationKinetic*>(m_kineticAnimation.get())->start(m_currentPosition,computeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar());117 m_kineticAnimation->start(m_currentPosition, m_kineticAnimation->computeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar()); 139 118 return true; 140 119 } 141 120 if (event.isTransitioningToMomentumScroll()) { 142 m_ scrollHistory.clear();143 static_cast<ScrollAnimationKinetic*>(m_kineticAnimation.get())->start(m_currentPosition, event.swipeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar());121 m_kineticAnimation->clearScrollHistory(); 122 m_kineticAnimation->start(m_currentPosition, event.swipeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar()); 144 123 return true; 145 124 } 146 #endif 147 148 m_scrollHistory.append(event); 125 126 m_kineticAnimation->appendToScrollHistory(event); 127 #endif 149 128 150 129 return ScrollAnimator::handleWheelEvent(event); … … 153 132 void ScrollAnimatorGeneric::willEndLiveResize() 154 133 { 155 m_kineticAnimation->updateVisibleLengths();156 157 134 #if ENABLE(SMOOTH_SCROLLING) 158 135 if (m_smoothAnimation) … … 170 147 void ScrollAnimatorGeneric::didAddVerticalScrollbar(Scrollbar* scrollbar) 171 148 { 172 m_kineticAnimation->updateVisibleLengths();173 174 149 #if ENABLE(SMOOTH_SCROLLING) 175 150 if (m_smoothAnimation) … … 187 162 void ScrollAnimatorGeneric::didAddHorizontalScrollbar(Scrollbar* scrollbar) 188 163 { 189 m_kineticAnimation->updateVisibleLengths();190 191 164 #if ENABLE(SMOOTH_SCROLLING) 192 165 if (m_smoothAnimation) -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h
r238675 r259112 37 37 38 38 class ScrollAnimation; 39 class ScrollAnimationKinetic; 39 40 40 41 class ScrollAnimatorGeneric final : public ScrollAnimator { … … 72 73 void updateOverlayScrollbarsOpacity(); 73 74 74 FloatPoint computeVelocity();75 76 75 #if ENABLE(SMOOTH_SCROLLING) 77 76 void ensureSmoothScrollingAnimation(); … … 79 78 std::unique_ptr<ScrollAnimation> m_smoothAnimation; 80 79 #endif 81 std::unique_ptr<ScrollAnimation> m_kineticAnimation; 82 Vector<PlatformWheelEvent> m_scrollHistory; 80 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; 83 81 Scrollbar* m_horizontalOverlayScrollbar { nullptr }; 84 82 Scrollbar* m_verticalOverlayScrollbar { nullptr }; -
trunk/Source/WebKit/ChangeLog
r259105 r259112 1 2020-03-27 Chris Lord <clord@igalia.com> 2 3 [GTK][WPE] Enable kinetic scrolling with async scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=209230 5 6 Reviewed by Žan Doberšek. 7 8 Modify WPE mousewheel event delivery so that it includes the necessary 9 phases needed to infer press/release times and allow for kinetic 10 scrolling. 11 12 * Shared/NativeWebWheelEvent.h: 13 * Shared/WebEvent.h: 14 * Shared/WebWheelEvent.cpp: 15 (WebKit::WebWheelEvent::encode const): 16 (WebKit::WebWheelEvent::decode): 17 * Shared/libwpe/NativeWebWheelEventLibWPE.cpp: 18 (WebKit::NativeWebWheelEvent::NativeWebWheelEvent): 19 * Shared/libwpe/WebEventFactory.cpp: 20 (WebKit::WebEventFactory::createWebWheelEvent): 21 * Shared/libwpe/WebEventFactory.h: 22 * UIProcess/API/wpe/PageClientImpl.cpp: 23 (WebKit::PageClientImpl::doneWithTouchEvent): 24 * UIProcess/API/wpe/ScrollGestureController.cpp: 25 (WebKit::ScrollGestureController::handleEvent): 26 * UIProcess/API/wpe/ScrollGestureController.h: 27 (WebKit::ScrollGestureController::phase): 28 * UIProcess/API/wpe/WPEView.cpp: 29 (WKWPE::m_backend): 30 1 31 2020-03-26 David Kilzer <ddkilzer@apple.com> 2 32 -
trunk/Source/WebKit/Shared/NativeWebWheelEvent.h
r238384 r259112 58 58 NativeWebWheelEvent(GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase); 59 59 #elif USE(LIBWPE) 60 NativeWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor );60 NativeWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase); 61 61 #elif PLATFORM(WIN) 62 62 NativeWebWheelEvent(HWND, UINT message, WPARAM, LPARAM); -
trunk/Source/WebKit/Shared/WebEvent.h
r254494 r259112 206 206 #if PLATFORM(COCOA) 207 207 WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, bool directionInvertedFromDevice, Phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, OptionSet<Modifier>, WallTime timestamp); 208 #elif PLATFORM(GTK) 208 #elif PLATFORM(GTK) || PLATFORM(WPE) 209 209 WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Phase, Phase momentumPhase, Granularity, OptionSet<Modifier>, WallTime timestamp); 210 210 #endif -
trunk/Source/WebKit/Shared/WebWheelEvent.cpp
r254494 r259112 66 66 ASSERT(isWheelEventType(type)); 67 67 } 68 #elif PLATFORM(GTK) 68 #elif PLATFORM(GTK) || PLATFORM(WPE) 69 69 WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Phase phase, Phase momentumPhase, Granularity granularity, OptionSet<Modifier> modifiers, WallTime timestamp) 70 70 : WebEvent(type, modifiers, timestamp) … … 92 92 encoder << m_granularity; 93 93 encoder << m_directionInvertedFromDevice; 94 #if PLATFORM(COCOA) || PLATFORM(GTK) 94 #if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WPE) 95 95 encoder << m_phase; 96 96 encoder << m_momentumPhase; … … 119 119 if (!decoder.decode(t.m_directionInvertedFromDevice)) 120 120 return false; 121 #if PLATFORM(COCOA) || PLATFORM(GTK) 121 #if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WPE) 122 122 if (!decoder.decode(t.m_phase)) 123 123 return false; -
trunk/Source/WebKit/Shared/libwpe/NativeWebWheelEventLibWPE.cpp
r238384 r259112 33 33 namespace WebKit { 34 34 35 NativeWebWheelEvent::NativeWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor )36 : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, deviceScaleFactor ))35 NativeWebWheelEvent::NativeWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor, WebWheelEvent::Phase phase, WebWheelEvent::Phase momentumPhase) 36 : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, deviceScaleFactor, phase, momentumPhase)) 37 37 { 38 38 } -
trunk/Source/WebKit/Shared/libwpe/WebEventFactory.cpp
r256913 r259112 143 143 } 144 144 145 WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor )145 WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor, WebWheelEvent::Phase phase, WebWheelEvent::Phase momentumPhase) 146 146 { 147 147 WebCore::IntPoint position(event->x, event->y); … … 169 169 170 170 return WebWheelEvent(WebEvent::Wheel, position, position, 171 delta, wheelTicks, WebWheelEvent::ScrollByPixelWheelEvent, 171 delta, wheelTicks, phase, momentumPhase, 172 WebWheelEvent::ScrollByPixelWheelEvent, 172 173 OptionSet<WebEvent::Modifier> { }, wallTimeForEventTime(event->time)); 173 174 } … … 201 202 202 203 return WebWheelEvent(WebEvent::Wheel, position, position, 203 delta, wheelTicks, WebWheelEvent::ScrollByPixelWheelEvent, 204 delta, wheelTicks, phase, momentumPhase, 205 WebWheelEvent::ScrollByPixelWheelEvent, 204 206 OptionSet<WebEvent::Modifier> { }, wallTimeForEventTime(event->time)); 205 207 } -
trunk/Source/WebKit/Shared/libwpe/WebEventFactory.h
r253881 r259112 41 41 static WebKeyboardEvent createWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&); 42 42 static WebMouseEvent createWebMouseEvent(struct wpe_input_pointer_event*, float deviceScaleFactor); 43 static WebWheelEvent createWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor );43 static WebWheelEvent createWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase); 44 44 #if ENABLE(TOUCH_EVENTS) 45 45 static WebTouchEvent createWebTouchEvent(struct wpe_input_touch_event*, float deviceScaleFactor); -
trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp
r255488 r259112 218 218 struct wpe_input_axis_event* axisEvent = scrollGestureController.axisEvent(); 219 219 if (axisEvent->type != wpe_input_axis_event_type_null) 220 page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, m_view.page().deviceScaleFactor() ));220 page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, m_view.page().deviceScaleFactor(), WebWheelEvent::Phase::PhaseNone, WebWheelEvent::Phase::PhaseNone)); 221 221 return; 222 222 } -
trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp
r258831 r259112 70 70 m_offset.x = touchPoint->x; 71 71 m_offset.y = touchPoint->y; 72 m_phase = WebWheelEvent::Phase::PhaseChanged; 72 73 return true; 73 74 } … … 78 79 #if WPE_CHECK_VERSION(1, 5, 0) 79 80 m_axisEvent.base = { 80 wpe_input_axis_event_type_null, 81 0, 0, 0, 0, 0, 0 81 m_axisEvent.base.type, 82 touchPoint->time, m_start.x, m_start.y, 83 0, 0, 0 82 84 }; 83 85 m_axisEvent.x_axis = m_axisEvent.y_axis = 0; 84 86 #else 85 87 m_axisEvent = { 86 wpe_input_axis_event_type_null, 87 0, 0, 0, 0, 0, 0 88 m_axisEvent.type, 89 touchPoint->time, m_start.x, m_start.y, 90 0, 0, 0 88 91 }; 89 92 #endif 93 m_offset.x = m_offset.y = 0; 94 m_phase = WebWheelEvent::Phase::PhaseEnded; 90 95 return true; 91 96 } -
trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h
r256913 r259112 26 26 #pragma once 27 27 28 #include "WebEvent.h" 28 29 #include <wpe/wpe.h> 29 30 … … 43 44 #endif 44 45 } 46 47 WebWheelEvent::Phase phase() { return m_phase; } 45 48 46 49 bool isHandling() const { return m_handling; } … … 65 68 struct wpe_input_axis_event m_axisEvent; 66 69 #endif 70 WebWheelEvent::Phase m_phase { WebWheelEvent::Phase::PhaseNone }; 67 71 }; 68 72 -
trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp
r258131 r259112 162 162 { 163 163 auto& page = reinterpret_cast<View*>(data)->page(); 164 page.handleWheelEvent(WebKit::NativeWebWheelEvent(event, page.deviceScaleFactor() ));164 page.handleWheelEvent(WebKit::NativeWebWheelEvent(event, page.deviceScaleFactor(), WebWheelEvent::Phase::PhaseNone, WebWheelEvent::Phase::PhaseNone)); 165 165 }, 166 166 // handle_touch_event … … 176 176 const struct wpe_input_touch_event_raw* touchPoint = touchEvent.nativeFallbackTouchPoint(); 177 177 if (touchPoint->type != wpe_input_touch_event_type_null && scrollGestureController.handleEvent(touchPoint)) { 178 struct wpe_input_axis_event* axisEvent = scrollGestureController.axisEvent(); 179 if (axisEvent->type != wpe_input_axis_event_type_null) 180 page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, page.deviceScaleFactor())); 178 page.handleWheelEvent(WebKit::NativeWebWheelEvent(scrollGestureController.axisEvent(), page.deviceScaleFactor(), scrollGestureController.phase(), WebWheelEvent::Phase::PhaseNone)); 181 179 return; 182 180 }
Note: See TracChangeset
for help on using the changeset viewer.