Changeset 268522 in webkit
- Timestamp:
- Oct 15, 2020 6:46:54 AM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r268521 r268522 1 2020-10-15 Chris Lord <clord@igalia.com> 2 3 [GTK][WPE] Add support for smooth scrolling animation with async scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=210382 5 6 Reviewed by Carlos Garcia Campos. 7 8 Respect smooth-scrolling setting and fix deadlock issues with async 9 scrolling on nicosia path. 10 11 No new tests, no functional change. 12 13 * page/scrolling/AsyncScrollingCoordinator.cpp: 14 (WebCore::AsyncScrollingCoordinator::scrollAnimatorEnabled const): 15 * page/scrolling/AsyncScrollingCoordinator.h: 16 * page/scrolling/ThreadedScrollingTree.cpp: 17 (WebCore::ThreadedScrollingTree::ThreadedScrollingTree): 18 * page/scrolling/ThreadedScrollingTree.h: 19 (WebCore::ThreadedScrollingTree::scrollAnimatorEnabled const): 20 * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp: 21 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::ScrollingTreeFrameScrollingNodeNicosia): 22 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::commitStateAfterChildren): 23 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::ensureScrollAnimationKinetic): 24 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::ensureScrollAnimationSmooth): 25 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent): 26 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::stopScrollAnimations): 27 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::repositionRelatedLayers): 28 * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h: 29 * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp: 30 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::ScrollingTreeOverflowScrollingNodeNicosia): 31 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::commitStateAfterChildren): 32 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::repositionScrollingLayers): 33 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::ensureScrollAnimationKinetic): 34 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::ensureScrollAnimationSmooth): 35 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::handleWheelEvent): 36 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::stopScrollAnimations): 37 * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h: 38 * platform/PlatformWheelEvent.h: 39 * platform/ScrollAnimation.h: 40 * platform/ScrollAnimationKinetic.cpp: 41 (WebCore::ScrollAnimationKinetic::isActive const): 42 * platform/ScrollAnimationKinetic.h: 43 * platform/ScrollAnimationSmooth.cpp: 44 (WebCore::ScrollAnimationSmooth::scroll): 45 (WebCore::ScrollAnimationSmooth::isActive const): 46 * platform/ScrollAnimationSmooth.h: 47 * platform/generic/ScrollAnimatorGeneric.cpp: 48 (WebCore::ScrollAnimatorGeneric::ensureSmoothScrollingAnimation): 49 1 50 2020-10-15 Youenn Fablet <youenn@apple.com> 2 51 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r268075 r268522 958 958 } 959 959 960 #if ENABLE(SMOOTH_SCROLLING) 961 bool AsyncScrollingCoordinator::scrollAnimatorEnabled() const 962 { 963 ASSERT(isMainThread()); 964 auto& settings = m_page->mainFrame().settings(); 965 return settings.scrollAnimatorEnabled(); 966 } 967 #endif 968 960 969 } // namespace WebCore 961 970 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
r267002 r268522 72 72 void reportSynchronousScrollingReasonsChanged(MonotonicTime, OptionSet<SynchronousScrollingReason>); 73 73 74 #if ENABLE(SMOOTH_SCROLLING) 75 bool scrollAnimatorEnabled() const; 76 #endif 77 74 78 protected: 75 79 WEBCORE_EXPORT AsyncScrollingCoordinator(Page*); -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
r268417 r268522 48 48 : m_scrollingCoordinator(&scrollingCoordinator) 49 49 { 50 #if ENABLE(SMOOTH_SCROLLING) 51 m_scrollAnimatorEnabled = scrollingCoordinator.scrollAnimatorEnabled(); 52 #endif 50 53 } 51 54 -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
r268417 r268522 59 59 Lock& treeMutex() { return m_treeMutex; } 60 60 61 bool scrollAnimatorEnabled() const { return m_scrollAnimatorEnabled; } 62 61 63 protected: 62 64 explicit ThreadedScrollingTree(AsyncScrollingCoordinator&); … … 104 106 // Dynamically allocated because it has to use the ScrollingThread's runloop. 105 107 std::unique_ptr<RunLoop::Timer<ThreadedScrollingTree>> m_delayedRenderingUpdateDetectionTimer; 108 109 bool m_scrollAnimatorEnabled { false }; 106 110 }; 107 111 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp
r266390 r268522 36 36 #include "NicosiaPlatformLayer.h" 37 37 #include "ScrollingStateFrameScrollingNode.h" 38 #include " ScrollingTree.h"38 #include "ThreadedScrollingTree.h" 39 39 40 40 #if ENABLE(KINETIC_SCROLLING) … … 55 55 : ScrollingTreeFrameScrollingNode(scrollingTree, nodeType, nodeID) 56 56 { 57 m_scrollAnimatorEnabled = downcast<ThreadedScrollingTree>(scrollingTree).scrollAnimatorEnabled(); 58 } 59 60 ScrollingTreeFrameScrollingNodeNicosia::~ScrollingTreeFrameScrollingNodeNicosia() = default; 61 62 void ScrollingTreeFrameScrollingNodeNicosia::commitStateBeforeChildren(const ScrollingStateNode& stateNode) 63 { 64 ScrollingTreeFrameScrollingNode::commitStateBeforeChildren(stateNode); 65 66 const auto& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(stateNode); 67 68 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::RootContentsLayer)) { 69 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.rootContentsLayer()); 70 m_rootContentsLayer = downcast<Nicosia::CompositionLayer>(layer); 71 } 72 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer)) { 73 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.counterScrollingLayer()); 74 m_counterScrollingLayer = downcast<Nicosia::CompositionLayer>(layer); 75 } 76 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer)) { 77 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.insetClipLayer()); 78 m_insetClipLayer = downcast<Nicosia::CompositionLayer>(layer); 79 } 80 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) { 81 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.contentShadowLayer()); 82 m_contentShadowLayer = downcast<Nicosia::CompositionLayer>(layer); 83 } 84 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer)) { 85 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.headerLayer()); 86 m_headerLayer = downcast<Nicosia::CompositionLayer>(layer); 87 } 88 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer)) { 89 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.footerLayer()); 90 m_footerLayer = downcast<Nicosia::CompositionLayer>(layer); 91 } 92 } 93 94 void ScrollingTreeFrameScrollingNodeNicosia::commitStateAfterChildren(const ScrollingStateNode& stateNode) 95 { 96 ScrollingTreeFrameScrollingNode::commitStateAfterChildren(stateNode); 97 98 const auto& scrollingStateNode = downcast<ScrollingStateScrollingNode>(stateNode); 99 100 // Update the scroll position after child nodes have been updated, because they need to have updated their constraints before any scrolling happens. 101 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { 102 stopScrollAnimations(); 103 const auto& requestedScrollData = scrollingStateNode.requestedScrollData(); 104 scrollTo(requestedScrollData.scrollPosition, requestedScrollData.scrollType, requestedScrollData.clamping); 105 #if ENABLE(SMOOTH_SCROLLING) 106 if (m_smoothAnimation) 107 m_smoothAnimation->setCurrentPosition(currentScrollPosition()); 108 #endif 109 } 110 } 111 57 112 #if ENABLE(KINETIC_SCROLLING) 113 void ScrollingTreeFrameScrollingNodeNicosia::ensureScrollAnimationKinetic() 114 { 115 if (m_kineticAnimation) 116 return; 117 58 118 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 59 119 [this]() -> ScrollExtents { … … 62 122 [this](FloatPoint&& position) { 63 123 #if ENABLE(SMOOTH_SCROLLING) 64 m_smoothAnimation->setCurrentPosition(position); 124 if (m_smoothAnimation) 125 m_smoothAnimation->setCurrentPosition(position); 65 126 #endif 66 127 … … 72 133 scrollTo(position); 73 134 }); 74 #endif 75 #if ENABLE(SMOOTH_SCROLLING) 135 } 136 #endif 137 138 #if ENABLE(SMOOTH_SCROLLING) 139 void ScrollingTreeFrameScrollingNodeNicosia::ensureScrollAnimationSmooth() 140 { 141 if (m_smoothAnimation) 142 return; 143 76 144 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>( 77 145 [this]() -> ScrollExtents { … … 88 156 }, 89 157 [] { }); 90 #endif 91 } 92 93 ScrollingTreeFrameScrollingNodeNicosia::~ScrollingTreeFrameScrollingNodeNicosia() = default; 94 95 void ScrollingTreeFrameScrollingNodeNicosia::commitStateBeforeChildren(const ScrollingStateNode& stateNode) 96 { 97 ScrollingTreeFrameScrollingNode::commitStateBeforeChildren(stateNode); 98 99 const auto& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(stateNode); 100 101 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::RootContentsLayer)) { 102 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.rootContentsLayer()); 103 m_rootContentsLayer = downcast<Nicosia::CompositionLayer>(layer); 104 } 105 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer)) { 106 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.counterScrollingLayer()); 107 m_counterScrollingLayer = downcast<Nicosia::CompositionLayer>(layer); 108 } 109 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer)) { 110 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.insetClipLayer()); 111 m_insetClipLayer = downcast<Nicosia::CompositionLayer>(layer); 112 } 113 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) { 114 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.contentShadowLayer()); 115 m_contentShadowLayer = downcast<Nicosia::CompositionLayer>(layer); 116 } 117 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer)) { 118 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.headerLayer()); 119 m_headerLayer = downcast<Nicosia::CompositionLayer>(layer); 120 } 121 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer)) { 122 auto* layer = static_cast<Nicosia::PlatformLayer*>(scrollingStateNode.footerLayer()); 123 m_footerLayer = downcast<Nicosia::CompositionLayer>(layer); 124 } 125 } 126 127 void ScrollingTreeFrameScrollingNodeNicosia::commitStateAfterChildren(const ScrollingStateNode& stateNode) 128 { 129 ScrollingTreeFrameScrollingNode::commitStateAfterChildren(stateNode); 130 131 const auto& scrollingStateNode = downcast<ScrollingStateScrollingNode>(stateNode); 132 133 // Update the scroll position after child nodes have been updated, because they need to have updated their constraints before any scrolling happens. 134 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { 135 stopScrollAnimations(); 136 const auto& requestedScrollData = scrollingStateNode.requestedScrollData(); 137 scrollTo(requestedScrollData.scrollPosition, requestedScrollData.scrollType, requestedScrollData.clamping); 138 #if ENABLE(SMOOTH_SCROLLING) 139 m_smoothAnimation->setCurrentPosition(currentScrollPosition()); 140 #endif 141 } 142 } 158 } 159 #endif 143 160 144 161 WheelEventHandlingResult ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent) … … 148 165 149 166 #if ENABLE(KINETIC_SCROLLING) 167 ensureScrollAnimationKinetic(); 150 168 m_kineticAnimation->appendToScrollHistory(wheelEvent); 151 169 m_kineticAnimation->stop(); … … 190 208 191 209 #if ENABLE(SMOOTH_SCROLLING) 192 m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, -deltaX); 193 m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, -deltaY); 194 #else 210 if (m_scrollAnimatorEnabled && !wheelEvent.hasPreciseScrollingDeltas()) { 211 ensureScrollAnimationSmooth(); 212 m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, -deltaX); 213 m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, -deltaY); 214 return WheelEventHandlingResult::handled(); 215 } 216 #endif 217 195 218 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 196 219 ASSERT(scrollLayer); … … 199 222 auto updateScope = compositionLayer.createUpdateScope(); 200 223 scrollBy({ -deltaX, -deltaY }); 201 #endif202 224 203 225 return WheelEventHandlingResult::handled(); … … 207 229 { 208 230 #if ENABLE(KINETIC_SCROLLING) 209 m_kineticAnimation->stop(); 210 m_kineticAnimation->clearScrollHistory(); 211 #endif 212 #if ENABLE(SMOOTH_SCROLLING) 213 m_smoothAnimation->stop(); 231 if (m_kineticAnimation) { 232 m_kineticAnimation->stop(); 233 m_kineticAnimation->clearScrollHistory(); 234 } 235 #endif 236 #if ENABLE(SMOOTH_SCROLLING) 237 if (m_smoothAnimation) 238 m_smoothAnimation->stop(); 214 239 #endif 215 240 } … … 290 315 applyLayerPosition(*m_footerLayer, FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForFooterLayer(scrollPosition, topContentInset, totalContentsSize().height(), footerHeight()))); 291 316 } 317 318 #if ENABLE(SMOOTH_SCROLLING) 319 if (m_smoothAnimation) 320 m_smoothAnimation->updateVisibleLengths(); 321 #endif 292 322 } 293 323 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h
r266390 r268522 54 54 void commitStateAfterChildren(const ScrollingStateNode&) override; 55 55 56 #if ENABLE(KINETIC_SCROLLING) 57 void ensureScrollAnimationKinetic(); 58 #endif 59 #if ENABLE(SMOOTH_SCROLLING) 60 void ensureScrollAnimationSmooth(); 61 #endif 62 56 63 WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&) override; 57 64 … … 72 79 RefPtr<Nicosia::CompositionLayer> m_footerLayer; 73 80 81 bool m_scrollAnimatorEnabled { false }; 74 82 #if ENABLE(KINETIC_SCROLLING) 75 83 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
r266390 r268522 40 40 #endif 41 41 #include "ScrollingStateOverflowScrollingNode.h" 42 #include " ScrollingTree.h"42 #include "ThreadedScrollingTree.h" 43 43 44 44 namespace WebCore { … … 52 52 : ScrollingTreeOverflowScrollingNode(scrollingTree, nodeID) 53 53 { 54 #if ENABLE(KINETIC_SCROLLING) 54 m_scrollAnimatorEnabled = downcast<ThreadedScrollingTree>(scrollingTree).scrollAnimatorEnabled(); 55 } 56 57 ScrollingTreeOverflowScrollingNodeNicosia::~ScrollingTreeOverflowScrollingNodeNicosia() = default; 58 59 void ScrollingTreeOverflowScrollingNodeNicosia::commitStateAfterChildren(const ScrollingStateNode& stateNode) 60 { 61 ScrollingTreeOverflowScrollingNode::commitStateAfterChildren(stateNode); 62 63 const auto& overflowStateNode = downcast<ScrollingStateOverflowScrollingNode>(stateNode); 64 if (overflowStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { 65 stopScrollAnimations(); 66 const auto& requestedScrollData = overflowStateNode.requestedScrollData(); 67 scrollTo(requestedScrollData.scrollPosition, requestedScrollData.scrollType, requestedScrollData.clamping); 68 #if ENABLE(SMOOTH_SCROLLING) 69 if (m_smoothAnimation) 70 m_smoothAnimation->setCurrentPosition(currentScrollPosition()); 71 #endif 72 } 73 } 74 75 FloatPoint ScrollingTreeOverflowScrollingNodeNicosia::adjustedScrollPosition(const FloatPoint& position, ScrollClamping clamping) const 76 { 77 FloatPoint scrollPosition(roundf(position.x()), roundf(position.y())); 78 return ScrollingTreeOverflowScrollingNode::adjustedScrollPosition(scrollPosition, clamping); 79 } 80 81 void ScrollingTreeOverflowScrollingNodeNicosia::repositionScrollingLayers() 82 { 83 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 84 ASSERT(scrollLayer); 85 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 86 87 auto scrollOffset = currentScrollOffset(); 88 89 compositionLayer.updateState( 90 [&scrollOffset](Nicosia::CompositionLayer::LayerState& state) 91 { 92 state.boundsOrigin = scrollOffset; 93 state.delta.boundsOriginChanged = true; 94 }); 95 96 #if ENABLE(SMOOTH_SCROLLING) 97 if (m_smoothAnimation) 98 m_smoothAnimation->updateVisibleLengths(); 99 #endif 100 } 101 102 #if ENABLE(KINETIC_SCROLLING) 103 void ScrollingTreeOverflowScrollingNodeNicosia::ensureScrollAnimationKinetic() 104 { 105 if (m_kineticAnimation) 106 return; 107 55 108 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 56 109 [this]() -> ScrollExtents { … … 59 112 [this](FloatPoint&& position) { 60 113 #if ENABLE(SMOOTH_SCROLLING) 61 m_smoothAnimation->setCurrentPosition(position); 114 if (m_smoothAnimation) 115 m_smoothAnimation->setCurrentPosition(position); 62 116 #endif 63 117 … … 69 123 scrollTo(position); 70 124 }); 71 #endif 72 #if ENABLE(SMOOTH_SCROLLING) 125 } 126 #endif 127 128 #if ENABLE(SMOOTH_SCROLLING) 129 void ScrollingTreeOverflowScrollingNodeNicosia::ensureScrollAnimationSmooth() 130 { 131 if (m_smoothAnimation) 132 return; 133 73 134 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>( 74 135 [this]() -> ScrollExtents { … … 85 146 }, 86 147 [] { }); 87 #endif 88 } 89 90 ScrollingTreeOverflowScrollingNodeNicosia::~ScrollingTreeOverflowScrollingNodeNicosia() = default; 91 92 void ScrollingTreeOverflowScrollingNodeNicosia::commitStateAfterChildren(const ScrollingStateNode& stateNode) 93 { 94 ScrollingTreeOverflowScrollingNode::commitStateAfterChildren(stateNode); 95 96 const auto& overflowStateNode = downcast<ScrollingStateOverflowScrollingNode>(stateNode); 97 if (overflowStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { 98 stopScrollAnimations(); 99 const auto& requestedScrollData = overflowStateNode.requestedScrollData(); 100 scrollTo(requestedScrollData.scrollPosition, requestedScrollData.scrollType, requestedScrollData.clamping); 101 #if ENABLE(SMOOTH_SCROLLING) 102 m_smoothAnimation->setCurrentPosition(currentScrollPosition()); 103 #endif 104 } 105 } 106 107 FloatPoint ScrollingTreeOverflowScrollingNodeNicosia::adjustedScrollPosition(const FloatPoint& position, ScrollClamping clamping) const 108 { 109 FloatPoint scrollPosition(roundf(position.x()), roundf(position.y())); 110 return ScrollingTreeOverflowScrollingNode::adjustedScrollPosition(scrollPosition, clamping); 111 } 112 113 void ScrollingTreeOverflowScrollingNodeNicosia::repositionScrollingLayers() 114 { 115 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 116 ASSERT(scrollLayer); 117 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 118 119 auto scrollOffset = currentScrollOffset(); 120 121 compositionLayer.updateState( 122 [&scrollOffset](Nicosia::CompositionLayer::LayerState& state) 123 { 124 state.boundsOrigin = scrollOffset; 125 state.delta.boundsOriginChanged = true; 126 }); 127 } 148 } 149 #endif 128 150 129 151 WheelEventHandlingResult ScrollingTreeOverflowScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent) … … 133 155 134 156 #if ENABLE(KINETIC_SCROLLING) 157 ensureScrollAnimationKinetic(); 135 158 m_kineticAnimation->appendToScrollHistory(wheelEvent); 136 159 m_kineticAnimation->stop(); … … 175 198 176 199 #if ENABLE(SMOOTH_SCROLLING) 177 m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, -deltaX); 178 m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, -deltaY); 179 #else 200 if (m_scrollAnimatorEnabled && !wheelEvent.hasPreciseScrollingDeltas()) { 201 ensureScrollAnimationSmooth(); 202 m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, -deltaX); 203 m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, -deltaY); 204 return WheelEventHandlingResult::handled(); 205 } 206 #endif 207 180 208 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrollContainerLayer()); 181 209 ASSERT(scrollLayer); … … 184 212 auto updateScope = compositionLayer.createUpdateScope(); 185 213 scrollBy({ -deltaX, -deltaY }); 186 #endif187 214 188 215 return WheelEventHandlingResult::handled(); … … 192 219 { 193 220 #if ENABLE(KINETIC_SCROLLING) 194 m_kineticAnimation->stop(); 195 m_kineticAnimation->clearScrollHistory(); 196 #endif 197 #if ENABLE(SMOOTH_SCROLLING) 198 m_smoothAnimation->stop(); 221 if (m_kineticAnimation) { 222 m_kineticAnimation->stop(); 223 m_kineticAnimation->clearScrollHistory(); 224 } 225 #endif 226 #if ENABLE(SMOOTH_SCROLLING) 227 if (m_smoothAnimation) 228 m_smoothAnimation->stop(); 199 229 #endif 200 230 } -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h
r266390 r268522 51 51 void repositionScrollingLayers() override; 52 52 53 #if ENABLE(KINETIC_SCROLLING) 54 void ensureScrollAnimationKinetic(); 55 #endif 56 #if ENABLE(SMOOTH_SCROLLING) 57 void ensureScrollAnimationSmooth(); 58 #endif 59 53 60 WheelEventHandlingResult handleWheelEvent(const PlatformWheelEvent&) override; 54 61 55 62 void stopScrollAnimations() override; 56 63 64 bool m_scrollAnimatorEnabled { false }; 57 65 #if ENABLE(KINETIC_SCROLLING) 58 66 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; -
trunk/Source/WebCore/platform/PlatformWheelEvent.h
r268287 r268522 142 142 #endif 143 143 144 #if PLATFORM(COCOA) 144 #if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE) 145 145 bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; } 146 146 void setHasPreciseScrollingDeltas(bool hasPreciseScrollingDeltas) { m_hasPreciseScrollingDeltas = hasPreciseScrollingDeltas; } 147 #endif 148 149 #if PLATFORM(COCOA) 147 150 unsigned scrollCount() const { return m_scrollCount; } 148 151 float unacceleratedScrollingDeltaX() const { return m_unacceleratedScrollingDeltaX; } … … 194 197 PlatformWheelEventPhase m_momentumPhase { PlatformWheelEventPhaseNone }; 195 198 #endif 199 #if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE) 200 bool m_hasPreciseScrollingDeltas { false }; 201 #endif 196 202 #if PLATFORM(COCOA) 197 bool m_hasPreciseScrollingDeltas { false };198 203 unsigned m_scrollCount { 0 }; 199 204 float m_unacceleratedScrollingDeltaX { 0 }; -
trunk/Source/WebCore/platform/ScrollAnimation.h
r266390 r268522 51 51 virtual void setCurrentPosition(const FloatPoint&) { }; 52 52 virtual void serviceAnimation() { }; 53 virtual bool isActive() const = 0; 53 54 }; 54 55 -
trunk/Source/WebCore/platform/ScrollAnimationKinetic.cpp
r266390 r268522 129 129 } 130 130 131 bool ScrollAnimationKinetic::isActive() const 132 { 133 return m_animationTimer.isActive(); 134 } 135 131 136 void ScrollAnimationKinetic::appendToScrollHistory(const PlatformWheelEvent& event) 132 137 { -
trunk/Source/WebCore/platform/ScrollAnimationKinetic.h
r266390 r268522 71 71 void start(const FloatPoint& initialPosition, const FloatPoint& velocity, bool mayHScroll, bool mayVScroll); 72 72 void stop() override; 73 bool isActive() const override; 73 74 74 75 private: -
trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp
r266390 r268522 86 86 } 87 87 bool needToScroll = updatePerAxisData(orientation == HorizontalScrollbar ? m_horizontalData : m_verticalData, granularity, step * multiplier, minScrollPosition, maxScrollPosition); 88 if (needToScroll && ! animationTimerActive()) {88 if (needToScroll && !isActive()) { 89 89 m_startTime = orientation == HorizontalScrollbar ? m_horizontalData.startTime : m_verticalData.startTime; 90 90 animationTimerFired(); … … 100 100 needToScroll |= 101 101 updatePerAxisData(m_verticalData, granularity, position.y() - m_verticalData.currentPosition, extents.minimumScrollPosition.y(), extents.maximumScrollPosition.y(), smoothFactorForProgrammaticScroll); 102 if (needToScroll && ! animationTimerActive()) {102 if (needToScroll && !isActive()) { 103 103 m_startTime = m_horizontalData.startTime; 104 104 animationTimerFired(); … … 450 450 } 451 451 452 bool ScrollAnimationSmooth:: animationTimerActive() const452 bool ScrollAnimationSmooth::isActive() const 453 453 { 454 454 return m_animationTimer.isActive(); -
trunk/Source/WebCore/platform/ScrollAnimationSmooth.h
r266390 r268522 59 59 void updateVisibleLengths() override; 60 60 void setCurrentPosition(const FloatPoint&) override; 61 bool isActive() const override; 61 62 62 63 struct PerAxisData { … … 102 103 void startNextTimer(Seconds delay); 103 104 void animationTimerFired(); 104 bool animationTimerActive() const;105 105 106 106 ScrollExtentsCallback m_scrollExtentsFunction; -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp
r266390 r268522 74 74 void ScrollAnimatorGeneric::ensureSmoothScrollingAnimation() 75 75 { 76 if (m_smoothAnimation) 77 return; 76 if (m_smoothAnimation) { 77 if (!m_smoothAnimation->isActive()) 78 m_smoothAnimation->setCurrentPosition(m_currentPosition); 79 return; 80 } 78 81 79 82 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>( -
trunk/Source/WebKit/ChangeLog
r268521 r268522 1 2020-10-15 Chris Lord <clord@igalia.com> 2 3 [GTK][WPE] Add support for smooth scrolling animation with async scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=210382 5 6 Reviewed by Carlos Garcia Campos. 7 8 Add hasPreciseScrollingDeltas to GTK/WPE wheel events. 9 10 No new tests needed. 11 12 * Shared/WebEventConversion.cpp: 13 (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent): 14 * Shared/WebWheelEvent.cpp: 15 (WebKit::WebWheelEvent::WebWheelEvent): 16 (WebKit::WebWheelEvent::encode const): 17 (WebKit::WebWheelEvent::decode): 18 * Shared/WebWheelEvent.h: 19 * Shared/WebWheelEventCoalescer.cpp: 20 (WebKit::WebWheelEventCoalescer::canCoalesce): 21 (WebKit::WebWheelEventCoalescer::coalesce): 22 * Shared/gtk/NativeWebWheelEventGtk.cpp: 23 (WebKit::NativeWebWheelEvent::NativeWebWheelEvent): 24 * Shared/gtk/WebEventFactory.cpp: 25 (WebKit::WebEventFactory::createWebWheelEvent): 26 * Shared/libwpe/WebEventFactory.cpp: 27 (WebKit::WebEventFactory::createWebWheelEvent): 28 1 29 2020-10-15 Youenn Fablet <youenn@apple.com> 2 30 -
trunk/Source/WebKit/Shared/WebEventConversion.cpp
r267916 r268522 165 165 m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.momentumPhase()); 166 166 #endif 167 #if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE) 168 m_hasPreciseScrollingDeltas = webEvent.hasPreciseScrollingDeltas(); 169 #endif 167 170 #if PLATFORM(COCOA) 168 m_hasPreciseScrollingDeltas = webEvent.hasPreciseScrollingDeltas();169 171 m_scrollCount = webEvent.scrollCount(); 170 172 m_unacceleratedScrollingDeltaX = webEvent.unacceleratedScrollingDelta().width(); -
trunk/Source/WebKit/Shared/WebWheelEvent.cpp
r267916 r268522 62 62 } 63 63 #elif PLATFORM(GTK) || USE(LIBWPE) 64 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)64 WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Phase phase, Phase momentumPhase, Granularity granularity, bool hasPreciseScrollingDeltas, OptionSet<Modifier> modifiers, WallTime timestamp) 65 65 : WebEvent(type, modifiers, timestamp) 66 66 , m_position(position) … … 71 71 , m_phase(phase) 72 72 , m_momentumPhase(momentumPhase) 73 , m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas) 73 74 { 74 75 ASSERT(isWheelEventType(type)); … … 89 90 encoder << m_phase; 90 91 encoder << m_momentumPhase; 92 encoder << m_hasPreciseScrollingDeltas; 91 93 #endif 92 94 #if PLATFORM(COCOA) 93 encoder << m_hasPreciseScrollingDeltas;94 95 encoder << m_scrollCount; 95 96 encoder << m_unacceleratedScrollingDelta; … … 118 119 if (!decoder.decode(t.m_momentumPhase)) 119 120 return false; 121 if (!decoder.decode(t.m_hasPreciseScrollingDeltas)) 122 return false; 120 123 #endif 121 124 #if PLATFORM(COCOA) 122 if (!decoder.decode(t.m_hasPreciseScrollingDeltas))123 return false;124 125 if (!decoder.decode(t.m_scrollCount)) 125 126 return false; -
trunk/Source/WebKit/Shared/WebWheelEvent.h
r267916 r268522 56 56 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); 57 57 #elif PLATFORM(GTK) || USE(LIBWPE) 58 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);58 WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Phase, Phase momentumPhase, Granularity, bool hasPreciseScrollingDeltas, OptionSet<Modifier>, WallTime timestamp); 59 59 #endif 60 60 … … 67 67 Phase phase() const { return static_cast<Phase>(m_phase); } 68 68 Phase momentumPhase() const { return static_cast<Phase>(m_momentumPhase); } 69 #if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE) 70 bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; } 71 #endif 69 72 #if PLATFORM(COCOA) 70 bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }71 73 uint32_t scrollCount() const { return m_scrollCount; } 72 74 const WebCore::FloatSize& unacceleratedScrollingDelta() const { return m_unacceleratedScrollingDelta; } … … 87 89 uint32_t m_momentumPhase { Phase::PhaseNone }; 88 90 bool m_directionInvertedFromDevice { false }; 91 #if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE) 92 bool m_hasPreciseScrollingDeltas { false }; 93 #endif 89 94 #if PLATFORM(COCOA) 90 bool m_hasPreciseScrollingDeltas { false };91 95 uint32_t m_scrollCount { 0 }; 92 96 WebCore::FloatSize m_unacceleratedScrollingDelta; -
trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp
r268287 r268522 60 60 if (a.momentumPhase() != b.momentumPhase()) 61 61 return false; 62 #endif 63 #if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE) 62 64 if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas()) 63 65 return false; … … 78 80 79 81 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.directionInvertedFromDevice(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.scrollCount(), mergedUnacceleratedScrollingDelta, b.modifiers(), b.timestamp()); 82 #elif PLATFORM(GTK) || USE(LIBWPE) 83 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.phase(), b.momentumPhase(), b.granularity(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp()); 80 84 #else 81 85 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp()); -
trunk/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp
r263887 r268522 51 51 52 52 NativeWebWheelEvent::NativeWebWheelEvent(const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, WebWheelEvent::Phase phase, WebWheelEvent::Phase momentumPhase) 53 : WebWheelEvent(WebEvent::Wheel, position, globalPosition, delta, wheelTicks, phase, momentumPhase, WebWheelEvent::ScrollByPixelWheelEvent, { }, WallTime::now())53 : WebWheelEvent(WebEvent::Wheel, position, globalPosition, delta, wheelTicks, phase, momentumPhase, WebWheelEvent::ScrollByPixelWheelEvent, false, { }, WallTime::now()) 54 54 { 55 55 } 56 56 57 57 NativeWebWheelEvent::NativeWebWheelEvent(const NativeWebWheelEvent& event) 58 : WebWheelEvent(event.type(), event.position(), event.globalPosition(), event.delta(), event.wheelTicks(), event.phase(), event.momentumPhase(), event.granularity(), event. modifiers(), event.timestamp())58 : WebWheelEvent(event.type(), event.position(), event.globalPosition(), event.delta(), event.wheelTicks(), event.phase(), event.momentumPhase(), event.granularity(), event.hasPreciseScrollingDeltas(), event.modifiers(), event.timestamp()) 59 59 , m_nativeEvent(event.nativeEvent() ? gdk_event_copy(event.nativeEvent()) : nullptr) 60 60 { -
trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp
r263887 r268522 289 289 momentumPhase, 290 290 WebWheelEvent::ScrollByPixelWheelEvent, 291 false, 291 292 modifiersForEvent(event), 292 293 wallTimeForEvent(event)); -
trunk/Source/WebKit/Shared/libwpe/WebEventFactory.cpp
r262702 r268522 165 165 WebCore::FloatSize wheelTicks; 166 166 WebCore::FloatSize delta; 167 bool hasPreciseScrollingDeltas = false; 167 168 168 169 #if WPE_CHECK_VERSION(1, 5, 0) … … 178 179 wheelTicks = WebCore::FloatSize(event2D->x_axis / deviceScaleFactor, event2D->y_axis / deviceScaleFactor); 179 180 delta = wheelTicks; 181 hasPreciseScrollingDeltas = true; 180 182 break; 181 183 default: … … 185 187 return WebWheelEvent(WebEvent::Wheel, position, position, 186 188 delta, wheelTicks, phase, momentumPhase, 187 WebWheelEvent::ScrollByPixelWheelEvent, 189 WebWheelEvent::ScrollByPixelWheelEvent, hasPreciseScrollingDeltas, 188 190 OptionSet<WebEvent::Modifier> { }, wallTimeForEventTime(event->time)); 189 191 } … … 211 213 wheelTicks = WebCore::FloatSize(0, event->value / deviceScaleFactor); 212 214 delta = wheelTicks; 215 hasPreciseScrollingDeltas = true; 213 216 break; 214 217 default: … … 218 221 return WebWheelEvent(WebEvent::Wheel, position, position, 219 222 delta, wheelTicks, phase, momentumPhase, 220 WebWheelEvent::ScrollByPixelWheelEvent, 223 WebWheelEvent::ScrollByPixelWheelEvent, hasPreciseScrollingDeltas, 221 224 OptionSet<WebEvent::Modifier> { }, wallTimeForEventTime(event->time)); 222 225 }
Note: See TracChangeset
for help on using the changeset viewer.