Changeset 285205 in webkit
- Timestamp:
- Nov 3, 2021, 7:37:04 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
-
ChangeLog (modified) (1 diff)
-
dom/Document.cpp (modified) (2 diffs)
-
page/FrameView.cpp (modified) (1 diff)
-
page/FrameView.h (modified) (1 diff)
-
platform/ScrollAnimator.cpp (modified) (3 diffs)
-
platform/ScrollAnimator.h (modified) (3 diffs)
-
platform/ScrollableArea.h (modified) (2 diffs)
-
platform/ScrollingEffectsController.cpp (modified) (1 diff)
-
rendering/RenderLayerScrollableArea.cpp (modified) (1 diff)
-
rendering/RenderLayerScrollableArea.h (modified) (1 diff)
-
rendering/RenderListBox.cpp (modified) (1 diff)
-
rendering/RenderListBox.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r285204 r285205 1 2021-11-03 Chris Lord <clord@igalia.com> 2 3 [GTK][WPE] Use the display refresh to drive scrolling animations (sync scroll) 4 https://bugs.webkit.org/show_bug.cgi?id=232077 5 6 Reviewed by Simon Fraser. 7 8 Service sync scroll animations as part of the scroll phase in 9 Page::updateRendering, which is driven by the display refresh. 10 11 No new tests, covered by existing tests. 12 13 * dom/Document.cpp: 14 (WebCore::serviceScrollAnimationForScrollableArea): 15 (WebCore::Document::runScrollSteps): 16 * page/FrameView.cpp: 17 (WebCore::FrameView::didStartScrollAnimation): 18 * page/FrameView.h: 19 * platform/ScrollAnimator.cpp: 20 (WebCore::ScrollAnimator::ScrollAnimator): 21 (WebCore::ScrollAnimator::startAnimationCallback): 22 (WebCore::ScrollAnimator::stopAnimationCallback): 23 (WebCore::ScrollAnimator::serviceScrollAnimation): 24 (WebCore::ScrollAnimator::scrollControllerAnimationTimerFired): Deleted. 25 * platform/ScrollAnimator.h: 26 * platform/ScrollableArea.h: 27 (WebCore::ScrollableArea::didStartScrollAnimation): 28 * platform/ScrollingEffectsController.cpp: 29 (WebCore::ScrollingEffectsController::retargetAnimatedScrollBy): 30 * rendering/RenderLayerScrollableArea.cpp: 31 (WebCore::RenderLayerScrollableArea::didStartScrollAnimation): 32 * rendering/RenderLayerScrollableArea.h: 33 * rendering/RenderListBox.cpp: 34 (WebCore::RenderListBox::didStartScrollAnimation): 35 * rendering/RenderListBox.h: 36 1 37 2021-11-03 Zalan Bujtas <zalan@apple.com> 2 38 -
trunk/Source/WebCore/dom/Document.cpp
r284857 r285205 212 212 #include "ScriptState.h" 213 213 #include "ScriptedAnimationController.h" 214 #include "ScrollAnimator.h" 214 215 #include "ScrollbarTheme.h" 215 216 #include "ScrollingCoordinator.h" … … 4348 4349 } 4349 4350 4351 static bool serviceScrollAnimationForScrollableArea(ScrollableArea* scrollableArea, MonotonicTime time) 4352 { 4353 if (!scrollableArea) 4354 return false; 4355 4356 if (auto* animator = scrollableArea->existingScrollAnimator()) 4357 return animator->serviceScrollAnimation(time) == ScrollAnimationStatus::Animating; 4358 4359 return false; 4360 } 4361 4350 4362 // https://drafts.csswg.org/cssom-view/#run-the-scroll-steps 4351 4363 void Document::runScrollSteps() 4352 4364 { 4365 // Service user scroll animations before scroll event dispatch. 4366 RefPtr<FrameView> frameView = view(); 4367 if (frameView) { 4368 MonotonicTime now = MonotonicTime::now(); 4369 bool scrollAnimationsInProgress = serviceScrollAnimationForScrollableArea(frameView.get(), now); 4370 if (auto* scrollableAreas = frameView->scrollableAreas()) { 4371 for (auto* scrollableArea : *scrollableAreas) { 4372 if (serviceScrollAnimationForScrollableArea(scrollableArea, now)) 4373 scrollAnimationsInProgress = true; 4374 } 4375 } 4376 if (scrollAnimationsInProgress) 4377 page()->scheduleRenderingUpdate({ RenderingUpdateStep::Scroll }); 4378 } 4379 4353 4380 // FIXME: The order of dispatching is not specified: https://github.com/WICG/visual-viewport/issues/66. 4354 4381 if (m_pendingScrollEventTargetList && !m_pendingScrollEventTargetList->targets.isEmpty()) { -
trunk/Source/WebCore/page/FrameView.cpp
r285120 r285205 5701 5701 } 5702 5702 5703 void FrameView::didStartScrollAnimation() 5704 { 5705 if (auto* page = frame().page()) 5706 page->scheduleRenderingUpdate({ RenderingUpdateStep::Scroll }); 5707 } 5708 5703 5709 void FrameView::updateScrollbarSteps() 5704 5710 { -
trunk/Source/WebCore/page/FrameView.h
r284857 r285205 877 877 // ScrollableArea. 878 878 float pageScaleFactor() const override; 879 void didStartScrollAnimation() final; 879 880 880 881 static MonotonicTime sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r284857 r285205 55 55 : m_scrollableArea(scrollableArea) 56 56 , m_scrollController(*this) 57 , m_scrollControllerAnimationTimer(*this, &ScrollAnimator::scrollControllerAnimationTimerFired)58 57 , m_keyboardScrollingAnimator(makeUnique<KeyboardScrollingAnimator>(*this, m_scrollController)) 59 58 { … … 385 384 void ScrollAnimator::startAnimationCallback(ScrollingEffectsController&) 386 385 { 387 if ( m_scrollControllerAnimationTimer.isActive())388 return;389 390 m_scrollControllerAnimationTimer.startRepeating(1_s / 60.);386 if (!m_scrollAnimationScheduled) { 387 m_scrollAnimationScheduled = true; 388 m_scrollableArea.didStartScrollAnimation(); 389 } 391 390 } 392 391 393 392 void ScrollAnimator::stopAnimationCallback(ScrollingEffectsController&) 394 393 { 395 m_scrollControllerAnimationTimer.stop(); 396 } 397 398 void ScrollAnimator::scrollControllerAnimationTimerFired() 399 { 400 m_scrollController.animationCallback(MonotonicTime::now()); 394 m_scrollAnimationScheduled = false; 401 395 } 402 396 … … 466 460 } 467 461 462 ScrollAnimationStatus ScrollAnimator::serviceScrollAnimation(MonotonicTime time) 463 { 464 if (m_scrollAnimationScheduled) 465 m_scrollController.animationCallback(time); 466 return m_scrollAnimationScheduled ? ScrollAnimationStatus::Animating : ScrollAnimationStatus::NotAnimating; 467 } 468 468 469 } // namespace WebCore -
trunk/Source/WebCore/platform/ScrollAnimator.h
r284575 r285205 124 124 void resnapAfterLayout(); 125 125 126 ScrollAnimationStatus serviceScrollAnimation(MonotonicTime); 127 126 128 protected: 127 129 virtual bool platformAllowsScrollAnimation() const { return true; } … … 130 132 void notifyPositionChanged(const FloatSize& delta); 131 133 132 void scrollControllerAnimationTimerFired();133 134 void updateActiveScrollSnapIndexForOffset(); 134 135 … … 177 178 RefPtr<WheelEventTestMonitor> m_wheelEventTestMonitor; 178 179 ScrollingEffectsController m_scrollController; 179 Timer m_scrollControllerAnimationTimer;180 180 FloatPoint m_currentPosition; 181 181 182 182 std::unique_ptr<KeyboardScrollingAnimator> m_keyboardScrollingAnimator; 183 184 private: 185 bool m_scrollAnimationScheduled { false }; 183 186 }; 184 187 -
trunk/Source/WebCore/platform/ScrollableArea.h
r284575 r285205 354 354 } 355 355 356 virtual void didStartScrollAnimation() { } 357 356 358 protected: 357 359 WEBCORE_EXPORT ScrollableArea(); … … 414 416 bool m_scrollOriginChanged { false }; 415 417 bool m_scrollShouldClearLatchedState { false }; 418 bool m_hasActiveScrollAnimation { false }; 416 419 }; 417 420 -
trunk/Source/WebCore/platform/ScrollingEffectsController.cpp
r284596 r285205 121 121 bool ScrollingEffectsController::retargetAnimatedScrollBy(FloatSize offset) 122 122 { 123 if (!is<ScrollAnimationSmooth>(m_currentAnimation.get()) )123 if (!is<ScrollAnimationSmooth>(m_currentAnimation.get()) || !m_currentAnimation->isActive()) 124 124 return false; 125 125 126 126 LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " retargetAnimatedScrollBy " << offset); 127 127 128 ASSERT(m_currentAnimation->isActive());129 128 if (auto destinationOffset = m_currentAnimation->destinationOffset()) 130 129 return m_currentAnimation->retargetActiveAnimation(*destinationOffset + offset); -
trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp
r284138 r285205 1841 1841 } 1842 1842 1843 void RenderLayerScrollableArea::didStartScrollAnimation() 1844 { 1845 m_layer.page().scheduleRenderingUpdate({ RenderingUpdateStep::Scroll }); 1846 } 1847 1843 1848 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h
r284138 r285205 195 195 196 196 String debugDescription() const final; 197 void didStartScrollAnimation() final; 197 198 198 199 IntSize visibleSize() const final; -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r284857 r285205 909 909 } 910 910 911 void RenderListBox::didStartScrollAnimation() 912 { 913 page().scheduleRenderingUpdate({ RenderingUpdateStep::Scroll }); 914 } 915 911 916 Ref<Scrollbar> RenderListBox::createScrollbar() 912 917 { -
trunk/Source/WebCore/rendering/RenderListBox.h
r284857 r285205 142 142 void logMockScrollAnimatorMessage(const String&) const final; 143 143 String debugDescription() const final; 144 void didStartScrollAnimation() final; 144 145 145 146 // NOTE: This should only be called by the overridden setScrollOffset from ScrollableArea.
Note:
See TracChangeset
for help on using the changeset viewer.