Subversion Revision: 252886 diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 8838d3e1386cc9f2f197848c16dafd92ee255b19..5a8fc11a3bde3144bee80fe9285e6b947c39eb9f 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,215 @@ +2018-11-09 Frederic Wang + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + + Reviewed by NOBODY (OOPS!). + + This patch introduces a programmatic smooth scrolling in WebKit from the CSSOM View + specification [1]. To use this effect, web developers can pass a behavior parameter (auto, + smooth, or instant) to Element.scroll, Element.scrollTo, Element.scrollBy, + Element.scrollIntoView, Window.scroll, Window.scrollTo or Window.scrollBy [2]. When behavior + is auto, the instant/smooth characteristic is actually taken from the value of a new CSS + scroll-behavior property [3]. Both the new CSS and DOM behavior are protected by a runtime + flag. The Element.scrollIntoView part will be refined later in bug 189907. The actual + animation of non-iOS platform relies on the existing ScrollAnimationSmooth. + On iOS platform it is using UIScrollView scroll animation. The scroll position is synchronous + from UI process to Web process. + + [1] https://drafts.csswg.org/cssom-view + [2] https://drafts.csswg.org/cssom-view/#dictdef-scrolloptions + [3] https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + + Tests: imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css.html + imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element.html + imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html + imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html + imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested.html + imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth-positions.html + imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html + imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html + fast/scrolling/ios/scroll-behavior-default-css.html + fast/scrolling/ios/scroll-behavior-element.html + fast/scrolling/ios/scroll-behavior-main-frame-root.html + fast/scrolling/ios/scroll-behavior-main-frame-window.html + fast/scrolling/ios/scroll-behavior-scrollintoview-nested.html + fast/scrolling/ios/scroll-behavior-smooth-positions.html + fast/scrolling/ios/scroll-behavior-subframe-root.html + fast/scrolling/ios/scroll-behavior-subframe-window.html + + * CMakeLists.txt: Add IDL files for ScrollOptions and ScrollBehavior. + * DerivedSources.make: Ditto. + * Headers.cmake: Add headers for ScrollBehavor and ScrollOptions. + * Sources.txt: Add ScrollBehavor and ScrollOptions implementation. Also build + ScrollAnimationSmooth.cpp on all platforms. + * SourcesGTK.txt: Remove ScrollAnimationSmooth.cpp since it is built on all platforms now. + * WebCore.xcodeproj/project.pbxproj: Add files to the build system. + * css/CSSComputedStyleDeclaration.cpp: Handle scroll-behavior. + (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): + * css/CSSProperties.json: Add scroll-behavior. + * css/CSSValueKeywords.in: Add keywords for scroll-behavior. + * css/parser/CSSParserContext.cpp: Add runtime config for scroll-behavior. + (WebCore::CSSParserContext::CSSParserContext): + (WebCore::operator==): + * css/parser/CSSParserContext.h: Ditto. + (WebCore::CSSParserContextHash::hash): + * css/parser/CSSParserFastPaths.cpp: Remove scroll-behavior templates. It is handled in the + slow path since property can be disabled. + (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): + (WebCore::CSSParserFastPaths::isKeywordPropertyID): + * css/parser/CSSPropertyParser.cpp: + (WebCore::consumeScrollBehavior): + (WebCore::CSSPropertyParser::parseSingleValue): Parse scroll-behavior (only if enabled). + * dom/Element.cpp: + (WebCore::Element::scrollIntoView): Pass scroll behavior, if any. + (WebCore::Element::scrollBy): + (WebCore::Element::scrollTo): Handle the case when scroll behavior is smooth. + (WebCore::Element::setScrollLeft): Handle the case when scroll behavior is smooth. + (WebCore::Element::setScrollTop): Handle the case when scroll behavior is smooth. + * page/DOMWindow.cpp: + (WebCore::DOMWindow::scrollBy const): + (WebCore::DOMWindow::scrollTo const): Handle the case when scroll behavior is smooth. The optimization when scroll position is (0, 0) is skipped + when a scroll is in progress, otherwise such a scroll can't be cancelled by a follow-up + scroll. + * page/FrameView.cpp: + (WebCore::FrameView::scrollToOffsetWithAnimation): Start an animation for scrolling. + * page/FrameView.h: + * page/ScrollBehavior.cpp: Added. + (WebCore::useSmoothScrolling): Helper funciton to determine the scroll behavior to apply to + an element from the CSS and DOM behavior. + * page/ScrollBehavior.h: Added. + * page/ScrollBehavior.idl: Added. + * page/ScrollIntoViewOptions.h: Make this class inherits from ScrollOption. Also remove + unnecessary forward declaration. + * page/ScrollIntoViewOptions.idl: Make this class inherits from ScrollOption. + * page/ScrollOptions.h: Added. + * page/ScrollOptions.idl: Added. + * page/ScrollToOptions.h: Make this struct inherits from ScrollOptions. + (WebCore::normalizeNonFiniteCoordinatesOrFallBackTo): Copy the current ScrollToOptions so + that the scroll behavior is preserved. + * page/ScrollToOptions.idl: Make this class inherit from ScrollOptions. + * page/Settings.yaml: New setting for CSSOM View smooth scrolling. + * page/scrolling/AsyncScrollingCoordinator.cpp: + (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate): Add a flag to indicate if this is animation scroll or not. + (WebCore::AsyncScrollingCoordinator::setScrollAnimationInProgress): Update the scroll animation status from UI side. + * page/scrolling/AsyncScrollingCoordinator.h: + * page/scrolling/ScrollingStateScrollingNode.cpp: + (WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode): Add m_requestedScrollPositionWithAnimation to indicate it's animated. + (WebCore::ScrollingStateScrollingNode::setRequestedScrollPosition): Ditto. + (WebCore::ScrollingStateScrollingNode::dumpProperties const): Ditto. + * page/scrolling/ScrollingStateScrollingNode.h: + (WebCore::ScrollingStateScrollingNode::requestedScrollPositionWithAnimation const): Ditto. + * page/scrolling/ScrollingTree.h: + (WebCore::ScrollingTree::scrollingTreeNodeRequestsScroll): Add withAnimation. + (WebCore::ScrollingTree::scrollingTreeNodeIsScrollAnimationInProgressDidChange): Update scroll animation status. + * page/scrolling/ScrollingTreeScrollingNode.cpp: + (WebCore::ScrollingTreeScrollingNode::commitStateAfterChildren): + (WebCore::ScrollingTreeScrollingNode::scrollTo): If needSyncScrollPosition is true, sync scroll position to Web side, even if scroll offset doesn't change. + Maintain the status of m_stopScrollAnimation and m_requestScrollWithAnimation. + (WebCore::ScrollingTreeScrollingNode::setRequestScrollWithAnimation): m_requestScrollWithAnimation indicates this is a animation scroll request. + (WebCore::ScrollingTreeScrollingNode::currentScrollPositionChanged): Animation scroll won't change scoll position immediatelly, so don't notify scroll info. + (WebCore::ScrollingTreeScrollingNode::setRequestScrollWithAnimation): Indicate this scroll request is animated or not. + (WebCore::ScrollingTreeScrollingNode::requestScrollWithAnimation const): Ditto. + (WebCore::ScrollingTreeScrollingNode::setScrollAnimationInProgress): Maintain scroll animation status. + (WebCore::ScrollingTreeScrollingNode::scrollAnimationInProgress const): Ditto. + (WebCore::ScrollingTreeScrollingNode::setNeedsStopCurrentScrollAnimation): If the Node is during scroll animation, the previous animation should stop first. + (WebCore::ScrollingTreeScrollingNode::needsStopCurrentScrollAnimation const): Ditto. + * page/scrolling/ScrollingTreeScrollingNode.h: + * platform/ScrollAnimation.h: + (WebCore::ScrollAnimation::scroll): Function to animate scrolling to a specified position. + (WebCore::ScrollAnimation::isScrollInProgress const): + * platform/ScrollAnimationKinetic.cpp: + (WebCore::ScrollAnimationKinetic::isScrollInProgress const): + * platform/ScrollAnimationKinetic.h: + * platform/ScrollAnimationSmooth.cpp: Build this file on all platforms. Add a + smoothFactorForProgrammaticScroll parameter to slow down the smooth scrolling. + (WebCore::ScrollAnimationSmooth::scroll): + (WebCore::ScrollAnimationSmooth::updatePerAxisData): Scale the time parameters of the + animation so that it looks smoother. + * platform/ScrollAnimationSmooth.h: Declare the class on all platforms. + * platform/ScrollAnimator.cpp: + (WebCore::ScrollAnimator::ScrollAnimator): Initialize animation member for programmatic scrolling. + (WebCore::ScrollAnimator::isScrollInProgress const): For now, only claims scroll is in + progress if smooth programmatic scroll is in progress. + (WebCore::ScrollAnimator::scrollToOffset): Animate scrolling to the specified position. + (WebCore::ScrollAnimator::cancelAnimations): Copy logic from ScrollAnimationSmooth.cpp. + (WebCore::ScrollAnimator::serviceScrollAnimations): Ditto. + (WebCore::ScrollAnimator::willEndLiveResize): Ditto. + (WebCore::ScrollAnimator::didAddVerticalScrollbar): Ditto. + (WebCore::ScrollAnimator::didAddHorizontalScrollbar): Ditto. + * platform/ScrollAnimator.h: New animation member for smooth programmatic scrolling. + * platform/ScrollTypes.h: Add ScrollBehaviorType to indicate it's instant or smooth scroll. + Add ScrollBehaviorStatus to indicate the status of scroll. + * platform/ScrollView.cpp: + (WebCore::ScrollView::setScrollPosition): Follow the CSSOM View spec: If a scroll is in + progress, we interrupt it and continue the scroll call (even when we are at the final + position). + * platform/ScrollableArea.cpp: + (WebCore::ScrollableArea::ScrollableArea): Add m_currentScrollBehaviorType. + (WebCore::ScrollableArea::isScrollInProgress): Helper function to check whether scroll + animation is in progress on the animator. Using the m_currentScrollBehaviorStatus, + if it's WebAnimationTimerStarted and m_scrollAnimator does not exist we don't construct it. + (WebCore::ScrollableArea::isWebScrollAnimationInProgress): Check if the m_scrollAnimator of + Web side is during a scroll animation. + (WebCore::ScrollableArea::scrollToOffsetWithAnimation): + (WebCore::ScrollableArea::setScrollOffsetFromInternals): + (WebCore::ScrollableArea::setScrollOffsetFromAnimation): To void iterate calling, + move the requestScrollPositionUpdate(position) checking out of setScrollOffsetFromAnimation(). + * platform/ScrollableArea.h: + (WebCore::ScrollableArea::currentScrollBehaviorStatus const): Maintain currentScrollBehaviorStatus. + (WebCore::ScrollableArea::setScrollBehaviorStatus): + (WebCore::ScrollableArea::currentScrollBehaviorType const): Maintain currentScrollBehaviorType. + (WebCore::ScrollableArea::setCurrentScrollBehaviorType): + * platform/generic/ScrollAnimatorGeneric.cpp: + (WebCore::ScrollAnimatorGeneric::updatePosition): + * platform/mac/ScrollAnimatorMac.mm: + (WebCore::ScrollAnimatorMac::cancelAnimations): Call parent member to handle programmatic scrolling. + * rendering/RenderBox.cpp: + (WebCore::RenderBox::setScrollLeft): Add flag to indicate animated or not. + (WebCore::RenderBox::setScrollTop): Ditto. + (WebCore::RenderBox::setScrollPosition): + * rendering/RenderBox.h: + * rendering/RenderLayer.cpp: + (WebCore::RenderLayer::scrollToXPosition): Ditto. + (WebCore::RenderLayer::scrollToYPosition): Ditto. + (WebCore::RenderLayer::scrollToPosition): + (WebCore::RenderLayer::scrollToOffset): Follow the CSSOM View spec: If a scroll is in + progress, we interrupt it and continue the scroll call (even when we are at the final + position). It's ScrollBehaviorType::Instant scroll. + (WebCore::RenderLayer::requestScrollPositionUpdate): + (WebCore::RenderLayer::scrollToOffsetWithAnimation): Ditto. This is similar to scrollToOffset + but animates the scroll. It's ScrollBehaviorType::Smooth scroll. + (WebCore::RenderLayer::scrollTo): + (WebCore::RenderLayer::scrollRectToVisible): Again don't do an early return if scroll is in + progress. We call scrollToOffsetWithAnimation instead of scrollToOffset when appropriate. + Note that this function may not work well for several nested scroll boxes with at least one + element with smooth behavior. It will handled in bug Follow. + * rendering/RenderLayer.h: Add scroll behavior to ScrollTectToVisibleOptions. + * rendering/RenderListBox.cpp: + (WebCore::RenderListBox::setScrollLeft): Add animated flag. + (WebCore::RenderListBox::setScrollTop): Ditto. + * rendering/RenderListBox.h: + * rendering/RenderObject.cpp: + (WebCore::RenderObject::scrollRectToVisible): + * rendering/RenderTextControlSingleLine.cpp: + (WebCore::RenderTextControlSingleLine::setScrollLeft): + (WebCore::RenderTextControlSingleLine::setScrollTop): + * rendering/RenderTextControlSingleLine.h: + * rendering/style/RenderStyle.h: Handle 'smooth scrolling' boolean data. + (WebCore::RenderStyle::useSmoothScrolling const): + (WebCore::RenderStyle::setUseSmoothScrolling): + (WebCore::RenderStyle::initialUseSmoothScrolling): + * rendering/style/StyleRareNonInheritedData.cpp: Ditto. + (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): + (WebCore::StyleRareNonInheritedData::operator== const): + * rendering/style/StyleRareNonInheritedData.h: Ditto. + * style/StyleBuilderConverter.h: + (WebCore::Style::BuilderConverter::convertSmoothScrolling): + * testing/Internals.cpp: + (WebCore::Internals::unconstrainedScrollTo): + 2019-11-26 Manuel Rego Casasnovas [css-grid] Avoid serializing [] in grid-template-* specified values diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index e0ef6a41ecf01a6f92e560396061afefbcaa0812..c566e787416e526c115eb7c7cc9182624da2dbab 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,56 @@ +2019-11-28 Cathie Chen + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + + Reviewed by NOBODY (OOPS!). + + Add CSSOM smooth scrolling as an experimental feature. + + * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp: Deal with requestedScrollPositionWithAnimation encode and decode. + (ArgumentCoder::encode): + (ArgumentCoder::decode): + (WebKit::dump): + * Shared/WebPreferences.yaml: + * UIProcess/API/Cocoa/WKWebView.mm: + (pointsEqualInRoundToDevicePixel): Help function to check if two float points is not equal but it's same in device pixel. + (-[WKWebView _scrollToContentScrollPosition:scrollOrigin:animated:]): Add animated to start a animated scroll. + (-[WKWebView scrollViewDidEndScrollingAnimation:]): Send end sroll message to Web side. + * UIProcess/API/Cocoa/WKWebViewInternal.h: + * UIProcess/PageClient.h: + (WebKit::PageClient::requestScrollWithAnimation): Provide interface for animated scroll. + * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm: + (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): Add animated flag. + * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: + (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll): Sync the scroll position to Web side. + (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll): Add animated scroll info to m_requestedScrollInfo. + (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeIsScrollAnimationInProgressDidChange): Sync scrollAnimationInProgress to Web side. + (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeRootNodeIsScrollAnimationInProgressDidChange): Ditto. For root node. + * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h: + * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp: + (WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll): Add animated info. + (WebKit::RemoteScrollingTree::scrollingTreeNodeRequestsScroll): Ditto. + (WebKit::RemoteScrollingTree::scrollingTreeNodeIsScrollAnimationInProgressDidChange): Ditto. + * UIProcess/RemoteLayerTree/RemoteScrollingTree.h: + * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h: + * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm: + (-[WKScrollingNodeScrollViewDelegate scrollViewDidEndScrollingAnimation:]): Send scoll end info to Web side. + (WebKit::ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren): If scrollPosition of Web side isn't equal to UI side, + the scroll position should be sync, even there's no scrolling in UI side. + (WebKit::ScrollingTreeScrollingNodeDelegateIOS::repositionScrollingLayers): Calling the animated scroll interface. + (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidEndScrollingAnimation): Sync scroll end info to web side. + * UIProcess/WebPageProxy.cpp: + (WebKit::WebPageProxy::requestScroll): To call different functions for smooth and instant scroll. + * UIProcess/WebPageProxy.h: + * UIProcess/ios/PageClientImplIOS.h: + * UIProcess/ios/PageClientImplIOS.mm: + (WebKit::PageClientImpl::requestScroll): + (WebKit::PageClientImpl::requestScrollWithAnimation): + * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h: + * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in: + * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm: + (WebKit::RemoteScrollingCoordinator::scrollAnimationInProgressChangedForNode): + 2019-11-26 Carlos Garcia Campos Unreviewed. Update OptionsGTK.cmake and NEWS for 2.27.3 release diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog index 6c054b25b51128ec434e04e5516de936440adce9..880f8581f7eb817c2dfaefda6ef9382dd3744a7b 100644 --- a/Source/WebKitLegacy/mac/ChangeLog +++ b/Source/WebKitLegacy/mac/ChangeLog @@ -1,3 +1,20 @@ +2018-11-07 Frederic Wang + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + + Reviewed by NOBODY (OOPS!). + + * WebView/WebPreferenceKeysPrivate.h: Handle CSSOMViewSmoothScrolling by. + * WebView/WebPreferences.mm: + ([WebPreferences initialize]): Disable CSSOMViewSmoothScrolling by default. + (-[WebPreferences CSSOMViewSmoothScrollingEnabled]): Getter. + (-[WebPreferences setCSSOMViewSmoothScrollingEnabled:]): Setter. + * WebView/WebPreferencesPrivate.h: + * WebView/WebView.mm: + (-[WebView _preferencesChanged:]): + + 2019-11-21 Daniel Bates Remove unneeded code that annotated DOMHTMLElement as conforming to UITextInputTraits protocol diff --git a/Source/WebKitLegacy/win/ChangeLog b/Source/WebKitLegacy/win/ChangeLog index e7a0b3877cba59bed015e3f70681780540b33cd2..3db746ee76ad4e4c388a774722a0d2dc852118a8 100644 --- a/Source/WebKitLegacy/win/ChangeLog +++ b/Source/WebKitLegacy/win/ChangeLog @@ -1,3 +1,20 @@ +2018-11-07 Frederic Wang + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + + Reviewed by NOBODY (OOPS!). + + * Interfaces/IWebPreferencesPrivate.idl: Handle smooth scrolling option. + * WebPreferenceKeysPrivate.h: Ditto. + * WebPreferences.cpp: Ditto. + (WebPreferences::initializeDefaultSettings): + (WebPreferences::CSSOMViewSmoothScrollingEnabled): + (WebPreferences::setCSSOMViewSmoothScrollingEnabled): + * WebPreferences.h: Ditto. + * WebView.cpp: Ditto. + (WebView::notifyPreferencesChanged): + 2019-10-31 Ryosuke Niwa Windows build fix attempt after r251798. diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index 7967c74e3afaa33e43285fc8f5eb014df870a110..a8abb89a35cbe867f0d7b2d524fcbc800abd4f7f 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -958,8 +958,10 @@ set(WebCore_NON_SVG_IDL_FILES page/ResizeObserverCallback.idl page/ResizeObserverEntry.idl page/Screen.idl + page/ScrollBehavior.idl page/ScrollIntoViewOptions.idl page/ScrollLogicalPosition.idl + page/ScrollOptions.idl page/ScrollToOptions.idl page/ShareData.idl page/UndoItem.idl diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make index fd72366285bebaada3670baa204cef442044b4a4..817a58325d54878a2a402fea37ddf81bd13fc17e 100644 --- a/Source/WebCore/DerivedSources.make +++ b/Source/WebCore/DerivedSources.make @@ -912,8 +912,10 @@ JS_BINDING_IDLS = \ $(WebCore)/page/ResizeObserverCallback.idl \ $(WebCore)/page/ResizeObserverEntry.idl \ $(WebCore)/page/Screen.idl \ + $(WebCore)/page/ScrollBehavior.idl \ $(WebCore)/page/ScrollIntoViewOptions.idl \ $(WebCore)/page/ScrollLogicalPosition.idl \ + $(WebCore)/page/ScrollOptions.idl \ $(WebCore)/page/ScrollToOptions.idl \ $(WebCore)/page/ShareData.idl \ $(WebCore)/page/UndoItem.idl \ diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake index efc275f6da8c2c1056bf00d59cf5a5f9b9f5ef91..785994025f3cb7129586a0c013c39583b1e94968 100644 --- a/Source/WebCore/Headers.cmake +++ b/Source/WebCore/Headers.cmake @@ -818,8 +818,10 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS page/RemoteFrame.h page/RenderingUpdateScheduler.h page/RuntimeEnabledFeatures.h + page/ScrollBehavior.h page/ScrollIntoViewOptions.h page/ScrollLogicalPosition.h + page/ScrollOptions.h page/ScrollToOptions.h page/SecurityOrigin.h page/SecurityOriginData.h diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt index 6a0d46acf5bf019caa8a3469cf145f5febeda46a..cdcc28c6d7c3a9111401cabbe7babba82db367d7 100644 --- a/Source/WebCore/Sources.txt +++ b/Source/WebCore/Sources.txt @@ -1641,6 +1641,7 @@ page/ResourceUsageOverlay.cpp page/ResourceUsageThread.cpp page/RuntimeEnabledFeatures.cpp page/Screen.cpp +page/ScrollBehavior.cpp page/SecurityOrigin.cpp page/SecurityOriginData.cpp page/SecurityPolicy.cpp @@ -1746,6 +1747,7 @@ platform/RemoteCommandListener.cpp platform/RuntimeApplicationChecks.cpp platform/SSLKeyGenerator.cpp platform/ScrollAnimator.cpp +platform/ScrollAnimationSmooth.cpp platform/ScrollView.cpp platform/ScrollableArea.cpp platform/Scrollbar.cpp @@ -3369,8 +3371,10 @@ JSSVGZoomAndPan.cpp JSSVGZoomEvent.cpp JSScreen.cpp JSScriptProcessorNode.cpp +JSScrollBehavior.cpp JSScrollIntoViewOptions.cpp JSScrollLogicalPosition.cpp +JSScrollOptions.cpp JSScrollToOptions.cpp JSSecurityPolicyViolationEvent.cpp JSServiceWorker.cpp diff --git a/Source/WebCore/SourcesGTK.txt b/Source/WebCore/SourcesGTK.txt index c2c2709b879a83869289fe2871357cde626a1aa4..54b536ed9c0bf0cdf5eeaac677e9bf61c37edaa1 100644 --- a/Source/WebCore/SourcesGTK.txt +++ b/Source/WebCore/SourcesGTK.txt @@ -63,7 +63,6 @@ page/scrolling/nicosia/ScrollingTreeStickyNode.cpp page/scrolling/generic/ScrollingThreadGeneric.cpp platform/ScrollAnimationKinetic.cpp -platform/ScrollAnimationSmooth.cpp platform/UserAgentQuirks.cpp platform/generic/ScrollAnimatorGeneric.cpp diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj index 7e010c316b943f5c4d95ceec92a0784d39ebb3f0..6ec2e5e38c9d354a4827050341112909ceff661b 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -2389,6 +2389,8 @@ 83407FC11E8D9C1700E048D3 /* VisibilityChangeClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83407FC01E8D9C1200E048D3 /* VisibilityChangeClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 834476EF1DA5BC5E002B5EB0 /* JSScrollLogicalPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFD8D4 /* JSScrollLogicalPosition.h */; }; 834476EF1DA5BC5E002B5EC1 /* JSScrollIntoViewOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.h */; }; + 834476EF1DA5BC5E002B6EB0 /* JSScrollBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFE8D4 /* JSScrollBehavior.h */; }; + 834476EF1DA5BC5E002B6EC1 /* JSScrollOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFE8E5 /* JSScrollOptions.h */; }; 834476EF1DA5BC5E002B6ED2 /* JSScrollToOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */; }; 8348BFAC1B85729800912F36 /* ClassCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8348BFAA1B85729500912F36 /* ClassCollection.h */; }; 834DFAD01F7DAE5D00C2725B /* SharedStringHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 834DFACC1F7DAE5600C2725B /* SharedStringHash.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -2443,6 +2445,8 @@ 83C45B8E1DC2B68A008871BA /* ValidationBubble.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C45B8D1DC2B67C008871BA /* ValidationBubble.h */; settings = {ATTRIBUTES = (Private, ); }; }; 83C5795D1DA5C301006F9C86 /* ScrollLogicalPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 8350C3E71DA59B6200355424 /* ScrollLogicalPosition.h */; settings = {ATTRIBUTES = (Private, ); }; }; 83C5795D1DA5C301006F9C97 /* ScrollIntoViewOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8350C3E71DA59B6200355435 /* ScrollIntoViewOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 83C5795D1DA5C301006FAC86 /* ScrollBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 8350C3E71DA59B6200356424 /* ScrollBehavior.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 83C5795D1DA5C301006FAC97 /* ScrollOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8350C3E71DA59B6200356435 /* ScrollOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8350C3E71DA59B6200356446 /* ScrollToOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 83D35AEC1C7187FA00F70D5A /* XMLHttpRequestEventTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D35AEA1C7187ED00F70D5A /* XMLHttpRequestEventTarget.h */; }; 83D35AF21C718D9000F70D5A /* JSXMLHttpRequestEventTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D35AF01C718D8400F70D5A /* JSXMLHttpRequestEventTarget.h */; }; @@ -10132,9 +10136,14 @@ 834DFACE1F7DAE5700C2725B /* SharedStringHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedStringHash.cpp; sourceTree = ""; }; 8350C3E71DA59B6200355424 /* ScrollLogicalPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollLogicalPosition.h; sourceTree = ""; }; 8350C3E71DA59B6200355435 /* ScrollIntoViewOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollIntoViewOptions.h; sourceTree = ""; }; + 8350C3E71DA59B6200356424 /* ScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBehavior.h; sourceTree = ""; }; + 8350C3E71DA59B6200356434 /* ScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBehavior.cpp; sourceTree = ""; }; + 8350C3E71DA59B6200356435 /* ScrollOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollOptions.h; sourceTree = ""; }; 8350C3E71DA59B6200356446 /* ScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollToOptions.h; sourceTree = ""; }; 8350C3E81DA59B6200355424 /* ScrollLogicalPosition.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollLogicalPosition.idl; sourceTree = ""; }; 8350C3E81DA59B6200355435 /* ScrollIntoViewOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollIntoViewOptions.idl; sourceTree = ""; }; + 8350C3E81DA59B6200356424 /* ScrollBehavior.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollBehavior.idl; sourceTree = ""; }; + 8350C3E81DA59B6200356435 /* ScrollOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollOptions.idl; sourceTree = ""; }; 8350C3E81DA59B6200356446 /* ScrollToOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollToOptions.idl; sourceTree = ""; }; 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = ""; }; 835657C61ECAB0E800CDE72D /* JSDOMMatrixInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMatrixInit.cpp; sourceTree = ""; }; @@ -10256,9 +10265,13 @@ 83E959E11B8BC22B004D9385 /* NativeNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeNodeFilter.h; sourceTree = ""; }; 83E9B3001DA5A51E00FFD8D4 /* JSScrollLogicalPosition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollLogicalPosition.cpp; sourceTree = ""; }; 83E9B3001DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollIntoViewOptions.cpp; sourceTree = ""; }; + 83E9B3001DA5A51E00FFE8D4 /* JSScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollBehavior.cpp; sourceTree = ""; }; + 83E9B3001DA5A51E00FFE8E5 /* JSScrollOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollOptions.cpp; sourceTree = ""; }; 83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollToOptions.cpp; sourceTree = ""; }; 83E9B3011DA5A51E00FFD8D4 /* JSScrollLogicalPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollLogicalPosition.h; sourceTree = ""; }; 83E9B3011DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollIntoViewOptions.h; sourceTree = ""; }; + 83E9B3011DA5A51E00FFE8D4 /* JSScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollBehavior.h; sourceTree = ""; }; + 83E9B3011DA5A51E00FFE8E5 /* JSScrollOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollOptions.h; sourceTree = ""; }; 83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollToOptions.h; sourceTree = ""; }; 83EE598B1F50958B003E8B30 /* JSErrorCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorCallback.h; sourceTree = ""; }; 83EE598C1F50958B003E8B30 /* JSErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorCallback.cpp; sourceTree = ""; }; @@ -20697,10 +20710,15 @@ BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */, BCEC01BB0C274DAC009F4EC9 /* Screen.h */, BCEC01BC0C274DAC009F4EC9 /* Screen.idl */, + 8350C3E71DA59B6200356434 /* ScrollBehavior.cpp */, + 8350C3E71DA59B6200356424 /* ScrollBehavior.h */, + 8350C3E81DA59B6200356424 /* ScrollBehavior.idl */, 8350C3E71DA59B6200355435 /* ScrollIntoViewOptions.h */, 8350C3E81DA59B6200355435 /* ScrollIntoViewOptions.idl */, 8350C3E71DA59B6200355424 /* ScrollLogicalPosition.h */, 8350C3E81DA59B6200355424 /* ScrollLogicalPosition.idl */, + 8350C3E71DA59B6200356435 /* ScrollOptions.h */, + 8350C3E81DA59B6200356435 /* ScrollOptions.idl */, 8350C3E71DA59B6200356446 /* ScrollToOptions.h */, 8350C3E81DA59B6200356446 /* ScrollToOptions.idl */, BCD0E0F70E972C3500265DEA /* SecurityOrigin.cpp */, @@ -25484,10 +25502,14 @@ 58B2FA022232D60A00938D63 /* JSResizeObserverEntry.h */, BCEC01C00C274DDD009F4EC9 /* JSScreen.cpp */, BCEC01C10C274DDD009F4EC9 /* JSScreen.h */, + 83E9B3001DA5A51E00FFE8D4 /* JSScrollBehavior.cpp */, + 83E9B3011DA5A51E00FFE8D4 /* JSScrollBehavior.h */, 83E9B3001DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.cpp */, 83E9B3011DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.h */, 83E9B3001DA5A51E00FFD8D4 /* JSScrollLogicalPosition.cpp */, 83E9B3011DA5A51E00FFD8D4 /* JSScrollLogicalPosition.h */, + 83E9B3001DA5A51E00FFE8E5 /* JSScrollOptions.cpp */, + 83E9B3011DA5A51E00FFE8E5 /* JSScrollOptions.h */, 83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */, 83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */, 7C73FB0F191EF6F4007DE061 /* JSUserMessageHandler.cpp */, @@ -30818,8 +30840,10 @@ 5E2C436C1BCF071E0001E2BC /* JSRTCTrackEvent.h in Headers */, BCEC01C30C274DDD009F4EC9 /* JSScreen.h in Headers */, FDA15ECE12B03F61003A583A /* JSScriptProcessorNode.h in Headers */, + 834476EF1DA5BC5E002B6EB0 /* JSScrollBehavior.h in Headers */, 834476EF1DA5BC5E002B5EC1 /* JSScrollIntoViewOptions.h in Headers */, 834476EF1DA5BC5E002B5EB0 /* JSScrollLogicalPosition.h in Headers */, + 834476EF1DA5BC5E002B6EC1 /* JSScrollOptions.h in Headers */, 834476EF1DA5BC5E002B6ED2 /* JSScrollToOptions.h in Headers */, CED06AD11C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.h in Headers */, 5182C2561F3143CD0059BA7C /* JSServiceWorker.h in Headers */, @@ -32016,6 +32040,7 @@ 44C991860F3D1EBE00586670 /* ScrollbarThemeIOS.h in Headers */, BC8B853E0E7C7F1100AB6984 /* ScrollbarThemeMac.h in Headers */, 0FE71406142170B800DB33BA /* ScrollbarThemeMock.h in Headers */, + 83C5795D1DA5C301006FAC86 /* ScrollBehavior.h in Headers */, 1AA84F05143BA7BD0051D153 /* ScrollController.h in Headers */, 0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */, 1AF62EE814DA22A70041556C /* ScrollingCoordinator.h in Headers */, @@ -32052,6 +32077,7 @@ 83C5795D1DA5C301006F9C97 /* ScrollIntoViewOptions.h in Headers */, 7AAFE8D019CB8672000F56D8 /* ScrollLatchingState.h in Headers */, 83C5795D1DA5C301006F9C86 /* ScrollLogicalPosition.h in Headers */, + 83C5795D1DA5C301006FAC97 /* ScrollOptions.h in Headers */, F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */, F46729281E0DE68500ACC3D8 /* ScrollSnapOffsetsInfo.h in Headers */, 83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */, diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp index 73596ee9ff70ae2e5f98d4fa80cafaa3d8f09b37..af4d6ff3a1a1ca90cee4b918217b9d3ec6cee5f2 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -3393,6 +3393,10 @@ RefPtr ComputedStyleExtractor::valueForPropertyInStyle(const RenderSty return cssValuePool.createIdentifierValue(CSSValueAuto); return cssValuePool.createIdentifierValue(CSSValueTouch); #endif + case CSSPropertyScrollBehavior: + if (!style.useSmoothScrolling()) + return cssValuePool.createIdentifierValue(CSSValueAuto); + return cssValuePool.createIdentifierValue(CSSValueSmooth); case CSSPropertyPerspective: if (!style.hasPerspective()) return cssValuePool.createIdentifierValue(CSSValueNone); diff --git a/Source/WebCore/css/CSSProperties.json b/Source/WebCore/css/CSSProperties.json index 41578a94ed0dc5f5f4e84c805cb9ba0175ebdd5d..f982d3f5eba5585315b2d5154635a8b3094bbc55 100644 --- a/Source/WebCore/css/CSSProperties.json +++ b/Source/WebCore/css/CSSProperties.json @@ -3557,6 +3557,16 @@ "url": "https://www.w3.org/TR/SVG/shapes.html" } }, + "scroll-behavior": { + "values": [ + "auto", + "smooth" + ], + "specification": { + "category": "cssom-view", + "url": "https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior" + } + }, "shape-rendering": { "inherited": true, "values": [ @@ -6489,6 +6499,22 @@ "url": "https://www.w3.org/TR/css-ui-4/#propdef-user-select" } }, + "scroll-behavior": { + "values": [ + "auto", + "smooth" + ], + "codegen-properties": { + "converter": "SmoothScrolling", + "name-for-methods": "UseSmoothScrolling" + }, + "status": { + "status": "experimental" + }, + "specification": { + "url": "https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior" + } + }, "scroll-padding": { "codegen-properties": { "enable-if": "ENABLE_CSS_SCROLL_SNAP", diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in index 5d7f4081a03356abc507e200ecbb0a94abd2f757..b59734de8e0cb8bbec2a0f40fabbfbc3d77e86ad 100644 --- a/Source/WebCore/css/CSSValueKeywords.in +++ b/Source/WebCore/css/CSSValueKeywords.in @@ -1387,6 +1387,10 @@ pan-y pinch-zoom #endif +// scroll-behavior +// auto +smooth + // hanging-punctuation allow-end first diff --git a/Source/WebCore/css/parser/CSSParserContext.cpp b/Source/WebCore/css/parser/CSSParserContext.cpp index 7537188cb93d301c824a788d53953eaec034971b..71f9aa62c4cb218f353baa34467bdf4ff3fea5c7 100644 --- a/Source/WebCore/css/parser/CSSParserContext.cpp +++ b/Source/WebCore/css/parser/CSSParserContext.cpp @@ -75,6 +75,7 @@ CSSParserContext::CSSParserContext(const Document& document, const URL& sheetBas attachmentEnabled = RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled(); #endif deferredCSSParserEnabled = document.settings().deferredCSSParserEnabled(); + scrollBehaviorEnabled = document.settings().CSSOMViewSmoothScrollingEnabled(); useSystemAppearance = document.page() ? document.page()->useSystemAppearance() : false; } @@ -99,6 +100,7 @@ bool operator==(const CSSParserContext& a, const CSSParserContext& b) && a.attachmentEnabled == b.attachmentEnabled #endif && a.deferredCSSParserEnabled == b.deferredCSSParserEnabled + && a.scrollBehaviorEnabled == b.scrollBehaviorEnabled && a.hasDocumentSecurityOrigin == b.hasDocumentSecurityOrigin && a.useSystemAppearance == b.useSystemAppearance; } diff --git a/Source/WebCore/css/parser/CSSParserContext.h b/Source/WebCore/css/parser/CSSParserContext.h index 86525fd70c42e913daabb9d9b0a2a0f3d10cedfa..c74dc94c25bf291d3b30e2900ef0fce8ea38600c 100644 --- a/Source/WebCore/css/parser/CSSParserContext.h +++ b/Source/WebCore/css/parser/CSSParserContext.h @@ -65,6 +65,7 @@ public: bool attachmentEnabled { false }; #endif bool deferredCSSParserEnabled { false }; + bool scrollBehaviorEnabled { false }; // This is only needed to support getMatchedCSSRules. bool hasDocumentSecurityOrigin { false }; @@ -116,7 +117,8 @@ struct CSSParserContextHash { #if ENABLE(ATTACHMENT_ELEMENT) & key.attachmentEnabled << 11 #endif - & key.mode << 12; // Keep this last. + & key.scrollBehaviorEnabled << 12 + & key.mode << 13; // Keep this last. hash ^= WTF::intHash(bits); return hash; } diff --git a/Source/WebCore/css/parser/CSSParserFastPaths.cpp b/Source/WebCore/css/parser/CSSParserFastPaths.cpp index 31d12ab9ab619ff5ae016f7c663424cb0c9aa435..4212889ed0e3320c55fa9caae30f4b99ba56959a 100644 --- a/Source/WebCore/css/parser/CSSParserFastPaths.cpp +++ b/Source/WebCore/css/parser/CSSParserFastPaths.cpp @@ -636,10 +636,6 @@ bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId || valueID == CSSValueSticky || valueID == CSSValueWebkitSticky; case CSSPropertyResize: // none | both | horizontal | vertical | auto return valueID == CSSValueNone || valueID == CSSValueBoth || valueID == CSSValueHorizontal || valueID == CSSValueVertical || valueID == CSSValueAuto; - // FIXME-NEWPARSER: Investigate this property. - // case CSSPropertyScrollBehavior: // auto | smooth - // ASSERT(RuntimeEnabledFeatures::cssomSmoothScrollEnabled()); - // return valueID == CSSValueAuto || valueID == CSSValueSmooth; case CSSPropertyShapeRendering: return valueID == CSSValueAuto || valueID == CSSValueOptimizeSpeed || valueID == CSSValueCrispedges || valueID == CSSValueGeometricPrecision; case CSSPropertyStrokeLinejoin: @@ -939,7 +935,6 @@ bool CSSParserFastPaths::isKeywordPropertyID(CSSPropertyID propertyId) // case CSSPropertyFontKerning: // case CSSPropertyHyphens: // case CSSPropertyOverflowAnchor: - // case CSSPropertyScrollBehavior: // case CSSPropertyScrollSnapType: // case CSSPropertyTextAlignLast: // case CSSPropertyTextCombineUpright: diff --git a/Source/WebCore/css/parser/CSSPropertyParser.cpp b/Source/WebCore/css/parser/CSSPropertyParser.cpp index e7a2b44ff066d91f961c915e1f9015cd329c6ec2..24a662fdcc51996d1a11a57929c3e4745859785b 100644 --- a/Source/WebCore/css/parser/CSSPropertyParser.cpp +++ b/Source/WebCore/css/parser/CSSPropertyParser.cpp @@ -2321,6 +2321,14 @@ static RefPtr consumeScrollSnapType(CSSParserTokenRange& range) #endif +static RefPtr consumeScrollBehavior(CSSParserTokenRange& range) +{ + auto valueID = range.peek().id(); + if (valueID != CSSValueAuto && valueID != CSSValueSmooth) + return nullptr; + return consumeIdent(range); +} + static RefPtr consumeBorderRadiusCorner(CSSParserTokenRange& range, CSSParserMode cssParserMode) { RefPtr parsedValue1 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); @@ -3920,6 +3928,10 @@ RefPtr CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSS case CSSPropertyScrollSnapType: return consumeScrollSnapType(m_range); #endif + case CSSPropertyScrollBehavior: + if (!m_context.scrollBehaviorEnabled) + return nullptr; + return consumeScrollBehavior(m_range); case CSSPropertyClip: return consumeClip(m_range, m_context.mode); #if ENABLE(POINTER_EVENTS) diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp index c9463b1fd7cf63f0154d6223c0b03341ccb6ecc4..bc58f4d617b2dbc58c88040d12ee97388c05234b 100644 --- a/Source/WebCore/dom/Element.cpp +++ b/Source/WebCore/dom/Element.cpp @@ -832,7 +832,6 @@ void Element::scrollIntoView(Optional>&& ar bool insideFixed; LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed); - // FIXME(webkit.org/b/188043): Support ScrollBehavior. ScrollIntoViewOptions options; if (arg) { auto value = arg.value(); @@ -851,7 +850,8 @@ void Element::scrollIntoView(Optional>&& ar SelectionRevealMode::Reveal, isHorizontal ? alignX : alignY, isHorizontal ? alignY : alignX, - ShouldAllowCrossOriginScrolling::No + ShouldAllowCrossOriginScrolling::No, + options.behavior.valueOr(ScrollBehavior::Auto) }; renderer()->scrollRectToVisible(absoluteBounds, insideFixed, visibleOptions); } @@ -912,7 +912,7 @@ void Element::scrollBy(const ScrollToOptions& options) void Element::scrollBy(double x, double y) { - scrollBy({ x, y }); + scrollBy(ScrollToOptions(x, y)); } void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) @@ -948,13 +948,17 @@ void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) adjustForAbsoluteZoom(renderer->scrollLeft(), *renderer), adjustForAbsoluteZoom(renderer->scrollTop(), *renderer) ); - renderer->setScrollLeft(clampToInteger(scrollToOptions.left.value() * renderer->style().effectiveZoom()), ScrollType::Programmatic, clamping); - renderer->setScrollTop(clampToInteger(scrollToOptions.top.value() * renderer->style().effectiveZoom()), ScrollType::Programmatic, clamping); + IntPoint scrollPosition( + clampToInteger(scrollToOptions.left.value() * renderer->style().effectiveZoom()), + clampToInteger(scrollToOptions.top.value() * renderer->style().effectiveZoom()) + ); + bool animated = useSmoothScrolling(scrollToOptions.behavior.valueOr(ScrollBehavior::Auto), *this); + renderer->setScrollPosition(scrollPosition, ScrollType::Programmatic, animated, clamping); } void Element::scrollTo(double x, double y) { - scrollTo({ x, y }); + scrollTo(ScrollToOptions(x, y)); } void Element::scrollByUnits(int units, ScrollGranularity granularity) @@ -1288,13 +1292,19 @@ void Element::setScrollLeft(int newLeft) document().updateLayoutIgnorePendingStylesheets(); if (document().scrollingElement() == this) { - if (auto* frame = documentFrameWithNonNullView()) - frame->view()->setScrollPosition(IntPoint(static_cast(newLeft * frame->pageZoomFactor() * frame->frameScaleFactor()), frame->view()->scrollY())); + if (auto* frame = documentFrameWithNonNullView()) { + // FIXME: Should we use document()->scrollingElement()? + // See https://github.com/w3c/csswg-drafts/issues/2977 + bool animated = document().documentElement() && useSmoothScrolling(ScrollBehavior::Auto, *document().documentElement()); + frame->view()->setScrollPosition(IntPoint(static_cast(newLeft * frame->pageZoomFactor() * frame->frameScaleFactor()), frame->view()->scrollY()), animated); + } return; } if (auto* renderer = renderBox()) { - renderer->setScrollLeft(static_cast(newLeft * renderer->style().effectiveZoom()), ScrollType::Programmatic); + int effectiveLeft = clampToInteger(newLeft * renderer->style().effectiveZoom()); + bool animated = useSmoothScrolling(ScrollBehavior::Auto, *this); + renderer->setScrollLeft(effectiveLeft, ScrollType::Programmatic, animated, ScrollClamping::Clamped); if (auto* scrollableArea = renderer->layer()) scrollableArea->setScrollShouldClearLatchedState(true); } @@ -1305,13 +1315,19 @@ void Element::setScrollTop(int newTop) document().updateLayoutIgnorePendingStylesheets(); if (document().scrollingElement() == this) { - if (auto* frame = documentFrameWithNonNullView()) - frame->view()->setScrollPosition(IntPoint(frame->view()->scrollX(), static_cast(newTop * frame->pageZoomFactor() * frame->frameScaleFactor()))); + if (auto* frame = documentFrameWithNonNullView()) { + // FIXME: Should we use document()->scrollingElement()? + // See https://github.com/w3c/csswg-drafts/issues/2977 + bool animated = document().documentElement() && useSmoothScrolling(ScrollBehavior::Auto, *document().documentElement()); + frame->view()->setScrollPosition(IntPoint(frame->view()->scrollX(), static_cast(newTop * frame->pageZoomFactor() * frame->frameScaleFactor())), animated); + } return; } if (auto* renderer = renderBox()) { - renderer->setScrollTop(static_cast(newTop * renderer->style().effectiveZoom()), ScrollType::Programmatic); + int effectiveTop = clampToInteger(newTop * renderer->style().effectiveZoom()); + bool animated = useSmoothScrolling(ScrollBehavior::Auto, *this); + renderer->setScrollTop(effectiveTop, ScrollType::Programmatic, animated, ScrollClamping::Clamped); if (auto* scrollableArea = renderer->layer()) scrollableArea->setScrollShouldClearLatchedState(true); } diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp index 0568b069dcd3ba51ca71e8178a2bdef5e7ff445b..41f5b649ea5add167294e05c5044a1317f72a6c6 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -1595,7 +1595,7 @@ double DOMWindow::devicePixelRatio() const void DOMWindow::scrollBy(double x, double y) const { - scrollBy({ x, y }); + scrollBy(ScrollToOptions(x, y)); } void DOMWindow::scrollBy(const ScrollToOptions& options) const @@ -1617,10 +1617,10 @@ void DOMWindow::scrollBy(const ScrollToOptions& options) const void DOMWindow::scrollTo(double x, double y, ScrollClamping clamping) const { - scrollTo({ x, y }, clamping); + scrollTo(ScrollToOptions(x, y), clamping); } -void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping) const +void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) const { if (!isCurrentlyDisplayedInFrame()) return; @@ -1633,12 +1633,20 @@ void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping) const view->contentsScrollPosition().x(), view->contentsScrollPosition().y() ); - if (!scrollToOptions.left.value() && !scrollToOptions.top.value() && view->contentsScrollPosition() == IntPoint(0, 0)) + if (!view->isScrollInProgress() && !scrollToOptions.left.value() && !scrollToOptions.top.value() && view->contentsScrollPosition() == IntPoint(0, 0)) return; document()->updateLayoutIgnorePendingStylesheets(); IntPoint layoutPos(view->mapFromCSSToLayoutUnits(scrollToOptions.left.value()), view->mapFromCSSToLayoutUnits(scrollToOptions.top.value())); + + // FIXME: Should we use document()->scrollingElement()? + // See https://github.com/w3c/csswg-drafts/issues/2977 + if (document()->documentElement() && useSmoothScrolling(scrollToOptions.behavior.valueOr(ScrollBehavior::Auto), *document()->documentElement())) { + view->scrollToOffsetWithAnimation(layoutPos, ScrollType::Programmatic, clamping); + return; + } + view->setContentsScrollPosition(layoutPos); } diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index 0f70ac78f60b72e3a811c1ca9d4e8d1c4038ed18..e886bb18d06f986cbeb6886c32fbafde3e22ad7a 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -2267,7 +2267,7 @@ void FrameView::scrollElementToRect(const Element& element, const IntRect& rect) setScrollPosition(IntPoint(bounds.x() - centeringOffsetX - rect.x(), bounds.y() - centeringOffsetY - rect.y())); } -void FrameView::setScrollPosition(const ScrollPosition& scrollPosition) +void FrameView::setScrollPosition(const ScrollPosition& scrollPosition, bool animated) { LOG_WITH_STREAM(Scrolling, stream << "FrameView::setScrollPosition " << scrollPosition << " , clearing anchor"); @@ -2280,7 +2280,10 @@ void FrameView::setScrollPosition(const ScrollPosition& scrollPosition) Page* page = frame().page(); if (page && page->isMonitoringWheelEvents()) scrollAnimator().setWheelEventTestMonitor(page->wheelEventTestMonitor()); - ScrollView::setScrollPosition(scrollPosition); + if (animated) + scrollToOffsetWithAnimation(scrollOffsetFromPosition(scrollPosition), ScrollType::Programmatic); + else + ScrollView::setScrollPosition(scrollPosition); setCurrentScrollType(oldScrollType); } @@ -3648,6 +3651,26 @@ void FrameView::scrollTo(const ScrollPosition& newPosition) didChangeScrollOffset(); } +void FrameView::scrollToOffsetWithAnimation(const ScrollOffset& offset, ScrollType scrollType, ScrollClamping) +{ + auto previousScrollType = currentScrollType(); + setCurrentScrollType(scrollType); + +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + setCurrentScrollBehaviorType(ScrollBehaviorType::Smooth); + if (requestScrollPositionUpdate(scrollPositionFromOffset(offset))) { + setCurrentScrollType(previousScrollType); + return; + } +#endif + + if (isWebScrollAnimationInProgress()) + scrollAnimator().cancelAnimations(); + if (offset != this->scrollOffset()) + ScrollableArea::scrollToOffsetWithAnimation(offset); + setCurrentScrollType(previousScrollType); +} + float FrameView::adjustScrollStepForFixedContent(float step, ScrollbarOrientation orientation, ScrollGranularity granularity) { if (granularity != ScrollByPage || orientation == HorizontalScrollbar) diff --git a/Source/WebCore/page/FrameView.h b/Source/WebCore/page/FrameView.h index ded7a5b5ca5ec447787fd634610b06f386eac41b..b143519c9cc8781cefa3b3cd924f596c076c6c9f 100644 --- a/Source/WebCore/page/FrameView.h +++ b/Source/WebCore/page/FrameView.h @@ -222,7 +222,7 @@ public: #if USE(COORDINATED_GRAPHICS) WEBCORE_EXPORT void setFixedVisibleContentRect(const IntRect&) final; #endif - WEBCORE_EXPORT void setScrollPosition(const ScrollPosition&) final; + WEBCORE_EXPORT void setScrollPosition(const ScrollPosition&, bool animated = false) final; void restoreScrollbar(); void scheduleScrollToFocusedElement(SelectionRevealMode); void scrollToFocusedElementImmediatelyIfNeeded(); @@ -658,6 +658,8 @@ public: void renderLayerDidScroll(const RenderLayer&); + WEBCORE_EXPORT void scrollToOffsetWithAnimation(const ScrollOffset&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped); + protected: bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) final; void scrollContentsSlowPath(const IntRect& updateRect) final; diff --git a/Source/WebCore/page/ScrollBehavior.cpp b/Source/WebCore/page/ScrollBehavior.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ed29cb42bf38bdb90e8f8009685c1d9b5080243 --- /dev/null +++ b/Source/WebCore/page/ScrollBehavior.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2019 Igalia S.L. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScrollBehavior.h" + +#include "Element.h" +#include "RenderElement.h" +#include "RenderStyle.h" +#include "Settings.h" + +namespace WebCore { + +bool useSmoothScrolling(ScrollBehavior behavior, Element& associatedElement) +{ + if (!associatedElement.document().settings().CSSOMViewSmoothScrollingEnabled() || !associatedElement.renderer()) + return false; + + // https://drafts.csswg.org/cssom-view/#scrolling + switch (behavior) { + case ScrollBehavior::Auto: + return associatedElement.renderer()->style().useSmoothScrolling(); + case ScrollBehavior::Instant: + return false; + case ScrollBehavior::Smooth: + return true; + } + ASSERT_NOT_REACHED(); + return false; +} + +} // namespace WebCore diff --git a/Source/WebCore/page/ScrollBehavior.h b/Source/WebCore/page/ScrollBehavior.h new file mode 100644 index 0000000000000000000000000000000000000000..1baef881e8088524d08993b09ccb3227c7b0fe51 --- /dev/null +++ b/Source/WebCore/page/ScrollBehavior.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Igalia S.L. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +namespace WebCore { + +class Element; + +enum class ScrollBehavior : uint8_t { + Auto = 0, + Instant, + Smooth +}; + +bool useSmoothScrolling(ScrollBehavior, Element& associatedElement); + +} // namespace WebCore diff --git a/Source/WebCore/page/ScrollBehavior.idl b/Source/WebCore/page/ScrollBehavior.idl new file mode 100644 index 0000000000000000000000000000000000000000..8971ae937aaf8e2952f7df260c7ef4f4e614df1f --- /dev/null +++ b/Source/WebCore/page/ScrollBehavior.idl @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2019 Igalia S.L. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +enum ScrollBehavior { "auto", "instant", "smooth" }; diff --git a/Source/WebCore/page/ScrollIntoViewOptions.h b/Source/WebCore/page/ScrollIntoViewOptions.h index 939cd73425ac7c3290c42d25d5e99d08aa14c00b..f275f2fbd1a3fc801ebc0ae86cda9199689f4505 100644 --- a/Source/WebCore/page/ScrollIntoViewOptions.h +++ b/Source/WebCore/page/ScrollIntoViewOptions.h @@ -20,12 +20,11 @@ #pragma once #include "ScrollLogicalPosition.h" +#include "ScrollOptions.h" namespace WebCore { -class Element; - -struct ScrollIntoViewOptions { +struct ScrollIntoViewOptions : ScrollOptions { Optional blockPosition { ScrollLogicalPosition::Start }; Optional inlinePosition { ScrollLogicalPosition::Nearest }; }; diff --git a/Source/WebCore/page/ScrollIntoViewOptions.idl b/Source/WebCore/page/ScrollIntoViewOptions.idl index cf9d1fd7678743398a72b9b7ca1effed9b1a2d90..1b24c686fc70a0c3d43deae89d209f248a79b4f6 100644 --- a/Source/WebCore/page/ScrollIntoViewOptions.idl +++ b/Source/WebCore/page/ScrollIntoViewOptions.idl @@ -17,8 +17,7 @@ * Boston, MA 02110-1301, USA. */ -// FIXME(webkit.org/b/188043): Support ScrollBehavior. -dictionary ScrollIntoViewOptions { +dictionary ScrollIntoViewOptions : ScrollOptions { [ImplementedAs=blockPosition] ScrollLogicalPosition block = "start"; [ImplementedAs=inlinePosition] ScrollLogicalPosition inline = "nearest"; }; diff --git a/Source/WebCore/page/ScrollOptions.h b/Source/WebCore/page/ScrollOptions.h new file mode 100644 index 0000000000000000000000000000000000000000..e1867c60150a55411cc0f1a7a049e2bc1dc13d97 --- /dev/null +++ b/Source/WebCore/page/ScrollOptions.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 Igalia S.L. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "ScrollBehavior.h" + +namespace WebCore { + +struct ScrollOptions { + Optional behavior { ScrollBehavior::Auto }; +}; + +} // namespace WebCore diff --git a/Source/WebCore/page/ScrollOptions.idl b/Source/WebCore/page/ScrollOptions.idl new file mode 100644 index 0000000000000000000000000000000000000000..329d6ff10863d6f754388e912f947a9b256bf208 --- /dev/null +++ b/Source/WebCore/page/ScrollOptions.idl @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2019 Igalia S.L. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +dictionary ScrollOptions { + ScrollBehavior behavior = "auto"; +}; diff --git a/Source/WebCore/page/ScrollToOptions.h b/Source/WebCore/page/ScrollToOptions.h index ce1cba1c7c010403bdb3e99446f656f604416d7f..f5774d44aef04a85eb147217e7faab872f243d8b 100644 --- a/Source/WebCore/page/ScrollToOptions.h +++ b/Source/WebCore/page/ScrollToOptions.h @@ -28,14 +28,21 @@ #pragma once +#include "ScrollOptions.h" #include #include namespace WebCore { -struct ScrollToOptions { +struct ScrollToOptions : ScrollOptions { Optional left; Optional top; + + ScrollToOptions() = default; + ScrollToOptions(double x, double y) + : left(x) + , top(y) + { } }; inline double normalizeNonFiniteValueOrFallBackTo(Optional value, double fallbackValue) @@ -47,7 +54,7 @@ inline double normalizeNonFiniteValueOrFallBackTo(Optional value, double // FIXME(https://webkit.org/b/88339): Consider using FloatPoint or DoublePoint for fallback and return values. inline ScrollToOptions normalizeNonFiniteCoordinatesOrFallBackTo(const ScrollToOptions& value, double x, double y) { - ScrollToOptions options; + ScrollToOptions options = value; options.left = normalizeNonFiniteValueOrFallBackTo(value.left, x); options.top = normalizeNonFiniteValueOrFallBackTo(value.top, y); return options; diff --git a/Source/WebCore/page/ScrollToOptions.idl b/Source/WebCore/page/ScrollToOptions.idl index 510bc071a681dcf0c5f8397e32fc7fed58dd16cf..2b9b554122aa7e92b8e1d4d523526c48556fac3d 100644 --- a/Source/WebCore/page/ScrollToOptions.idl +++ b/Source/WebCore/page/ScrollToOptions.idl @@ -26,8 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// FIXME(webkit.org/b/188043): Support ScrollBehavior. -dictionary ScrollToOptions { +dictionary ScrollToOptions : ScrollOptions { unrestricted double left; unrestricted double top; }; diff --git a/Source/WebCore/page/Settings.yaml b/Source/WebCore/page/Settings.yaml index a01d2f652ff33f1bed3926df2b989064bf65a34b..efa9a4b65775029e8e8dc849dec555ce6a5fc1fa 100644 --- a/Source/WebCore/page/Settings.yaml +++ b/Source/WebCore/page/Settings.yaml @@ -615,6 +615,9 @@ syntheticEditingCommandsEnabled: CSSOMViewScrollingAPIEnabled: initial: false +CSSOMViewSmoothScrollingEnabled: + initial: false + inputEventsEnabled: initial: true diff --git a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp index 429eee9a9653fdc4ff7e09883bc4a088fd1ccefe..11fa5a5988b19e0516bb05d2e0c5b622d9f8f321 100644 --- a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp +++ b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp @@ -248,7 +248,14 @@ bool AsyncScrollingCoordinator::requestScrollPositionUpdate(ScrollableArea& scro bool inBackForwardCache = frameView->frame().document()->backForwardCacheState() != Document::NotInBackForwardCache; bool inProgrammaticScroll = scrollableArea.currentScrollType() == ScrollType::Programmatic; - if (inProgrammaticScroll || inBackForwardCache) + bool animated = false; + +#if PLATFORM(IOS_FAMILY) + animated = scrollableArea.currentScrollBehaviorType() == ScrollBehaviorType::Smooth; +#endif + + // The scroll position of animated scrolling will be set from the UI side. So it shouldn't be set now. + if (!animated && (inProgrammaticScroll || inBackForwardCache)) updateScrollPositionAfterAsyncScroll(scrollingNodeID, scrollPosition, { }, ScrollType::Programmatic, ScrollingLayerPositionAction::Set); // If this frame view's document is being put into the back/forward cache, we don't want to update our @@ -260,7 +267,18 @@ bool AsyncScrollingCoordinator::requestScrollPositionUpdate(ScrollableArea& scro if (!stateNode) return false; - stateNode->setRequestedScrollPosition(scrollPosition, inProgrammaticScroll); +#if PLATFORM(IOS_FAMILY) + if (animated) + scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::InUINativeAnimation); + else + scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); +#else + // If web scroll animation is in progress, this is set by scroll animator, otherwise the animation should stop first. + if (!scrollableArea.isWebScrollAnimationInProgress()) + scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); +#endif + + stateNode->setRequestedScrollPosition(scrollPosition, inProgrammaticScroll, animated); return true; } @@ -291,6 +309,30 @@ void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(Scr m_updateNodeScrollPositionTimer.startOneShot(0_s); } +void AsyncScrollingCoordinator::setScrollAnimationInProgress(ScrollingNodeID nodeID, bool isScrollAnimationInProgress) +{ + ASSERT(isMainThread()); + + if (!m_page) + return; + + auto* frameView = frameViewForScrollingNode(nodeID); + if (!frameView) + return; + + if (nodeID == frameView->scrollingNodeID()) { + if (!isScrollAnimationInProgress) + frameView->setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); + return; + } + + // Overflow-scroll area. + if (auto* scrollableArea = frameView->scrollableAreaForScrollLayerID(nodeID)) { + if (!isScrollAnimationInProgress) + scrollableArea->setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); + } +} + void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired() { updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, ScrollType::User, m_scheduledScrollUpdate.updateLayerPositionAction); diff --git a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h index 9be69aafb1e285f8a55392895cde634bcc16f711..e804e0195b2d58d817d4c88818bee354fcc94b94 100644 --- a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h +++ b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h @@ -53,6 +53,8 @@ public: WEBCORE_EXPORT void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, const Optional& layoutViewportOrigin, ScrollingLayerPositionAction); + WEBCORE_EXPORT void setScrollAnimationInProgress(ScrollingNodeID, bool isScrollAnimationInProgress); + #if PLATFORM(COCOA) WEBCORE_EXPORT void setActiveScrollSnapIndices(ScrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex); void deferWheelEventTestCompletionForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const; diff --git a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp index 717bfc2a55cc18cb38cdb44edb0ef543587f2ae0..62868b47d1a9bfc70a311937c09e1d05176c3a45 100644 --- a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp +++ b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp @@ -56,6 +56,7 @@ ScrollingStateScrollingNode::ScrollingStateScrollingNode(const ScrollingStateScr #endif , m_scrollableAreaParameters(stateNode.scrollableAreaParameters()) , m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll()) + , m_requestedScrollPositionWithAnimation(stateNode.requestedScrollPositionWithAnimation()) , m_isMonitoringWheelEvents(stateNode.isMonitoringWheelEvents()) { if (hasChangedProperty(ScrollContainerLayer)) @@ -219,10 +220,11 @@ void ScrollingStateScrollingNode::setScrollableAreaParameters(const ScrollableAr setPropertyChanged(ScrollableAreaParams); } -void ScrollingStateScrollingNode::setRequestedScrollPosition(const FloatPoint& requestedScrollPosition, bool representsProgrammaticScroll) +void ScrollingStateScrollingNode::setRequestedScrollPosition(const FloatPoint& requestedScrollPosition, bool representsProgrammaticScroll, bool requestedWithAnimation) { m_requestedScrollPosition = requestedScrollPosition; m_requestedScrollPositionRepresentsProgrammaticScroll = representsProgrammaticScroll; + m_requestedScrollPositionWithAnimation = requestedWithAnimation; setPropertyChanged(RequestedScrollPosition); } @@ -314,6 +316,9 @@ void ScrollingStateScrollingNode::dumpProperties(TextStream& ts, ScrollingStateT if (m_requestedScrollPositionRepresentsProgrammaticScroll) ts.dumpProperty("requested scroll position represents programmatic scroll", m_requestedScrollPositionRepresentsProgrammaticScroll); + if (m_requestedScrollPositionWithAnimation) + ts.dumpProperty("requested scroll position with animation", m_requestedScrollPositionWithAnimation); + if (!m_parentRelativeScrollableRect.isEmpty()) ts.dumpProperty("parent relative scrollable rect", m_parentRelativeScrollableRect); diff --git a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h index 4967a6ce812f2ba3b2fbf0d912a0357178e8f171..ad56d29d03f6e16a5b6e3169b89dfda665670f77 100644 --- a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h +++ b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h @@ -111,7 +111,8 @@ public: const FloatPoint& requestedScrollPosition() const { return m_requestedScrollPosition; } bool requestedScrollPositionRepresentsProgrammaticScroll() const { return m_requestedScrollPositionRepresentsProgrammaticScroll; } - WEBCORE_EXPORT void setRequestedScrollPosition(const FloatPoint&, bool representsProgrammaticScroll); + bool requestedScrollPositionWithAnimation() const { return m_requestedScrollPositionWithAnimation; } + WEBCORE_EXPORT void setRequestedScrollPosition(const FloatPoint&, bool representsProgrammaticScroll, bool requestedWithAnimation = false); bool isMonitoringWheelEvents() const { return m_isMonitoringWheelEvents; } WEBCORE_EXPORT void setIsMonitoringWheelEvents(bool); @@ -171,6 +172,7 @@ private: ScrollableAreaParameters m_scrollableAreaParameters; bool m_requestedScrollPositionRepresentsProgrammaticScroll { false }; + bool m_requestedScrollPositionWithAnimation { false }; bool m_isMonitoringWheelEvents { false }; }; diff --git a/Source/WebCore/page/scrolling/ScrollingTree.h b/Source/WebCore/page/scrolling/ScrollingTree.h index 151ac29f8a53cdd387c93c475a5ded36cc6d1c4f..ae59f2d57f550f2d5c222c232b0af50bf3f5d27e 100644 --- a/Source/WebCore/page/scrolling/ScrollingTree.h +++ b/Source/WebCore/page/scrolling/ScrollingTree.h @@ -83,7 +83,10 @@ public: virtual void scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode&, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) = 0; // Called for requested scroll position updates. - virtual void scrollingTreeNodeRequestsScroll(ScrollingNodeID, const FloatPoint& /*scrollPosition*/, bool /*representsProgrammaticScroll*/) { } + virtual void scrollingTreeNodeRequestsScroll(ScrollingNodeID, const FloatPoint& /*scrollPosition*/, bool /*representsProgrammaticScroll*/, bool /*withAnimation*/) { } + + // Called for scroll animation status updates. + virtual void scrollingTreeNodeIsScrollAnimationInProgressDidChange(WebCore::ScrollingNodeID, bool /*isScrollAnimationInProgress*/) { } // Delegated scrolling/zooming has caused the viewport to change, so update viewport-constrained layers WEBCORE_EXPORT void mainFrameViewportChangedViaDelegatedScrolling(const FloatPoint& scrollPosition, const WebCore::FloatRect& layoutViewport, double scale); diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp index 73dca28ef1e3c2d55a953fc5e40676c371aed9e6..f25fbee3f51c795f15b6754b642833bb9239b0d9 100644 --- a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp +++ b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp @@ -108,7 +108,7 @@ void ScrollingTreeScrollingNode::commitStateAfterChildren(const ScrollingStateNo { const ScrollingStateScrollingNode& scrollingStateNode = downcast(stateNode); if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) - scrollingTree().scrollingTreeNodeRequestsScroll(scrollingNodeID(), scrollingStateNode.requestedScrollPosition(), scrollingStateNode.requestedScrollPositionRepresentsProgrammaticScroll()); + scrollingTree().scrollingTreeNodeRequestsScroll(scrollingNodeID(), scrollingStateNode.requestedScrollPosition(), scrollingStateNode.requestedScrollPositionRepresentsProgrammaticScroll(), scrollingStateNode.requestedScrollPositionWithAnimation()); m_isFirstCommit = false; } @@ -157,11 +157,20 @@ void ScrollingTreeScrollingNode::scrollBy(const FloatSize& delta, ScrollPosition scrollTo(currentScrollPosition() + delta, ScrollType::User, clamp); } -void ScrollingTreeScrollingNode::scrollTo(const FloatPoint& position, ScrollType scrollType, ScrollPositionClamp clamp) +void ScrollingTreeScrollingNode::scrollTo(const FloatPoint& position, ScrollType scrollType, ScrollPositionClamp clamp, bool needSyncScrollPosition) { - if (position == m_currentScrollPosition) + if (position == m_currentScrollPosition) { + // Sync the scroll position to web side. + if (requestScrollWithAnimation() && needSyncScrollPosition) + scrollingTree().scrollingTreeNodeDidScroll(*this, ScrollingLayerPositionAction::Sync); + scrollingTree().scrollingTreeNodeIsScrollAnimationInProgressDidChange(scrollingNodeID(), false); + setRequestScrollWithAnimation(false); return; + } + // If during an scroll animation, need to stop it before starting a new one. + if (scrollAnimationInProgress()) + setNeedsStopCurrentScrollAnimation(true); scrollingTree().setIsHandlingProgrammaticScroll(scrollType == ScrollType::Programmatic); m_currentScrollPosition = adjustedScrollPosition(position, clamp); @@ -171,6 +180,8 @@ void ScrollingTreeScrollingNode::scrollTo(const FloatPoint& position, ScrollType updateViewportForCurrentScrollPosition(); currentScrollPositionChanged(); + setNeedsStopCurrentScrollAnimation(false); + setRequestScrollWithAnimation(false); scrollingTree().setIsHandlingProgrammaticScroll(false); } @@ -179,8 +190,10 @@ void ScrollingTreeScrollingNode::currentScrollPositionChanged() repositionScrollingLayers(); repositionRelatedLayers(); - scrollingTree().notifyRelatedNodesAfterScrollPositionChange(*this); - scrollingTree().scrollingTreeNodeDidScroll(*this); + if (!requestScrollWithAnimation()) { + scrollingTree().notifyRelatedNodesAfterScrollPositionChange(*this); + scrollingTree().scrollingTreeNodeDidScroll(*this); + } } bool ScrollingTreeScrollingNode::scrollPositionAndLayoutViewportMatch(const FloatPoint& position, Optional) @@ -266,6 +279,35 @@ void ScrollingTreeScrollingNode::dumpProperties(TextStream& ts, ScrollingStateTr ts.dumpProperty("scrollable area parameters", m_scrollableAreaParameters); } +void ScrollingTreeScrollingNode::setRequestScrollWithAnimation(bool withAnimation) +{ + m_requestScrollWithAnimation = withAnimation; +} + +bool ScrollingTreeScrollingNode::requestScrollWithAnimation() const +{ + return m_requestScrollWithAnimation; +} + +void ScrollingTreeScrollingNode::setScrollAnimationInProgress(bool inProgress) +{ + m_scrollAnimationInProgress = inProgress; +} + +bool ScrollingTreeScrollingNode::scrollAnimationInProgress() const +{ + return m_scrollAnimationInProgress; +} + +void ScrollingTreeScrollingNode::setNeedsStopCurrentScrollAnimation(bool stop) +{ + m_needsStopCurrentScrollAnimation = stop; +} + +bool ScrollingTreeScrollingNode::needsStopCurrentScrollAnimation() const +{ + return m_needsStopCurrentScrollAnimation; +} } // namespace WebCore #endif // ENABLE(ASYNC_SCROLLING) diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h index 4cbf4d1af0dcf470134f4b7264f20db7b95ec9dd..8031b19068c3d8627998e59846245b9b33454255 100644 --- a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h +++ b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h @@ -60,7 +60,7 @@ public: FloatSize scrollDeltaSinceLastCommit() const { return m_currentScrollPosition - m_lastCommittedScrollPosition; } // These are imperative; they adjust the scrolling layers. - void scrollTo(const FloatPoint&, ScrollType = ScrollType::User, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges); + void scrollTo(const FloatPoint&, ScrollType = ScrollType::User, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges, bool needSnycScrollPosition = false); void scrollBy(const FloatSize&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges); void wasScrolledByDelegatedScrolling(const FloatPoint& position, Optional overrideLayoutViewport = { }, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync); @@ -91,6 +91,13 @@ public: const LayerRepresentation& scrollContainerLayer() const { return m_scrollContainerLayer; } const LayerRepresentation& scrolledContentsLayer() const { return m_scrolledContentsLayer; } + void setRequestScrollWithAnimation(bool); + bool requestScrollWithAnimation() const; + void setScrollAnimationInProgress(bool); + bool scrollAnimationInProgress() const; + void setNeedsStopCurrentScrollAnimation(bool); + bool needsStopCurrentScrollAnimation() const; + protected: ScrollingTreeScrollingNode(ScrollingTree&, ScrollingNodeType, ScrollingNodeID); @@ -147,6 +154,9 @@ private: #endif ScrollableAreaParameters m_scrollableAreaParameters; bool m_isFirstCommit { true }; + bool m_requestScrollWithAnimation { false }; + bool m_scrollAnimationInProgress { false }; + bool m_needsStopCurrentScrollAnimation { false }; LayerRepresentation m_scrollContainerLayer; LayerRepresentation m_scrolledContentsLayer; diff --git a/Source/WebCore/platform/ScrollAnimation.h b/Source/WebCore/platform/ScrollAnimation.h index b7c1d24eb49e5a55f691f06ce9e1d80b21bccad0..0bc42dae16fe9721dd3a95bea31ead71eda5a8fc 100644 --- a/Source/WebCore/platform/ScrollAnimation.h +++ b/Source/WebCore/platform/ScrollAnimation.h @@ -32,16 +32,19 @@ namespace WebCore { class FloatPoint; class ScrollableArea; +enum class ScrollClamping : uint8_t; class ScrollAnimation { WTF_MAKE_FAST_ALLOCATED; public: virtual ~ScrollAnimation() { }; virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float /* step */, float /* multiplier */) { return true; }; + virtual void scroll(const FloatPoint&) { }; virtual void stop() = 0; virtual void updateVisibleLengths() { }; virtual void setCurrentPosition(const FloatPoint&) { }; virtual void serviceAnimation() { }; + virtual bool isScrollInProgress() const { return false; } protected: ScrollAnimation(ScrollableArea& scrollableArea) diff --git a/Source/WebCore/platform/ScrollAnimationKinetic.cpp b/Source/WebCore/platform/ScrollAnimationKinetic.cpp index ac9f2f0f37f1e805860f036b42b0d027620c1de2..50fb6098409cfad3f3be942d233c628a5e4f320e 100644 --- a/Source/WebCore/platform/ScrollAnimationKinetic.cpp +++ b/Source/WebCore/platform/ScrollAnimationKinetic.cpp @@ -165,4 +165,9 @@ void ScrollAnimationKinetic::animationTimerFired() m_notifyPositionChangedFunction(FloatPoint(m_position)); } +bool ScrollAnimationKinetic::isScrollInProgress() const +{ + return m_animationTimer.isActive(); +} + } // namespace WebCore diff --git a/Source/WebCore/platform/ScrollAnimationKinetic.h b/Source/WebCore/platform/ScrollAnimationKinetic.h index cfd33ce5b4958d42a07548416e136c4095255400..291fa9c19a7f7caa678bd2045fd012c1a7287043 100644 --- a/Source/WebCore/platform/ScrollAnimationKinetic.h +++ b/Source/WebCore/platform/ScrollAnimationKinetic.h @@ -66,6 +66,7 @@ public: private: void stop() override; void animationTimerFired(); + bool isScrollInProgress() const override; std::function m_notifyPositionChangedFunction; diff --git a/Source/WebCore/platform/ScrollAnimationSmooth.cpp b/Source/WebCore/platform/ScrollAnimationSmooth.cpp index d064e69379f8c5c34290a48ff28a6dafbedf5a8a..062baeaeae5a0c0562402b1ba272183bb71129a2 100644 --- a/Source/WebCore/platform/ScrollAnimationSmooth.cpp +++ b/Source/WebCore/platform/ScrollAnimationSmooth.cpp @@ -28,8 +28,6 @@ #include "config.h" #include "ScrollAnimationSmooth.h" -#if ENABLE(SMOOTH_SCROLLING) - #include "FloatPoint.h" #include "ScrollableArea.h" @@ -38,6 +36,7 @@ namespace WebCore { static const double frameRate = 60; static const Seconds tickTime = 1_s / frameRate; static const Seconds minimumTimerInterval { 1_ms }; +static const double smoothFactorForProgrammaticScroll = 5; ScrollAnimationSmooth::ScrollAnimationSmooth(ScrollableArea& scrollableArea, const FloatPoint& position, WTF::Function&& notifyPositionChangedFunction) : ScrollAnimation(scrollableArea) @@ -67,6 +66,18 @@ bool ScrollAnimationSmooth::scroll(ScrollbarOrientation orientation, ScrollGranu return needToScroll; } +void ScrollAnimationSmooth::scroll(const FloatPoint& position) +{ + ScrollGranularity granularity = ScrollByPage; + bool needToScroll = updatePerAxisData(m_horizontalData, granularity, position.x() - m_horizontalData.currentPosition, m_scrollableArea.minimumScrollPosition().x(), m_scrollableArea.maximumScrollPosition().x(), smoothFactorForProgrammaticScroll); + needToScroll |= + updatePerAxisData(m_verticalData, granularity, position.y() - m_verticalData.currentPosition, m_scrollableArea.minimumScrollPosition().y(), m_scrollableArea.maximumScrollPosition().y(), smoothFactorForProgrammaticScroll); + if (needToScroll && !animationTimerActive()) { + m_startTime = m_horizontalData.startTime; + animationTimerFired(); + } +}; + void ScrollAnimationSmooth::stop() { m_animationTimer.stop(); @@ -247,7 +258,7 @@ static inline void getAnimationParametersForGranularity(ScrollGranularity granul } } -bool ScrollAnimationSmooth::updatePerAxisData(PerAxisData& data, ScrollGranularity granularity, float delta, float minScrollPosition, float maxScrollPosition) +bool ScrollAnimationSmooth::updatePerAxisData(PerAxisData& data, ScrollGranularity granularity, float delta, float minScrollPosition, float maxScrollPosition, double smoothFactor) { if (!data.startTime || !delta || (delta < 0) != (data.desiredPosition - data.currentPosition < 0)) { data.desiredPosition = data.currentPosition; @@ -264,6 +275,12 @@ bool ScrollAnimationSmooth::updatePerAxisData(PerAxisData& data, ScrollGranulari Curve coastTimeCurve; getAnimationParametersForGranularity(granularity, animationTime, repeatMinimumSustainTime, attackTime, releaseTime, coastTimeCurve, maximumCoastTime); + animationTime *= smoothFactor; + repeatMinimumSustainTime *= smoothFactor; + attackTime *= smoothFactor; + releaseTime *= smoothFactor; + maximumCoastTime *= smoothFactor; + data.desiredPosition = newPosition; if (!data.startTime) data.attackTime = attackTime; @@ -407,5 +424,3 @@ bool ScrollAnimationSmooth::animationTimerActive() const } } // namespace WebCore - -#endif // ENABLE(SMOOTH_SCROLLING) diff --git a/Source/WebCore/platform/ScrollAnimationSmooth.h b/Source/WebCore/platform/ScrollAnimationSmooth.h index 02cc4ee2bd743d0629ead048bf76c48167bfe8ed..d6f524f03c2c464e9096134186d3ce508334ec80 100644 --- a/Source/WebCore/platform/ScrollAnimationSmooth.h +++ b/Source/WebCore/platform/ScrollAnimationSmooth.h @@ -27,14 +27,13 @@ #include "ScrollAnimation.h" -#if ENABLE(SMOOTH_SCROLLING) - #include "Timer.h" namespace WebCore { class FloatPoint; class ScrollableArea; +enum class ScrollClamping : uint8_t; class ScrollAnimationSmooth final: public ScrollAnimation { public: @@ -51,9 +50,11 @@ public: private: bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier) override; + void scroll(const FloatPoint&) override; void stop() override; void updateVisibleLengths() override; void setCurrentPosition(const FloatPoint&) override; + bool isScrollInProgress() const override { return animationTimerActive(); } struct PerAxisData { PerAxisData() = delete; @@ -89,7 +90,7 @@ private: int visibleLength { 0 }; }; - bool updatePerAxisData(PerAxisData&, ScrollGranularity, float delta, float minScrollPosition, float maxScrollPosition); + bool updatePerAxisData(PerAxisData&, ScrollGranularity, float delta, float minScrollPosition, float maxScrollPosition, double smoothFactor = 1); bool animateScroll(PerAxisData&, MonotonicTime currentTime); void requestAnimationTimerFired(); @@ -108,4 +109,3 @@ private: } // namespace WebCore -#endif // ENABLE(SMOOTH_SCROLLING) diff --git a/Source/WebCore/platform/ScrollAnimator.cpp b/Source/WebCore/platform/ScrollAnimator.cpp index a61186837da86fdfec3d81ccc18ae451537c562f..42b4691da69856c2e02932c04266207f42fab5d3 100644 --- a/Source/WebCore/platform/ScrollAnimator.cpp +++ b/Source/WebCore/platform/ScrollAnimator.cpp @@ -35,6 +35,7 @@ #include "FloatPoint.h" #include "LayoutSize.h" #include "PlatformWheelEvent.h" +#include "ScrollAnimationSmooth.h" #include "ScrollableArea.h" #include @@ -52,11 +53,29 @@ ScrollAnimator::ScrollAnimator(ScrollableArea& scrollableArea) #if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING) , m_scrollController(*this) #endif + , m_animationProgrammaticScroll(makeUnique(scrollableArea, m_currentPosition, [this](FloatPoint&& position) { + auto previousScrollType = m_scrollableArea.currentScrollType(); + m_scrollableArea.setCurrentScrollType(ScrollType::Programmatic); + bool updated = m_scrollableArea.requestScrollPositionUpdate(roundedIntPoint(position)); + m_scrollableArea.setCurrentScrollType(previousScrollType); + if (updated) + return; + + FloatSize delta = position - m_currentPosition; + m_currentPosition = WTFMove(position); + notifyPositionChanged(delta); + })) { } ScrollAnimator::~ScrollAnimator() = default; +bool ScrollAnimator::isScrollInProgress() const +{ + // FIXME (TODO): This should also take into account animations in derived classes. + return m_animationProgrammaticScroll->isScrollInProgress(); +} + bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier) { FloatPoint currentPosition = this->currentPosition(); @@ -75,6 +94,14 @@ bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, return true; } +void ScrollAnimator::scrollToOffset(const FloatPoint& offset) +{ + m_animationProgrammaticScroll->setCurrentPosition(m_currentPosition); + auto newPosition = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); + m_animationProgrammaticScroll->scroll(newPosition); + m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::WebAnimationTimerStarted); +} + void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping) { FloatPoint newPositon = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); @@ -245,4 +272,34 @@ void ScrollAnimator::removeWheelEventTestCompletionDeferralForReason(WheelEventT } #endif +void ScrollAnimator::cancelAnimations() +{ +#if !USE(REQUEST_ANIMATION_FRAME_TIMER) + m_animationProgrammaticScroll->stop(); +#endif + m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); +} + +void ScrollAnimator::serviceScrollAnimations() +{ +#if !USE(REQUEST_ANIMATION_FRAME_TIMER) + m_animationProgrammaticScroll->serviceAnimation(); +#endif +} + +void ScrollAnimator::willEndLiveResize() +{ + m_animationProgrammaticScroll->updateVisibleLengths(); +} + +void ScrollAnimator::didAddVerticalScrollbar(Scrollbar*) +{ + m_animationProgrammaticScroll->updateVisibleLengths(); +} + +void ScrollAnimator::didAddHorizontalScrollbar(Scrollbar*) +{ + m_animationProgrammaticScroll->updateVisibleLengths(); +} + } // namespace WebCore diff --git a/Source/WebCore/platform/ScrollAnimator.h b/Source/WebCore/platform/ScrollAnimator.h index a5c69c53b7e90dbce68467ec2617f04f197e43f9..060537edb324596bb3a0ca623491a86ce196045c 100644 --- a/Source/WebCore/platform/ScrollAnimator.h +++ b/Source/WebCore/platform/ScrollAnimator.h @@ -46,6 +46,7 @@ namespace WebCore { class FloatPoint; class PlatformTouchEvent; +class ScrollAnimation; class ScrollableArea; class Scrollbar; class WheelEventTestMonitor; @@ -68,6 +69,7 @@ public: // The base class implementation always scrolls immediately, never animates. virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier); + void scrollToOffset(const FloatPoint&); virtual void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); ScrollableArea& scrollableArea() const { return m_scrollableArea; } @@ -85,8 +87,8 @@ public: void setCurrentPosition(const FloatPoint&); const FloatPoint& currentPosition() const { return m_currentPosition; } - virtual void cancelAnimations() { } - virtual void serviceScrollAnimations() { } + virtual void cancelAnimations(); + virtual void serviceScrollAnimations(); virtual void contentAreaWillPaint() const { } virtual void mouseEnteredContentArea() { } @@ -97,16 +99,16 @@ public: virtual void mouseIsDownInScrollbar(Scrollbar*, bool) const { } virtual void willStartLiveResize() { } virtual void contentsResized() const { } - virtual void willEndLiveResize() { } + virtual void willEndLiveResize(); virtual void contentAreaDidShow() { } virtual void contentAreaDidHide() { } virtual void lockOverlayScrollbarStateToHidden(bool) { } virtual bool scrollbarsCanBeActive() const { return true; } - virtual void didAddVerticalScrollbar(Scrollbar*) { } + virtual void didAddVerticalScrollbar(Scrollbar*); virtual void willRemoveVerticalScrollbar(Scrollbar*) { } - virtual void didAddHorizontalScrollbar(Scrollbar*) { } + virtual void didAddHorizontalScrollbar(Scrollbar*); virtual void willRemoveHorizontalScrollbar(Scrollbar*) { } virtual void invalidateScrollbarPartLayers(Scrollbar*) { } @@ -120,6 +122,7 @@ public: virtual bool isRubberBandInProgress() const { return false; } virtual bool isScrollSnapInProgress() const { return false; } + bool isScrollInProgress() const; void setWheelEventTestMonitor(RefPtr&& testMonitor) { m_wheelEventTestMonitor = testMonitor; } @@ -151,6 +154,8 @@ protected: ScrollController m_scrollController; #endif FloatPoint m_currentPosition; + + std::unique_ptr m_animationProgrammaticScroll; }; } // namespace WebCore diff --git a/Source/WebCore/platform/ScrollTypes.h b/Source/WebCore/platform/ScrollTypes.h index 891149103d36ce3aa634450128bc89c4402fba8c..90a4562c021e4601bca72c7948bec68ec3b8508b 100644 --- a/Source/WebCore/platform/ScrollTypes.h +++ b/Source/WebCore/platform/ScrollTypes.h @@ -54,6 +54,19 @@ enum class ScrollPositionClamp : uint8_t { ToContentEdges, }; +enum class ScrollBehaviorType : uint8_t { + Instant, + Smooth, +}; + +enum class ScrollBehaviorStatus : uint8_t { + NotInAnimation, + WebAnimationTimerStarted, +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + InUINativeAnimation, +#endif +}; + inline ScrollDirection logicalToPhysical(ScrollLogicalDirection direction, bool isVertical, bool isFlipped) { switch (direction) { diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp index b126a9c2b706a117346c57407851e385582cc968..c2569cbd25aca5d2eba72fbb8c153a322bdda2a2 100644 --- a/Source/WebCore/platform/ScrollView.cpp +++ b/Source/WebCore/platform/ScrollView.cpp @@ -461,10 +461,12 @@ void ScrollView::completeUpdatesAfterScrollTo(const IntSize& scrollDelta) updateCompositingLayersAfterScrolling(); } -void ScrollView::setScrollPosition(const ScrollPosition& scrollPosition) +void ScrollView::setScrollPosition(const ScrollPosition& scrollPosition, bool/* animated*/) { LOG_WITH_STREAM(Scrolling, stream << "ScrollView::setScrollPosition " << scrollPosition); - +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + setCurrentScrollBehaviorType(ScrollBehaviorType::Instant); +#endif if (prohibitsScrolling()) return; @@ -475,13 +477,17 @@ void ScrollView::setScrollPosition(const ScrollPosition& scrollPosition) ScrollPosition newScrollPosition = !delegatesScrolling() ? adjustScrollPositionWithinRange(scrollPosition) : scrollPosition; - if ((!delegatesScrolling() || currentScrollType() == ScrollType::User) && newScrollPosition == this->scrollPosition()) + if ((!delegatesScrolling() || currentScrollType() == ScrollType::User) && !isScrollInProgress() && newScrollPosition == this->scrollPosition()) return; + if (isWebScrollAnimationInProgress()) + scrollAnimator().cancelAnimations(); + if (requestScrollPositionUpdate(newScrollPosition)) return; updateScrollbars(newScrollPosition); + setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); } bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity) @@ -538,7 +544,8 @@ void ScrollView::updateScrollbars(const ScrollPosition& desiredPosition) if (!managesScrollbars()) { if (scrollOriginChanged()) { - ScrollableArea::scrollToOffsetWithoutAnimation(scrollOffsetFromPosition(desiredPosition)); + if (!requestScrollPositionUpdate(desiredPosition)) + ScrollableArea::scrollToOffsetWithoutAnimation(scrollOffsetFromPosition(desiredPosition)); resetScrollOriginChanged(); } return; diff --git a/Source/WebCore/platform/ScrollView.h b/Source/WebCore/platform/ScrollView.h index 03eb5d170a7b7fdd15b238920493e58f595b5000..265377a02d73c6cd6f2f6f4396d26c127765f6b0 100644 --- a/Source/WebCore/platform/ScrollView.h +++ b/Source/WebCore/platform/ScrollView.h @@ -260,7 +260,7 @@ public: ScrollPosition cachedScrollPosition() const { return m_cachedScrollPosition; } // Functions for scrolling the view. - virtual void setScrollPosition(const ScrollPosition&); + virtual void setScrollPosition(const ScrollPosition&, bool animated = false); void scrollBy(const IntSize& s) { return setScrollPosition(scrollPosition() + s); } // This function scrolls by lines, pages or pixels. diff --git a/Source/WebCore/platform/ScrollableArea.cpp b/Source/WebCore/platform/ScrollableArea.cpp index 96d0f300b3418e60821da2da2a64189c4dee0b3c..ac4602ab9a7a5a941a1454ca9a6e25981a79c9ee 100644 --- a/Source/WebCore/platform/ScrollableArea.cpp +++ b/Source/WebCore/platform/ScrollableArea.cpp @@ -71,6 +71,9 @@ ScrollableArea::ScrollableArea() , m_scrollOriginChanged(false) , m_currentScrollType(static_cast(ScrollType::User)) , m_scrollShouldClearLatchedState(false) +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + , m_currentScrollBehaviorType(static_cast(ScrollBehaviorType::Instant)) +#endif { } @@ -104,6 +107,24 @@ float ScrollableArea::adjustScrollStepForFixedContent(float step, ScrollbarOrien return step; } +bool ScrollableArea::isScrollInProgress() +{ + if (m_currentScrollBehaviorStatus == ScrollBehaviorStatus::WebAnimationTimerStarted) { + if (!(m_scrollAnimator && scrollAnimator().isScrollInProgress())) + m_currentScrollBehaviorStatus = ScrollBehaviorStatus::NotInAnimation; + } + return m_currentScrollBehaviorStatus != ScrollBehaviorStatus::NotInAnimation; +} + +bool ScrollableArea::isWebScrollAnimationInProgress() +{ + if (m_currentScrollBehaviorStatus == ScrollBehaviorStatus::WebAnimationTimerStarted) { + if (!(m_scrollAnimator && scrollAnimator().isScrollInProgress())) + m_currentScrollBehaviorStatus = ScrollBehaviorStatus::NotInAnimation; + } + return m_currentScrollBehaviorStatus == ScrollBehaviorStatus::WebAnimationTimerStarted; +} + bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) { ScrollbarOrientation orientation; @@ -142,6 +163,12 @@ bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula return scrollAnimator().scroll(orientation, granularity, step, multiplier); } +void ScrollableArea::scrollToOffsetWithAnimation(const FloatPoint& offset, ScrollClamping) +{ + LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToOffset " << offset); + scrollAnimator().scrollToOffset(offset); +} + void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping) { LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToOffsetWithoutAnimation " << offset); @@ -221,16 +248,15 @@ bool ScrollableArea::handleTouchEvent(const PlatformTouchEvent& touchEvent) // NOTE: Only called from Internals for testing. void ScrollableArea::setScrollOffsetFromInternals(const ScrollOffset& offset) { + if (requestScrollPositionUpdate(scrollPositionFromOffset(offset))) + return; + setScrollOffsetFromAnimation(offset); } void ScrollableArea::setScrollOffsetFromAnimation(const ScrollOffset& offset) { - ScrollPosition position = scrollPositionFromOffset(offset); - if (requestScrollPositionUpdate(position)) - return; - - scrollPositionChanged(position); + scrollPositionChanged(scrollPositionFromOffset(offset)); } void ScrollableArea::willStartLiveResize() diff --git a/Source/WebCore/platform/ScrollableArea.h b/Source/WebCore/platform/ScrollableArea.h index d7438c15cd51d6660c0f738ac2e97fabf5abdc23..73a373700af00c547adbbc9edd328297caa5c0e5 100644 --- a/Source/WebCore/platform/ScrollableArea.h +++ b/Source/WebCore/platform/ScrollableArea.h @@ -62,7 +62,13 @@ inline int offsetForOrientation(ScrollOffset offset, ScrollbarOrientation orient class ScrollableArea : public CanMakeWeakPtr { public: + WEBCORE_EXPORT bool isScrollInProgress(); + bool isWebScrollAnimationInProgress(); + ScrollBehaviorStatus currentScrollBehaviorStatus() const { return m_currentScrollBehaviorStatus; } + void setScrollBehaviorStatus(ScrollBehaviorStatus status) { m_currentScrollBehaviorStatus = status; } + WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); + WEBCORE_EXPORT void scrollToOffsetWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); WEBCORE_EXPORT void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); @@ -242,6 +248,11 @@ public: ScrollType currentScrollType() const { return static_cast(m_currentScrollType); } void setCurrentScrollType(ScrollType scrollType) { m_currentScrollType = static_cast(scrollType); } +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + ScrollBehaviorType currentScrollBehaviorType() const { return static_cast(m_currentScrollBehaviorType); } + void setCurrentScrollBehaviorType(ScrollBehaviorType scrollBehaviorType) { m_currentScrollBehaviorType = static_cast(scrollBehaviorType); } +#endif + bool scrollShouldClearLatchedState() const { return m_scrollShouldClearLatchedState; } void setScrollShouldClearLatchedState(bool shouldClear) { m_scrollShouldClearLatchedState = shouldClear; } @@ -378,6 +389,8 @@ private: unsigned m_currentVerticalSnapPointIndex { 0 }; #endif + ScrollBehaviorStatus m_currentScrollBehaviorStatus { ScrollBehaviorStatus::NotInAnimation }; + // There are 8 possible combinations of writing mode and direction. Scroll origin will be non-zero in the x or y axis // if there is any reversed direction or writing-mode. The combinations are: // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set @@ -403,6 +416,10 @@ private: unsigned m_scrollOriginChanged : 1; unsigned m_currentScrollType : 1; // ScrollType unsigned m_scrollShouldClearLatchedState : 1; +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + unsigned m_currentScrollBehaviorType : 1; +#endif + }; } // namespace WebCore diff --git a/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp b/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp index 208af7b8479ecaef5530ccc557b736ebabcbcb8f..ad332c3283d93d3f2dd7f348066deb7fc4252e1a 100644 --- a/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp +++ b/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp @@ -162,6 +162,8 @@ void ScrollAnimatorGeneric::willEndLiveResize() void ScrollAnimatorGeneric::updatePosition(FloatPoint&& position) { + if (m_scrollableArea.requestScrollPositionUpdate(roundedIntPoint(position))) + return; FloatSize delta = position - m_currentPosition; m_currentPosition = WTFMove(position); notifyPositionChanged(delta); diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm index f5917672eefdf1f523cdf69246b23860494fb2a2..63753ad26b52ce4346b9a9bc5e0dd8cf4a6c3222 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -1155,6 +1155,7 @@ void ScrollAnimatorMac::notifyContentAreaScrolled(const FloatSize& delta) void ScrollAnimatorMac::cancelAnimations() { + ScrollAnimator::cancelAnimations(); m_haveScrolledSincePageLoad = false; if (scrollbarPaintTimerIsActive()) diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp index 87ae7624061f47c743e4060a185e932927bc7352..b6e5e5804d2c38787c47c101b25d5185d6cec22a 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -581,20 +581,28 @@ static void setupWheelEventMonitor(RenderLayer& layer) layer.scrollAnimator().setWheelEventTestMonitor(page.wheelEventTestMonitor()); } -void RenderBox::setScrollLeft(int newLeft, ScrollType scrollType, ScrollClamping clamping) +void RenderBox::setScrollLeft(int newLeft, ScrollType scrollType, bool animated, ScrollClamping clamping) { if (!hasOverflowClip() || !layer()) return; setupWheelEventMonitor(*layer()); - layer()->scrollToXPosition(newLeft, scrollType, clamping); + layer()->scrollToXPosition(newLeft, scrollType, animated, clamping); } -void RenderBox::setScrollTop(int newTop, ScrollType scrollType, ScrollClamping clamping) +void RenderBox::setScrollTop(int newTop, ScrollType scrollType, bool animated, ScrollClamping clamping) { if (!hasOverflowClip() || !layer()) return; setupWheelEventMonitor(*layer()); - layer()->scrollToYPosition(newTop, scrollType, clamping); + layer()->scrollToYPosition(newTop, scrollType, animated, clamping); +} + +void RenderBox::setScrollPosition(const ScrollPosition& position, ScrollType scrollType, bool animated, ScrollClamping clamping) +{ + if (!hasOverflowClip() || !layer()) + return; + setupWheelEventMonitor(*layer()); + layer()->scrollToPosition(position, scrollType, animated, clamping); } void RenderBox::absoluteRects(Vector& rects, const LayoutPoint& accumulatedOffset) const diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h index 2bfce5f674b9f091bc451a6958381345a13b0e55..b9b08c56ee70dd14b0131ff24e5de056abecba68 100644 --- a/Source/WebCore/rendering/RenderBox.h +++ b/Source/WebCore/rendering/RenderBox.h @@ -247,8 +247,9 @@ public: virtual int scrollTop() const; virtual int scrollWidth() const; virtual int scrollHeight() const; - virtual void setScrollLeft(int, ScrollType, ScrollClamping = ScrollClamping::Clamped); - virtual void setScrollTop(int, ScrollType, ScrollClamping = ScrollClamping::Clamped); + virtual void setScrollLeft(int, ScrollType, bool animated = false, ScrollClamping = ScrollClamping::Clamped); + virtual void setScrollTop(int, ScrollType, bool animated = false, ScrollClamping = ScrollClamping::Clamped); + void setScrollPosition(const ScrollPosition&, ScrollType, bool animated = false, ScrollClamping = ScrollClamping::Clamped); LayoutUnit marginTop() const override { return m_marginBox.top(); } LayoutUnit marginBottom() const override { return m_marginBox.bottom(); } diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index 22876b7abe7d5a43cfae096ce924f534b834f6ae..78fa8f7663a5567a9bdde2e897d45f1781317769 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -116,6 +116,7 @@ #include "ScaleTransformOperation.h" #include "ScriptDisallowedScope.h" #include "ScrollAnimator.h" +#include "ScrollBehavior.h" #include "Scrollbar.h" #include "ScrollbarTheme.h" #include "ScrollingCoordinator.h" @@ -2547,16 +2548,24 @@ void RenderLayer::applyPostLayoutScrollPositionIfNeeded() m_postLayoutScrollPosition = WTF::nullopt; } -void RenderLayer::scrollToXPosition(int x, ScrollType scrollType, ScrollClamping clamping) +void RenderLayer::scrollToXPosition(int x, ScrollType scrollType, bool animated, ScrollClamping clamping) { ScrollPosition position(x, m_scrollPosition.y()); - scrollToOffset(scrollOffsetFromPosition(position), scrollType, clamping); + scrollToPosition(position, scrollType, animated, clamping); } -void RenderLayer::scrollToYPosition(int y, ScrollType scrollType, ScrollClamping clamping) +void RenderLayer::scrollToYPosition(int y, ScrollType scrollType, bool animated, ScrollClamping clamping) { ScrollPosition position(m_scrollPosition.x(), y); - scrollToOffset(scrollOffsetFromPosition(position), scrollType, clamping); + scrollToPosition(position, scrollType, animated, clamping); +} + +void RenderLayer::scrollToPosition(const ScrollPosition& position, ScrollType scrollType, bool animated, ScrollClamping clamping) +{ + if (animated) + scrollToOffsetWithAnimation(scrollOffsetFromPosition(position), scrollType, clamping); + else + scrollToOffset(scrollOffsetFromPosition(position), scrollType, clamping); } ScrollOffset RenderLayer::clampScrollOffset(const ScrollOffset& scrollOffset) const @@ -2566,23 +2575,67 @@ ScrollOffset RenderLayer::clampScrollOffset(const ScrollOffset& scrollOffset) co void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollType scrollType, ScrollClamping clamping) { +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + setCurrentScrollBehaviorType(ScrollBehaviorType::Instant); +#endif + if (isWebScrollAnimationInProgress()) + scrollAnimator().cancelAnimations(); + ScrollOffset clampedScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset; - if (clampedScrollOffset == this->scrollOffset()) + if (clampedScrollOffset == this->scrollOffset()) { +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + // If UIScrollView is during scroll animation, the scroll offset of web side might be overriden. + // So we need to requestScrollPositionUpdate here, and check in UI side. If the scroll offset in UI side + // is different, the correct scroll offset need to sync back to Web side. + if (currentScrollBehaviorStatus() == ScrollBehaviorStatus::InUINativeAnimation) + requestScrollPositionUpdate(scrollPositionFromOffset(clampedScrollOffset)); +#endif return; + } auto previousScrollType = currentScrollType(); setCurrentScrollType(scrollType); bool handled = false; #if ENABLE(ASYNC_SCROLLING) - if (ScrollingCoordinator* scrollingCoordinator = page().scrollingCoordinator()) - handled = scrollingCoordinator->requestScrollPositionUpdate(*this, scrollPositionFromOffset(clampedScrollOffset)); + handled = requestScrollPositionUpdate(scrollPositionFromOffset(clampedScrollOffset)); #endif if (!handled) scrollToOffsetWithoutAnimation(clampedScrollOffset, clamping); setCurrentScrollType(previousScrollType); + setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); +} + +bool RenderLayer::requestScrollPositionUpdate(const ScrollPosition& position) +{ +#if ENABLE(ASYNC_SCROLLING) + if (ScrollingCoordinator* scrollingCoordinator = page().scrollingCoordinator()) + return scrollingCoordinator->requestScrollPositionUpdate(*this, position); +#endif + return false; +} + +void RenderLayer::scrollToOffsetWithAnimation(const ScrollOffset& offset, ScrollType scrollType, ScrollClamping clamping) +{ + auto previousScrollType = currentScrollType(); + setCurrentScrollType(scrollType); + +#if PLATFORM(IOS_FAMILY) && ENABLE(ASYNC_SCROLLING) + setCurrentScrollBehaviorType(ScrollBehaviorType::Smooth); + if (requestScrollPositionUpdate(scrollPositionFromOffset(offset))) { + setCurrentScrollType(previousScrollType); + return; + } +#endif + + ScrollOffset newScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(offset) : offset; + if (isWebScrollAnimationInProgress()) + scrollAnimator().cancelAnimations(); + if (newScrollOffset != this->scrollOffset()) + ScrollableArea::scrollToOffsetWithAnimation(newScrollOffset); + setCurrentScrollType(previousScrollType); } void RenderLayer::scrollTo(const ScrollPosition& position) @@ -2617,7 +2670,7 @@ void RenderLayer::scrollTo(const ScrollPosition& position) #endif } - if (m_scrollPosition == newPosition) { + if (m_scrollPosition == newPosition && !isScrollInProgress()) { // FIXME: Nothing guarantees we get a scrollTo() with an unchanged position at the end of a user gesture. // The ScrollingCoordinator probably needs to message the main thread when a gesture ends. if (requiresScrollPositionReconciliation()) { @@ -2735,6 +2788,7 @@ bool RenderLayer::allowsCurrentScroll() const void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions& options) { + // FIXME (https://webkit.org/b/189907): Make this work with nested scrollable boxes when a smooth scrolling must be performed. LOG_WITH_STREAM(Scrolling, stream << "Layer " << this << " scrollRectToVisible " << absoluteRect); RenderLayer* parentLayer = nullptr; @@ -2762,10 +2816,11 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insid LayoutRect revealRect = getRectToExpose(layerBounds, localExposeRect, insideFixed, options.alignX, options.alignY); ScrollOffset clampedScrollOffset = clampScrollOffset(scrollOffset() + toIntSize(roundedIntRect(revealRect).location())); - if (clampedScrollOffset != scrollOffset()) { + if (isScrollInProgress() || clampedScrollOffset != scrollOffset()) { ScrollOffset oldScrollOffset = scrollOffset(); - scrollToOffset(clampedScrollOffset); - IntSize scrollOffsetDifference = scrollOffset() - oldScrollOffset; + bool animated = (box->element() && useSmoothScrolling(options.behavior, *box->element())); + scrollToPosition(scrollPositionFromOffset(clampedScrollOffset), ScrollType::Programmatic, animated); + IntSize scrollOffsetDifference = clampedScrollOffset - oldScrollOffset; localExposeRect.move(-scrollOffsetDifference); newRect = LayoutRect(box->localToAbsoluteQuad(FloatQuad(FloatRect(localExposeRect)), UseTransforms).boundingBox()); } @@ -2785,10 +2840,13 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insid LayoutRect viewRect = frameView.visibleContentRect(LegacyIOSDocumentVisibleRect); LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, options.alignX, options.alignY); - IntPoint scrollOffset(roundedIntPoint(exposeRect.location())); + IntPoint scrollPosition(roundedIntPoint(exposeRect.location())); // Adjust offsets if they're outside of the allowable range. - scrollOffset = scrollOffset.constrainedBetween(IntPoint(), IntPoint(frameView.contentsSize())); - frameView.setScrollPosition(scrollOffset); + scrollPosition = scrollPosition.constrainedBetween(IntPoint(), IntPoint(frameView.contentsSize())); + // FIXME: Should we use contentDocument()->scrollingElement()? + // See https://github.com/w3c/csswg-drafts/issues/2977 + bool animated = ownerElement->contentDocument() && ownerElement->contentDocument()->documentElement() && useSmoothScrolling(options.behavior, *ownerElement->contentDocument()->documentElement()); + frameView.setScrollPosition(scrollPosition, animated); if (options.shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) { parentLayer = ownerElement->renderer()->enclosingLayer(); @@ -2827,7 +2885,10 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insid // Avoid scrolling to the rounded value of revealRect.location() if we don't actually need to scroll if (revealRect != viewRect) { ScrollOffset clampedScrollPosition = roundedIntPoint(revealRect.location()).constrainedBetween(minScrollPosition, maxScrollPosition); - frameView.setScrollPosition(clampedScrollPosition); + // FIXME: Should we use document()->scrollingElement()? + // See https://github.com/w3c/csswg-drafts/issues/2977 + bool animated = renderer().document().documentElement() && useSmoothScrolling(options.behavior, *renderer().document().documentElement()); + frameView.setScrollPosition(clampedScrollPosition, animated); } // This is the outermost view of a web page, so after scrolling this view we diff --git a/Source/WebCore/rendering/RenderLayer.h b/Source/WebCore/rendering/RenderLayer.h index 49ee9d4844caa39f3ec2816fa6c621ac6ff5c3ad..e02124fb40e2781ce256120e8f6e1fad126a72fa 100644 --- a/Source/WebCore/rendering/RenderLayer.h +++ b/Source/WebCore/rendering/RenderLayer.h @@ -50,6 +50,7 @@ #include "PaintInfo.h" #include "RenderBox.h" #include "RenderPtr.h" +#include "ScrollBehavior.h" #include "ScrollableArea.h" #include #include @@ -134,6 +135,7 @@ struct ScrollRectToVisibleOptions { const ScrollAlignment& alignX { ScrollAlignment::alignCenterIfNeeded }; const ScrollAlignment& alignY { ScrollAlignment::alignCenterIfNeeded }; ShouldAllowCrossOriginScrolling shouldAllowCrossOriginScrolling { ShouldAllowCrossOriginScrolling::No }; + ScrollBehavior behavior { ScrollBehavior::Auto }; }; class RenderLayer final : public ScrollableArea { @@ -434,9 +436,13 @@ public: void scrollByRecursively(const IntSize& delta, ScrollableArea** scrolledArea = nullptr); WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped); + WEBCORE_EXPORT void scrollToOffsetWithAnimation(const ScrollOffset&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped); - void scrollToXPosition(int x, ScrollType, ScrollClamping = ScrollClamping::Clamped); - void scrollToYPosition(int y, ScrollType, ScrollClamping = ScrollClamping::Clamped); + bool requestScrollPositionUpdate(const ScrollPosition&) override; + + void scrollToXPosition(int x, ScrollType, bool animated, ScrollClamping = ScrollClamping::Clamped); + void scrollToYPosition(int y, ScrollType, bool animated, ScrollClamping = ScrollClamping::Clamped); + void scrollToPosition(const ScrollPosition&, ScrollType, bool animated, ScrollClamping = ScrollClamping::Clamped); // These are only used by marquee. void scrollToXOffset(int x) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), ScrollType::Programmatic, ScrollClamping::Unclamped); } diff --git a/Source/WebCore/rendering/RenderListBox.cpp b/Source/WebCore/rendering/RenderListBox.cpp index 9c81d7d9c84aeb3c16d6312629b4df51367ef049..f3271e4fbb0546e4d203f33654caf4c0670f0889 100644 --- a/Source/WebCore/rendering/RenderListBox.cpp +++ b/Source/WebCore/rendering/RenderListBox.cpp @@ -744,7 +744,7 @@ int RenderListBox::scrollLeft() const return 0; } -void RenderListBox::setScrollLeft(int, ScrollType, ScrollClamping) +void RenderListBox::setScrollLeft(int, ScrollType, bool, ScrollClamping) { } @@ -761,7 +761,7 @@ static void setupWheelEventTestMonitor(RenderListBox& renderer) renderer.scrollAnimator().setWheelEventTestMonitor(renderer.page().wheelEventTestMonitor()); } -void RenderListBox::setScrollTop(int newTop, ScrollType, ScrollClamping) +void RenderListBox::setScrollTop(int newTop, ScrollType, bool, ScrollClamping) { // Determine an index and scroll to it. int index = newTop / itemHeight(); diff --git a/Source/WebCore/rendering/RenderListBox.h b/Source/WebCore/rendering/RenderListBox.h index 65d9226b3a054e6978a029674ea9df44041e37bc..25c90651df0b7517afe7241460136eb05329e40c 100644 --- a/Source/WebCore/rendering/RenderListBox.h +++ b/Source/WebCore/rendering/RenderListBox.h @@ -106,8 +106,8 @@ private: int scrollTop() const override; int scrollWidth() const override; int scrollHeight() const override; - void setScrollLeft(int, ScrollType, ScrollClamping) override; - void setScrollTop(int, ScrollType, ScrollClamping) override; + void setScrollLeft(int, ScrollType, bool, ScrollClamping) override; + void setScrollTop(int, ScrollType, bool, ScrollClamping) override; bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; diff --git a/Source/WebCore/rendering/RenderObject.cpp b/Source/WebCore/rendering/RenderObject.cpp index 8fe703a4572a9f7333cb8d2aa09fff9c99998d2b..14159735fae6ac7dc3c1f6d3009566683415c6a2 100644 --- a/Source/WebCore/rendering/RenderObject.cpp +++ b/Source/WebCore/rendering/RenderObject.cpp @@ -427,7 +427,10 @@ bool RenderObject::scrollRectToVisible(const LayoutRect& absoluteRect, bool insi if (!enclosingLayer) return false; + auto previousScrollType = enclosingLayer->currentScrollType(); + enclosingLayer->setCurrentScrollType(ScrollType::Programmatic); enclosingLayer->scrollRectToVisible(absoluteRect, insideFixed, options); + enclosingLayer->setCurrentScrollType(previousScrollType); return true; } diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp index 9ee888867110b566529e8fba1025cd5191e1ac39..4df7d318dc78c943d33a8f5e1a5d5e7f4f6688ff 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp @@ -376,13 +376,13 @@ int RenderTextControlSingleLine::scrollTop() const return RenderBlockFlow::scrollTop(); } -void RenderTextControlSingleLine::setScrollLeft(int newLeft, ScrollType, ScrollClamping) +void RenderTextControlSingleLine::setScrollLeft(int newLeft, ScrollType, bool, ScrollClamping) { if (innerTextElement()) innerTextElement()->setScrollLeft(newLeft); } -void RenderTextControlSingleLine::setScrollTop(int newTop, ScrollType, ScrollClamping) +void RenderTextControlSingleLine::setScrollTop(int newTop, ScrollType, bool, ScrollClamping) { if (innerTextElement()) innerTextElement()->setScrollTop(newTop); diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.h b/Source/WebCore/rendering/RenderTextControlSingleLine.h index 3f5786dfe400eb80fd8e2b3906662bd99b94f13a..666aa31451b31572027052bcde5b8949e5b00fdb 100644 --- a/Source/WebCore/rendering/RenderTextControlSingleLine.h +++ b/Source/WebCore/rendering/RenderTextControlSingleLine.h @@ -57,8 +57,8 @@ private: int scrollTop() const override; int scrollWidth() const override; int scrollHeight() const override; - void setScrollLeft(int, ScrollType, ScrollClamping) override; - void setScrollTop(int, ScrollType, ScrollClamping) override; + void setScrollLeft(int, ScrollType, bool, ScrollClamping) override; + void setScrollTop(int, ScrollType, bool, ScrollClamping) override; bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final; bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) final; diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index c2ec48ed9c4f8d51945219a61c2a4594478823e3..99a23c2ca2566746cdff1540ce3268a11b67f3dc 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -736,6 +736,8 @@ public: bool useTouchOverflowScrolling() const { return m_rareInheritedData->useTouchOverflowScrolling; } #endif + bool useSmoothScrolling() const { return m_rareNonInheritedData->useSmoothScrolling; } + #if ENABLE(TEXT_AUTOSIZING) TextSizeAdjustment textSizeAdjust() const { return m_rareInheritedData->textSizeAdjust; } AutosizeStatus autosizeStatus() const; @@ -1267,6 +1269,8 @@ public: void setUseTouchOverflowScrolling(bool v) { SET_VAR(m_rareInheritedData, useTouchOverflowScrolling, v); } #endif + void setUseSmoothScrolling(bool v) { SET_VAR(m_rareNonInheritedData, useSmoothScrolling, v); } + #if ENABLE(TEXT_AUTOSIZING) void setTextSizeAdjust(TextSizeAdjustment adjustment) { SET_VAR(m_rareInheritedData, textSizeAdjust, adjustment); } void setAutosizeStatus(AutosizeStatus); @@ -1704,6 +1708,8 @@ public: static bool initialUseTouchOverflowScrolling() { return false; } #endif + static bool initialUseSmoothScrolling() { return false; } + static const FilterOperations& initialFilter() { static NeverDestroyed ops; return ops; } static const FilterOperations& initialAppleColorFilter() { static NeverDestroyed ops; return ops; } diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp index fb32082337428b11fd6815207afe513f42cf101f..b00f3e8b686cb4846ed8eb867548ec6ab9674608 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp @@ -82,6 +82,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData() #if ENABLE(POINTER_EVENTS) , touchActions(static_cast(RenderStyle::initialTouchActions())) #endif + , useSmoothScrolling(static_cast(RenderStyle::initialUseSmoothScrolling())) , pageSizeType(PAGE_SIZE_AUTO) , transformStyle3D(static_cast(RenderStyle::initialTransformStyle3D())) , backfaceVisibility(static_cast(RenderStyle::initialBackfaceVisibility())) @@ -175,6 +176,7 @@ inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonIn #if ENABLE(POINTER_EVENTS) , touchActions(o.touchActions) #endif + , useSmoothScrolling(o.useSmoothScrolling) , pageSizeType(o.pageSizeType) , transformStyle3D(o.transformStyle3D) , backfaceVisibility(o.backfaceVisibility) @@ -287,6 +289,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c #if ENABLE(POINTER_EVENTS) && touchActions == o.touchActions #endif + && useSmoothScrolling == o.useSmoothScrolling #if ENABLE(CSS_COMPOSITING) && effectiveBlendMode == o.effectiveBlendMode && isolation == o.isolation diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h index 19c591b2d124c965d897eba580511114a6bc7435..58f1c6ccf66076f9f0ab2b8b6aada97f2d7b580d 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h @@ -175,6 +175,8 @@ public: unsigned touchActions : 6; // TouchAction #endif + unsigned useSmoothScrolling : 1; // ScrollBehavior + unsigned pageSizeType : 2; // PageSizeType unsigned transformStyle3D : 1; // TransformStyle3D unsigned backfaceVisibility : 1; // BackfaceVisibility diff --git a/Source/WebCore/style/StyleBuilderConverter.h b/Source/WebCore/style/StyleBuilderConverter.h index 7f3f0cbc4e5515bb18b2af3900fa65d8d6ba099f..e38204f680357db182837ebb5db9b0edec249494 100644 --- a/Source/WebCore/style/StyleBuilderConverter.h +++ b/Source/WebCore/style/StyleBuilderConverter.h @@ -129,6 +129,7 @@ public: static bool convertOverflowScrolling(BuilderState&, const CSSValue&); #endif static FontFeatureSettings convertFontFeatureSettings(BuilderState&, const CSSValue&); + static bool convertSmoothScrolling(BuilderState&, const CSSValue&); static FontSelectionValue convertFontWeightFromValue(const CSSValue&); static FontSelectionValue convertFontStretchFromValue(const CSSValue&); static Optional convertFontStyleFromValue(const CSSValue&); @@ -1403,6 +1404,11 @@ inline bool BuilderConverter::convertOverflowScrolling(BuilderState&, const CSSV } #endif +inline bool BuilderConverter::convertSmoothScrolling(BuilderState&, const CSSValue& value) +{ + return downcast(value).valueID() == CSSValueSmooth; +} + inline SVGLengthValue BuilderConverter::convertSVGLengthValue(BuilderState&, const CSSValue& value) { return SVGLengthValue::fromCSSPrimitiveValue(downcast(value)); diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp index b9d2b537c8f45d262d870025fe34fb80ac5da261..7e7715f8aaa90388180ce33985037044f16dd81a 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -1764,7 +1764,7 @@ ExceptionOr Internals::unconstrainedScrollTo(Element& element, double x, d if (!document || !document->view()) return Exception { InvalidAccessError }; - element.scrollTo({ x, y }, ScrollClamping::Unclamped); + element.scrollTo(ScrollToOptions(x, y), ScrollClamping::Unclamped); return { }; } diff --git a/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp b/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp index e826a30b12e24ecf430c69b76b1a6f28f5bb98d8..c039c9e12d6c2c5fefd2e5faf8682b8612c68946 100644 --- a/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp +++ b/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp @@ -152,6 +152,7 @@ void ArgumentCoder::encode(Encoder& encoder, const SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::ScrollableAreaParams, scrollableAreaParameters) SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::RequestedScrollPosition, requestedScrollPosition) SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::RequestedScrollPosition, requestedScrollPositionRepresentsProgrammaticScroll) + SCROLLING_NODE_ENCODE(ScrollingStateScrollingNode::RequestedScrollPosition, requestedScrollPositionWithAnimation) if (node.hasChangedProperty(ScrollingStateScrollingNode::ScrollContainerLayer)) encoder << static_cast(node.scrollContainerLayer()); @@ -260,7 +261,11 @@ bool ArgumentCoder::decode(Decoder& decoder, Scroll if (!decoder.decode(representsProgrammaticScroll)) return false; - node.setRequestedScrollPosition(scrollPosition, representsProgrammaticScroll); + bool scrollWithAnimation; + if (!decoder.decode(scrollWithAnimation)) + return false; + + node.setRequestedScrollPosition(scrollPosition, representsProgrammaticScroll, scrollWithAnimation); } if (node.hasChangedProperty(ScrollingStateScrollingNode::ScrollContainerLayer)) { @@ -608,6 +613,7 @@ static void dump(TextStream& ts, const ScrollingStateScrollingNode& node, bool c if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { ts.dumpProperty("requested-scroll-position", node.requestedScrollPosition()); ts.dumpProperty("requested-scroll-position-is-programatic", node.requestedScrollPositionRepresentsProgrammaticScroll()); + ts.dumpProperty("requested-scroll-position-with-animation", node.requestedScrollPositionWithAnimation()); } if (!changedPropertiesOnly || node.hasChangedProperty(ScrollingStateScrollingNode::ScrollContainerLayer)) diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml index 18db8cf43d608ee7107bd5ded1b215416d876227..5f013ab5d30db5d5e9e5fdf6a2ffc1cd8af7a56b 100644 --- a/Source/WebKit/Shared/WebPreferences.yaml +++ b/Source/WebKit/Shared/WebPreferences.yaml @@ -1309,6 +1309,13 @@ BlockingOfSmallPluginsEnabled: humanReadableDescription: "Stop plugins smaller than a certain threshold from loading." category: internal +CSSOMViewSmoothScrollingEnabled: + type: bool + defaultValue: true + humanReadableName: "CSSOM View Smooth Scrolling" + humanReadableDescription: "Enable DOM API and CSS property for 'smooth' scroll behavior" + category: experimental + WebAnimationsEnabled: type: bool defaultValue: true diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm index 3951d8d4d80c96dec273b8ff0fdd6f0b76ce7e95..1f8faa4f82443e9e217e0ffa5c02ec993f1857ec 100644 --- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm +++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm @@ -1616,6 +1616,11 @@ static inline bool pointsEqualInDevicePixels(CGPoint a, CGPoint b, float deviceS && fabs(a.y * deviceScaleFactor - b.y * deviceScaleFactor) < std::numeric_limits::epsilon(); } +static inline bool pointsEqualInRoundToDevicePixel(CGPoint a, CGPoint b, float deviceScaleFactor) +{ + return CGRound(a.x * deviceScaleFactor) == CGRound(b.x * deviceScaleFactor) + && CGRound(a.y * deviceScaleFactor) == CGRound(b.y * deviceScaleFactor); +} static CGSize roundScrollViewContentSize(const WebKit::WebPageProxy& page, CGSize contentSize) { float deviceScaleFactor = page.deviceScaleFactor(); @@ -2340,9 +2345,10 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff return contentOffset.constrainedBetween(WebCore::FloatPoint(), WebCore::FloatPoint(maximumContentOffset)); } -- (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin +- (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin animated:(BOOL)animated { - if (_commitDidRestoreScrollPosition || _dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) + // Animated scrolling shouldn't be skipped. + if (!animated && (_commitDidRestoreScrollPosition || _dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing)) return; WebCore::FloatPoint contentOffset = WebCore::ScrollableArea::scrollOffsetFromPosition(scrollPosition, toFloatSize(scrollOrigin)); @@ -2356,13 +2362,21 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff [_scrollView _stopScrollingAndZoomingAnimations]; - if (!CGPointEqualToPoint(contentOffsetInScrollViewCoordinates, [_scrollView contentOffset])) - [_scrollView setContentOffset:contentOffsetInScrollViewCoordinates]; + // It's possible that they are not equal, but in the same device pixel, so _scrollView won't change. + // We need to calculate the round to device pixel here. + if (!pointsEqualInRoundToDevicePixel(contentOffsetInScrollViewCoordinates, [_scrollView contentOffset], _page->deviceScaleFactor())) + [_scrollView setContentOffset:contentOffsetInScrollViewCoordinates animated:animated]; else { // If we haven't changed anything, there would not be any VisibleContentRect update sent to the content. // The WebProcess would keep the invalid contentOffset as its scroll position. // To synchronize the WebProcess with what is on screen, we send the VisibleContentRect again. _page->resendLastVisibleContentRects(); + // If _scrollView won't change, we still need send animation stop info to web side. + if (animated) { + WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy(); + if (coordinator) + coordinator->scrollingTreeRootNodeIsScrollAnimationInProgressDidChange(false); + } } } @@ -2878,6 +2892,10 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { [self _didFinishScrolling]; + + WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy(); + if (coordinator) + coordinator->scrollingTreeRootNodeIsScrollAnimationInProgressDidChange(false); } - (void)_scrollViewDidInterruptDecelerating:(UIScrollView *)scrollView diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h index 435080f32445ce8e7f56ee5dc004394bcf1aa5d9..5cb5f58172561af1d814f09c554cb05c34e184bc 100644 --- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h +++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h @@ -97,7 +97,7 @@ struct PrintInfo; - (RefPtr)_takeViewSnapshot; -- (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin; +- (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin animated:(BOOL)animated; - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance; - (double)_initialScaleFactor; - (double)_contentZoomScale; diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h index 2a298993485bda1b800077cabcfaeed134e0d47e..418107764df7b62ccdf900897dbffe623f120b0a 100644 --- a/Source/WebKit/UIProcess/PageClient.h +++ b/Source/WebKit/UIProcess/PageClient.h @@ -181,6 +181,8 @@ public: // Tell the view to scroll to the given position, and whether this was a programmatic scroll. virtual void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin) = 0; + virtual void requestScrollWithAnimation(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin) { } + // Return the current scroll position (not necessarily the same as the WebCore scroll position, because of scaling, insets etc.) virtual WebCore::FloatPoint viewScrollPosition() = 0; diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm index b7b04695925dc68fdc656358e59f14215e85ce60..c8a9df7f8818e5c0ae9ba4e101bda2bc28bd3c5f 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm +++ b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm @@ -225,7 +225,7 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans // Handle requested scroll position updates from the scrolling tree transaction after didCommitLayerTree() // has updated the view size based on the content size. if (requestedScrollInfo.requestsScrollPositionUpdate) - m_webPageProxy.requestScroll(requestedScrollInfo.requestedScrollPosition, layerTreeTransaction.scrollOrigin()); + m_webPageProxy.requestScroll(requestedScrollInfo.requestedScrollPosition, layerTreeTransaction.scrollOrigin(), requestedScrollInfo.requestWithAnimation); #endif // ENABLE(ASYNC_SCROLLING) if (m_debugIndicatorLayerTreeHost) { diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp index 4823f76a9772f977cd76c25c3d5ea7d32f1dac66..0546b3134e3da89dd244b0cc4797bc1ec5b133f0 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp +++ b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp @@ -208,7 +208,7 @@ void RemoteScrollingCoordinatorProxy::currentSnapPointIndicesDidChange(WebCore:: } // This comes from the scrolling tree. -void RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll(ScrollingNodeID scrolledNodeID, const FloatPoint& newScrollPosition, const Optional& layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction) +void RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll(ScrollingNodeID scrolledNodeID, const FloatPoint& newScrollPosition, const Optional& layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction, bool instantScrollDidStopAnimation) { // Scroll updates for the main frame are sent via WebPageProxy::updateVisibleContentRects() // so don't send them here. @@ -222,21 +222,33 @@ void RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll(ScrollingNodeID m_webPageProxy.scrollingNodeScrollViewDidScroll(); #endif - if (m_scrollingTree->isHandlingProgrammaticScroll()) + if (m_scrollingTree->isHandlingProgrammaticScroll() && !instantScrollDidStopAnimation) return; m_webPageProxy.send(Messages::RemoteScrollingCoordinator::ScrollPositionChangedForNode(scrolledNodeID, newScrollPosition, scrollingLayerPositionAction == ScrollingLayerPositionAction::Sync)); } -void RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll(ScrollingNodeID scrolledNodeID, const FloatPoint& scrollPosition, bool representsProgrammaticScroll) +void RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll(ScrollingNodeID scrolledNodeID, const FloatPoint& scrollPosition, bool representsProgrammaticScroll, bool withAnimation) { if (scrolledNodeID == rootScrollingNodeID() && m_requestedScrollInfo) { m_requestedScrollInfo->requestsScrollPositionUpdate = true; m_requestedScrollInfo->requestIsProgrammaticScroll = representsProgrammaticScroll; + m_requestedScrollInfo->requestWithAnimation = withAnimation; m_requestedScrollInfo->requestedScrollPosition = scrollPosition; } } +void RemoteScrollingCoordinatorProxy::scrollingTreeNodeIsScrollAnimationInProgressDidChange(WebCore::ScrollingNodeID scrolledNodeID, bool isScrollAnimationInProgress) +{ + m_webPageProxy.send(Messages::RemoteScrollingCoordinator::scrollAnimationInProgressChangedForNode(scrolledNodeID, isScrollAnimationInProgress)); +} + +void RemoteScrollingCoordinatorProxy::scrollingTreeRootNodeIsScrollAnimationInProgressDidChange(bool isScrollAnimationInProgress) +{ + m_webPageProxy.send(Messages::RemoteScrollingCoordinator::scrollAnimationInProgressChangedForNode(rootScrollingNodeID(), isScrollAnimationInProgress)); +} + + String RemoteScrollingCoordinatorProxy::scrollingTreeAsText() const { if (m_scrollingTree) diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h index 1a76943f245be1cd822f19613cdd35f540a94cda..3ed7a8f64aa2dec9d5d27545b028a9a809c772a3 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h +++ b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h @@ -56,8 +56,11 @@ public: virtual ~RemoteScrollingCoordinatorProxy(); // Inform the web process that the scroll position changed (called from the scrolling tree) - void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& newScrollPosition, const Optional& layoutViewportOrigin, WebCore::ScrollingLayerPositionAction); - void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool representsProgrammaticScroll); + void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& newScrollPosition, const Optional& layoutViewportOrigin, WebCore::ScrollingLayerPositionAction, bool instantScrollDidStopAnimation = false); + void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool representsProgrammaticScroll, bool withAnimation = false); + + void scrollingTreeNodeIsScrollAnimationInProgressDidChange(WebCore::ScrollingNodeID, bool isScrollAnimationInProgress); + void scrollingTreeRootNodeIsScrollAnimationInProgressDidChange(bool isScrollAnimationInProgress); WebCore::TrackingType eventTrackingTypeForPoint(const AtomString& eventName, WebCore::IntPoint) const; @@ -80,6 +83,7 @@ public: struct RequestedScrollInfo { bool requestsScrollPositionUpdate { }; bool requestIsProgrammaticScroll { }; + bool requestWithAnimation { }; WebCore::FloatPoint requestedScrollPosition; }; void commitScrollingTreeState(const RemoteScrollingCoordinatorTransaction&, RequestedScrollInfo&); diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp index afabbc1eae31f86b9d4ab89f67545efedec550f2..385c2c661494322d23b2c1e6b983d8eccf6e2b6d 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp +++ b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp @@ -104,12 +104,12 @@ void RemoteScrollingTree::scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode& if (is(node)) layoutViewportOrigin = downcast(node).layoutViewport().location(); - m_scrollingCoordinatorProxy.scrollingTreeNodeDidScroll(node.scrollingNodeID(), node.currentScrollPosition(), layoutViewportOrigin, scrollingLayerPositionAction); + m_scrollingCoordinatorProxy.scrollingTreeNodeDidScroll(node.scrollingNodeID(), node.currentScrollPosition(), layoutViewportOrigin, scrollingLayerPositionAction, node.needsStopCurrentScrollAnimation() && !node.requestScrollWithAnimation()); } -void RemoteScrollingTree::scrollingTreeNodeRequestsScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, bool representsProgrammaticScroll) +void RemoteScrollingTree::scrollingTreeNodeRequestsScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, bool representsProgrammaticScroll, bool withAnimation) { - m_scrollingCoordinatorProxy.scrollingTreeNodeRequestsScroll(nodeID, scrollPosition, representsProgrammaticScroll); + m_scrollingCoordinatorProxy.scrollingTreeNodeRequestsScroll(nodeID, scrollPosition, representsProgrammaticScroll, withAnimation); } Ref RemoteScrollingTree::createScrollingTreeNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID) @@ -143,6 +143,11 @@ Ref RemoteScrollingTree::createScrollingTreeNode(ScrollingNod return ScrollingTreeFixedNode::create(*this, nodeID); } +void RemoteScrollingTree::scrollingTreeNodeIsScrollAnimationInProgressDidChange(WebCore::ScrollingNodeID nodeID, bool isScrollAnimationInProgress) +{ + m_scrollingCoordinatorProxy.scrollingTreeNodeIsScrollAnimationInProgressDidChange(nodeID, isScrollAnimationInProgress); +} + void RemoteScrollingTree::currentSnapPointIndicesDidChange(ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical) { m_scrollingCoordinatorProxy.currentSnapPointIndicesDidChange(nodeID, horizontal, vertical); diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h index 23bac06a3b96f2e88d5cebb71c0d5a7ce589ecf5..19200934e0df3b7e631710bd3442c54fa647b663 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h +++ b/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h @@ -52,7 +52,9 @@ public: const RemoteScrollingCoordinatorProxy& scrollingCoordinatorProxy() const { return m_scrollingCoordinatorProxy; } void scrollingTreeNodeDidScroll(WebCore::ScrollingTreeScrollingNode&, WebCore::ScrollingLayerPositionAction = WebCore::ScrollingLayerPositionAction::Sync) override; - void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool representsProgrammaticScroll) override; + void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool representsProgrammaticScroll, bool withAnimation = false) override; + + void scrollingTreeNodeIsScrollAnimationInProgressDidChange(WebCore::ScrollingNodeID, bool isScrollAnimationInProgress) override; void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical) override; diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h b/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h index e637d615325d380ce92d07a2b121913ff181dd2e..00b4dbcd370e18cdfd399ee76b13fb0543b33197 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h +++ b/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h @@ -57,6 +57,7 @@ public: void scrollDidEnd() const; void scrollViewWillStartPanGesture() const; void scrollViewDidScroll(const WebCore::FloatPoint& scrollOffset, bool inUserInteraction); + void scrollViewDidEndScrollingAnimation(); void currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical) const; CALayer *scrollLayer() const { return m_scrollLayer.get(); } diff --git a/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm b/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm index e7689837581b9d9b95bfea0376e1e491cef39a46..98895e7da248bad4cb799e70c72e6c310dc5860c 100644 --- a/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm +++ b/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm @@ -152,6 +152,11 @@ } } +- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView +{ + _scrollingTreeNodeDelegate->scrollViewDidEndScrollingAnimation(); +} + #if ENABLE(POINTER_EVENTS) - (CGPoint)_scrollView:(UIScrollView *)scrollView adjustedOffsetForOffset:(CGPoint)offset translation:(CGPoint)translation startPoint:(CGPoint)start locationInView:(CGPoint)locationInView horizontalVelocity:(inout double *)hv verticalVelocity:(inout double *)vv { @@ -300,15 +305,36 @@ void ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren(const Scrol if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { auto scrollType = scrollingStateNode.requestedScrollPositionRepresentsProgrammaticScroll() ? ScrollType::Programmatic : ScrollType::User; - scrollingNode().scrollTo(scrollingStateNode.requestedScrollPosition(), scrollType); + if (scrollingStateNode.requestedScrollPositionWithAnimation()) + scrollingNode().setRequestScrollWithAnimation(true); + // If the scroll positions are not same, there's a posibility that the scroll offset from web has been overriden. + // In this case, it need to sync the scroll offset back to Web side. + bool shouldSyncScrollPosition = scrollingStateNode.scrollPosition() != scrollingNode().currentScrollPosition(); + scrollingNode().scrollTo(scrollingStateNode.requestedScrollPosition(), scrollType, ScrollPositionClamp::ToContentEdges, shouldSyncScrollPosition); } } void ScrollingTreeScrollingNodeDelegateIOS::repositionScrollingLayers() { - BEGIN_BLOCK_OBJC_EXCEPTIONS - [scrollView() setContentOffset:scrollingNode().currentScrollOffset()]; - END_BLOCK_OBJC_EXCEPTIONS + bool animationInProgress = scrollingNode().scrollAnimationInProgress(); + bool needToStopAnimation = scrollingNode().needsStopCurrentScrollAnimation(); + if (needToStopAnimation && animationInProgress) { + BEGIN_BLOCK_OBJC_EXCEPTIONS + [scrollView() setContentOffset:scrollView().contentOffset animated:NO]; + END_BLOCK_OBJC_EXCEPTIONS + } + + if (scrollingNode().requestScrollWithAnimation()) { + BEGIN_BLOCK_OBJC_EXCEPTIONS + [scrollView() setContentOffset:scrollingNode().currentScrollOffset() animated:YES]; + END_BLOCK_OBJC_EXCEPTIONS + + scrollingNode().setScrollAnimationInProgress(true); + } else if (!animationInProgress || needToStopAnimation) { + BEGIN_BLOCK_OBJC_EXCEPTIONS + [scrollView() setContentOffset:scrollingNode().currentScrollOffset()]; + END_BLOCK_OBJC_EXCEPTIONS + } } void ScrollingTreeScrollingNodeDelegateIOS::scrollWillStart() const @@ -335,6 +361,15 @@ void ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll(const FloatPoint scrollingNode().wasScrolledByDelegatedScrolling(scrollPosition, { }, inUserInteraction ? ScrollingLayerPositionAction::Sync : ScrollingLayerPositionAction::Set); } +void ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidEndScrollingAnimation() +{ + auto& node = scrollingNode(); + if (!(node.requestScrollWithAnimation() && node.scrollAnimationInProgress())) { + scrollingTree().scrollingTreeNodeIsScrollAnimationInProgressDidChange(node.scrollingNodeID(), false); + node.setScrollAnimationInProgress(false); + } +} + void ScrollingTreeScrollingNodeDelegateIOS::currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical) const { if (m_updatingFromStateNode) diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp index 81b65c6e2db1d801b7c3e56751675aaf6c78fd78..9b5eb057dd5ae045f9c1531b0b96dfeb37ec575b 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit/UIProcess/WebPageProxy.cpp @@ -1731,9 +1731,12 @@ void WebPageProxy::setViewNeedsDisplay(const Region& region) pageClient().setViewNeedsDisplay(region); } -void WebPageProxy::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin) +void WebPageProxy::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, const bool withAnimation) { - pageClient().requestScroll(scrollPosition, scrollOrigin); + if (withAnimation) + pageClient().requestScrollWithAnimation(scrollPosition, scrollOrigin); + else + pageClient().requestScroll(scrollPosition, scrollOrigin); } WebCore::FloatPoint WebPageProxy::viewScrollPosition() const diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h index 488ac80306d59bdd65c4c1bd3468f3c0989b320b..ef109cd7e9f0e8a84d272770820a97bfe0071a83 100644 --- a/Source/WebKit/UIProcess/WebPageProxy.h +++ b/Source/WebKit/UIProcess/WebPageProxy.h @@ -612,7 +612,7 @@ public: PageClient& pageClient() const; void setViewNeedsDisplay(const WebCore::Region&); - void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin); + void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool withAnimation = false); WebCore::FloatPoint viewScrollPosition() const; diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.h b/Source/WebKit/UIProcess/ios/PageClientImplIOS.h index ea535257dfcdc601009ccb54cb0b2bbd80492fcc..2a7d20c1f050a5f4467c363bc9507ae9cd9a237a 100644 --- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.h +++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.h @@ -57,6 +57,7 @@ private: std::unique_ptr createDrawingAreaProxy(WebProcessProxy&) override; void setViewNeedsDisplay(const WebCore::Region&) override; void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin) override; + void requestScrollWithAnimation(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin) override; WebCore::FloatPoint viewScrollPosition() override; WebCore::IntSize viewSize() override; bool isViewWindowActive() override; diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm index e139968d4f0ee3323dd289f477dd8d641d77ec3a..537fd6051e356dc5171f17669871dba6af821e51 100644 --- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm +++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm @@ -95,7 +95,12 @@ void PageClientImpl::setViewNeedsDisplay(const Region&) void PageClientImpl::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin) { - [m_webView _scrollToContentScrollPosition:scrollPosition scrollOrigin:scrollOrigin]; + [m_webView _scrollToContentScrollPosition:scrollPosition scrollOrigin:scrollOrigin animated:NO]; +} + +void PageClientImpl::requestScrollWithAnimation(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin) +{ + [m_webView _scrollToContentScrollPosition:scrollPosition scrollOrigin:scrollOrigin animated:YES]; } WebCore::FloatPoint PageClientImpl::viewScrollPosition() diff --git a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h index 8e6493554583abf395d891acaabf015f17644597..d3bc9133ee0d4135713e1ced448a21b5261a50be 100644 --- a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h +++ b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h @@ -73,6 +73,8 @@ private: void scrollPositionChangedForNode(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool syncLayerPosition); void currentSnapPointIndicesChangedForNode(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical); + void scrollAnimationInProgressChangedForNode(WebCore::ScrollingNodeID, bool isScrollAnimationInProgress); + WebPage* m_webPage; }; diff --git a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in index 2c098a109702367c383371e88e5a761d45e199ad..d550cec2ca27dfcb58169fedd83db03f8810ca8d 100644 --- a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in +++ b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in @@ -25,6 +25,7 @@ messages -> RemoteScrollingCoordinator { ScrollPositionChangedForNode(uint64_t nodeID, WebCore::FloatPoint scrollPosition, bool syncLayerPosition); CurrentSnapPointIndicesChangedForNode(uint64_t nodeID, unsigned horizontal, unsigned vertical); + scrollAnimationInProgressChangedForNode(uint64_t nodeID, bool isScrollAnimationInProgress); } #endif // ENABLE(ASYNC_SCROLLING) diff --git a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm index 835441d319b95f466877585389092c9eea293861..a2d724596b6b9b5cd0d3123c2207c147d84c5c00 100644 --- a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm +++ b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm @@ -104,6 +104,11 @@ void RemoteScrollingCoordinator::currentSnapPointIndicesChangedForNode(Scrolling setActiveScrollSnapIndices(nodeID, horizontal, vertical); } +void RemoteScrollingCoordinator::scrollAnimationInProgressChangedForNode(WebCore::ScrollingNodeID nodeID, bool isScrollAnimationInProgress) +{ + setScrollAnimationInProgress(nodeID, isScrollAnimationInProgress); +} + } // namespace WebKit #endif // ENABLE(ASYNC_SCROLLING) diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h index 6b5ad1000969833dfbc365a4dfdffbd1c9c969e0..4c8aeb8b58c147f481e2d16d23a3f3104890f710 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h @@ -186,6 +186,7 @@ #define WebKitDirectoryUploadEnabledPreferenceKey @"WebKitDirectoryUploadEnabled" #define WebKitVisualViewportAPIEnabledPreferenceKey @"WebKitVisualViewportAPIEnabled" #define WebKitCSSOMViewScrollingAPIEnabledPreferenceKey @"WebKitCSSOMViewScrollingAPIEnabled" +#define WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey @"WebKitCSSOMViewSmoothScrollingEnabled" #define WebKitModernMediaControlsEnabledPreferenceKey @"WebKitModernMediaControlsEnabled" #define WebKitRemotePlaybackEnabledPreferenceKey @"WebKitRemotePlaybackEnabled" #define WebKitSubtleCryptoEnabledPreferenceKey @"WebKitSubtleCryptoEnabled" diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm index 836657313e6f7aa61b97f24edf88486093ff3c56..a20ec2b6b587ee630f07358958bc81a8464089db 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm +++ b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm @@ -658,6 +658,7 @@ public: #endif @YES, WebKitCSSOMViewScrollingAPIEnabledPreferenceKey, + @NO, WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey, @YES, WebKitNeedsStorageAccessFromFileURLsQuirkKey, @NO, WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey, #if ENABLE(MEDIA_STREAM) @@ -3166,6 +3167,16 @@ static NSString *classIBCreatorID = nil; [self _setBoolValue:flag forKey:WebKitCSSOMViewScrollingAPIEnabledPreferenceKey]; } +- (BOOL)CSSOMViewSmoothScrollingEnabled +{ + return [self _boolValueForKey:WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey]; +} + +- (void)setCSSOMViewSmoothScrollingEnabled:(BOOL)flag +{ + [self _setBoolValue:flag forKey:WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey]; +} + - (BOOL)webAnimationsEnabled { return [self _boolValueForKey:WebKitWebAnimationsEnabledPreferenceKey]; diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h b/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h index 81bdfe8cd48169141eccc3d45d7aeda67ecaef7c..2c2ca56c924afd0b8402e80996f765e355526432 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h @@ -626,6 +626,7 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification WEBKIT_DEPR @property (nonatomic) BOOL visualViewportAPIEnabled; @property (nonatomic) BOOL CSSOMViewScrollingAPIEnabled; +@property (nonatomic) BOOL CSSOMViewSmoothScrollingEnabled; @property (nonatomic) BOOL largeImageAsyncDecodingEnabled; @property (nonatomic) BOOL animatedImageAsyncDecodingEnabled; @property (nonatomic) BOOL javaScriptMarkupEnabled; diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm index 13efc27d0b90f4768096ef320abed1daa3f0e243..f428db88d7b940d275773028b52e62be08483cf2 100644 --- a/Source/WebKitLegacy/mac/WebView/WebView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm @@ -2992,6 +2992,7 @@ static bool needsSelfRetainWhileLoadingQuirk() settings.setVisualViewportAPIEnabled([preferences visualViewportAPIEnabled]); settings.setSyntheticEditingCommandsEnabled([preferences syntheticEditingCommandsEnabled]); settings.setCSSOMViewScrollingAPIEnabled([preferences CSSOMViewScrollingAPIEnabled]); + settings.setCSSOMViewSmoothScrollingEnabled([preferences CSSOMViewSmoothScrollingEnabled]); settings.setMediaContentTypesRequiringHardwareSupport([preferences mediaContentTypesRequiringHardwareSupport]); switch ([preferences storageBlockingPolicy]) { diff --git a/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl b/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl index 1f07581604515f8e9f1328200ff32e8f2023c7a3..598cd1281f81cfbb02cced615758204090597ed1 100644 --- a/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl +++ b/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl @@ -223,6 +223,8 @@ interface IWebPreferencesPrivate6 : IWebPreferencesPrivate5 HRESULT setVisualViewportAPIEnabled([in] BOOL enabled); HRESULT CSSOMViewScrollingAPIEnabled([out, retval] BOOL*); HRESULT setCSSOMViewScrollingAPIEnabled([in] BOOL enabled); + HRESULT CSSOMViewSmoothScrollingEnabled([out, retval] BOOL*); + HRESULT setCSSOMViewSmoothScrollingEnabled([in] BOOL enabled); HRESULT fetchAPIKeepAliveEnabled([out, retval] BOOL* enabled); HRESULT setFetchAPIKeepAliveEnabled([in] BOOL enabled); HRESULT spatialNavigationEnabled([out, retval] BOOL *enabled); diff --git a/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h b/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h index 447fd9f4b55ac86bc66c92a09f8856a455c06a87..bb8a75702ca30d70d9adad73cc70257dc5e4feee 100644 --- a/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h @@ -207,6 +207,7 @@ #define WebKitServerTimingEnabledPreferenceKey "WebKitServerTimingEnabled" #define WebKitCSSOMViewScrollingAPIEnabledPreferenceKey "WebKitCSSOMViewScrollingAPIEnabled" +#define WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey "WebKitCSSOMViewSmoothScrollingEnabled" #define WebKitResizeObserverEnabledPreferenceKey "WebKitResizeObserverEnabled" diff --git a/Source/WebKitLegacy/win/WebPreferences.cpp b/Source/WebKitLegacy/win/WebPreferences.cpp index 9a78426b295be6592677e9074b976efcaf3b913e..b6ae6e1b82ccb4e7a0bfe0e2d1fc6e7cc199e760 100644 --- a/Source/WebKitLegacy/win/WebPreferences.cpp +++ b/Source/WebKitLegacy/win/WebPreferences.cpp @@ -337,6 +337,8 @@ void WebPreferences::initializeDefaultSettings() CFDictionaryAddValue(defaults, CFSTR(WebKitResizeObserverEnabledPreferenceKey), kCFBooleanFalse); + CFDictionaryAddValue(defaults, CFSTR(WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey), kCFBooleanFalse); + CFDictionaryAddValue(defaults, CFSTR(WebKitCoreMathMLEnabledPreferenceKey), kCFBooleanFalse); CFDictionaryAddValue(defaults, CFSTR(WebKitRequestIdleCallbackEnabledPreferenceKey), kCFBooleanFalse); @@ -2280,6 +2282,20 @@ HRESULT WebPreferences::setCoreMathMLEnabled(BOOL enabled) setBoolValue(WebKitCoreMathMLEnabledPreferenceKey, enabled); return S_OK; } + +HRESULT WebPreferences::CSSOMViewSmoothScrollingEnabled(_Out_ BOOL* enabled) +{ + if (!enabled) + return E_POINTER; + *enabled = boolValueForKey(WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey); + return S_OK; +} + +HRESULT WebPreferences::setCSSOMViewSmoothScrollingEnabled(BOOL enabled) +{ + setBoolValue(WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey, enabled); + return S_OK; +} HRESULT WebPreferences::requestIdleCallbackEnabled(_Out_ BOOL* enabled) { diff --git a/Source/WebKitLegacy/win/WebPreferences.h b/Source/WebKitLegacy/win/WebPreferences.h index 22bb1b3ddf662512b08ab537e86259683e1a306d..de59d529c3231f7e7c86b4450a2de2e914b368a8 100644 --- a/Source/WebKitLegacy/win/WebPreferences.h +++ b/Source/WebKitLegacy/win/WebPreferences.h @@ -271,6 +271,8 @@ public: virtual HRESULT STDMETHODCALLTYPE setVisualViewportAPIEnabled(BOOL); virtual HRESULT STDMETHODCALLTYPE CSSOMViewScrollingAPIEnabled(_Out_ BOOL*); virtual HRESULT STDMETHODCALLTYPE setCSSOMViewScrollingAPIEnabled(BOOL); + virtual HRESULT STDMETHODCALLTYPE CSSOMViewSmoothScrollingEnabled(_Out_ BOOL*); + virtual HRESULT STDMETHODCALLTYPE setCSSOMViewSmoothScrollingEnabled(BOOL); virtual HRESULT STDMETHODCALLTYPE fetchAPIKeepAliveEnabled(_Out_ BOOL*); virtual HRESULT STDMETHODCALLTYPE setFetchAPIKeepAliveEnabled(BOOL); virtual HRESULT STDMETHODCALLTYPE spatialNavigationEnabled(_Out_ BOOL*); diff --git a/Source/WebKitLegacy/win/WebView.cpp b/Source/WebKitLegacy/win/WebView.cpp index 23bf4b452bd3819aabac7c8f5ba608223f8c5336..7bd6c9e6cdf427e05209ac3603a0bff113791bf4 100644 --- a/Source/WebKitLegacy/win/WebView.cpp +++ b/Source/WebKitLegacy/win/WebView.cpp @@ -5298,6 +5298,11 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification) return hr; settings.setCSSOMViewScrollingAPIEnabled(!!enabled); + hr = prefsPrivate->CSSOMViewSmoothScrollingEnabled(&enabled); + if (FAILED(hr)) + return hr; + settings.setCSSOMViewSmoothScrollingEnabled(!!enabled); + hr = preferences->privateBrowsingEnabled(&enabled); if (FAILED(hr)) return hr; diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 648381df8646f572aac2c9b1ab12aca6fed33dd1..9e8f5be7f479fb4ed10ba00f705491133be8e15b 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,16 @@ +2018-11-06 Frederic Wang + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + + Reviewed by NOBODY (OOPS!). + + * DumpRenderTree/TestOptions.cpp: + (TestOptions::TestOptions): Parse CSSOMViewSmoothScrollingEnabled. + * DumpRenderTree/TestOptions.h: Add CSSOMViewSmoothScrollingEnabled, disabled by default. + * DumpRenderTree/mac/DumpRenderTree.mm: + (setWebPreferencesForTestOptions): Set CSSOMViewSmoothScrollingEnabled from the test options. + 2019-11-25 Kent Tamura Remove tkent@ from watchlist diff --git a/Tools/DumpRenderTree/TestOptions.cpp b/Tools/DumpRenderTree/TestOptions.cpp index 556eec276637e81b93f77d9659375cfc2a495959..99bb2ba3322b1aca78311bc881950a471f5f94bc 100644 --- a/Tools/DumpRenderTree/TestOptions.cpp +++ b/Tools/DumpRenderTree/TestOptions.cpp @@ -121,6 +121,8 @@ TestOptions::TestOptions(const std::string& pathOrURL, const std::string& absolu adClickAttributionEnabled = parseBooleanTestHeaderValue(value); else if (key == "experimental:ResizeObserverEnabled") enableResizeObserver = parseBooleanTestHeaderValue(value); + else if (key == "experimental:CSSOMViewSmoothScrollingEnabled") + enableCSSOMViewSmoothScrolling = parseBooleanTestHeaderValue(value); else if (key == "experimental:CoreMathMLEnabled") enableCoreMathML = parseBooleanTestHeaderValue(value); else if (key == "experimental:RequestIdleCallbackEnabled") diff --git a/Tools/DumpRenderTree/TestOptions.h b/Tools/DumpRenderTree/TestOptions.h index e5335e83114e79e5b54d861c3d23ffcebba70a0b..f7e8d2911d13035e66c1965b7706428ddfea9aae 100644 --- a/Tools/DumpRenderTree/TestOptions.h +++ b/Tools/DumpRenderTree/TestOptions.h @@ -50,6 +50,7 @@ struct TestOptions { bool enableCSSLogical { false }; bool adClickAttributionEnabled { false }; bool enableResizeObserver { false }; + bool enableCSSOMViewSmoothScrolling { false }; bool enableCoreMathML { false }; bool enableRequestIdleCallback { false }; bool enableAsyncClipboardAPI { false }; diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm index 2ca08bf7bbf7a6d3a061f71674c53cc695da74b0..03e796b0588b0d32c3e0f8df640ff109e9e4ff5e 100644 --- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm @@ -1027,6 +1027,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options) preferences.CSSLogicalEnabled = options.enableCSSLogical; preferences.adClickAttributionEnabled = options.adClickAttributionEnabled; preferences.resizeObserverEnabled = options.enableResizeObserver; + preferences.CSSOMViewSmoothScrollingEnabled = options.enableCSSOMViewSmoothScrolling; preferences.coreMathMLEnabled = options.enableCoreMathML; preferences.requestIdleCallbackEnabled = options.enableRequestIdleCallback; preferences.asyncClipboardAPIEnabled = options.enableAsyncClipboardAPI; diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 09aa1cefb05e3e60b478206d57ffef6f26202275..bbdf261040d169cdb79091d51cdda3a710ea3101 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,37 @@ +2018-11-07 Frederic Wang + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + The scroll animation on iOS platform is using native scroll animation which need enable + AsyncOverflowScrollingEnabled and AsyncFrameScrollingEnabled. In order to test properly, + copy scroll-behavior test to fast/scrolling/ios/ + + Reviewed by NOBODY (OOPS!). + + * fast/scrolling/ios/resources/scroll-behavior.js: Added. + (observeScrolling): + (waitForScrollEnd): + (scrollNode): + (scrollWindow): + * fast/scrolling/ios/scroll-behavior-default-css-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-default-css.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css.html. + * fast/scrolling/ios/scroll-behavior-element-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-element.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element.html. + * fast/scrolling/ios/scroll-behavior-main-frame-root-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-main-frame-root.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html. + * fast/scrolling/ios/scroll-behavior-main-frame-window-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-main-frame-window.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html. + * fast/scrolling/ios/scroll-behavior-scrollintoview-nested-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-scrollintoview-nested.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested.html. + * fast/scrolling/ios/scroll-behavior-smooth-positions-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-smooth-positions.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth-positions.html. + * fast/scrolling/ios/scroll-behavior-subframe-root-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-subframe-root.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html. + * fast/scrolling/ios/scroll-behavior-subframe-window-expected.txt: Added. + * fast/scrolling/ios/scroll-behavior-subframe-window.html: Copied from LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html. + * platform/mac-wk1/TestExpectations: Skip these tests on WK1 as they don't work for now and + are slow anyway. + 2019-11-26 Alejandro G. Castro [GTK][WPE] New tests crashing after added in the r251377 diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog index 9f2d7cef401683b0c753d6fba06c997fe5c90d88..36741b93ea581885d7896bb4f5d1632903d7ff7f 100644 --- a/LayoutTests/imported/w3c/ChangeLog +++ b/LayoutTests/imported/w3c/ChangeLog @@ -1,3 +1,27 @@ +2018-11-06 Frederic Wang + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + + Reviewed by NOBODY (OOPS!). + Enable CSSOMViewSmoothScrollingEnabled on scroll behavior tests and update expectations. + + * web-platform-tests/css/cssom-view/scroll-behavior-default-css-expected.txt: + * web-platform-tests/css/cssom-view/scroll-behavior-default-css.html: + * web-platform-tests/css/cssom-view/scroll-behavior-element-expected.txt: + * web-platform-tests/css/cssom-view/scroll-behavior-element.html: + * web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root-expected.txt: + * web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html: + * web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window-expected.txt: + * web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html: + * web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested-expected.txt: + * web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested.html: + * web-platform-tests/css/cssom-view/scroll-behavior-smooth-positions.html: + * web-platform-tests/css/cssom-view/scroll-behavior-subframe-root-expected.txt: + * web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html: + * web-platform-tests/css/cssom-view/scroll-behavior-subframe-window-expected.txt: + * web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html: + 2019-11-26 Manuel Rego Casasnovas [css-grid] Avoid serializing [] in grid-template* specified values @@ -4310,7 +4334,7 @@ (@charset "windows-1250";): * web-platform-tests/css/css-syntax/charset/support/http-bogus-at-charset-windows-1250.bogus.css.headers: Added. * web-platform-tests/css/css-syntax/charset/support/http-bogus.bogus.css: Added. - (#È): + (#�): * web-platform-tests/css/css-syntax/charset/support/http-bogus.bogus.css.headers: Added. * web-platform-tests/css/css-syntax/charset/support/http-windows-1250-at-charset-windows-1253.windows1250.css: Added. (@charset "windows-1253";): @@ -4318,9 +4342,9 @@ * web-platform-tests/css/css-syntax/charset/support/no-decl-ascii-only.css: Added. (#foo): * web-platform-tests/css/css-syntax/charset/support/no-decl.css: Added. - (#È): + (#�): * web-platform-tests/css/css-syntax/charset/support/utf8-bom.css: Added. - (#È): + (#�): * web-platform-tests/css/css-syntax/charset/support/w3c-import.log: Added. * web-platform-tests/css/css-syntax/charset/w3c-import.log: Added. * web-platform-tests/css/css-syntax/charset/xml-stylesheet-page-windows-1251-charset-attribute-windows-1250-expected.txt: Added. diff --git a/LayoutTests/fast/scrolling/ios/resources/scroll-behavior.js b/LayoutTests/fast/scrolling/ios/resources/scroll-behavior.js new file mode 100644 index 0000000000000000000000000000000000000000..0a0968e025bd8604c0765352d3a2e8b3cc1233aa --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/resources/scroll-behavior.js @@ -0,0 +1,87 @@ +function observeScrolling(elements, callback) { + if (!Array.isArray(elements)) + elements = [elements]; + var lastChangedFrame = 0; + var lastLeft = new Map(); + var lastTop = new Map(); + elements.forEach((element) => { + lastLeft.set(element, element.scrollLeft); + lastTop.set(element, element.scrollTop); + }); + function tick(frames) { + // We requestAnimationFrame either for 500 frames or until 20 frames with + // no change have been observed. + if (frames >= 500 || frames - lastChangedFrame > 20) { + callback(true); + } else { + var scrollHappened = elements.some((element) => { + return element.scrollLeft != lastLeft.get(element) || element.scrollTop != lastTop.get(element); + }); + if (scrollHappened) { + lastChangedFrame = frames; + elements.forEach((element) => { + lastLeft.set(element, element.scrollLeft); + lastTop.set(element, element.scrollTop); + }); + callback(false); + } + requestAnimationFrame(tick.bind(null, frames + 1)); + } + } + tick(0); +} + +function waitForScrollEnd(elements) { + return new Promise((resolve) => { + observeScrolling(elements, (done) => { + if (done) + resolve(); + }); + }); +} + +function resetScroll(scrollingElement) { + // Try various methods to ensure the element position is reset immediately. + scrollingElement.scrollLeft = 0; + scrollingElement.scrollTop = 0; + scrollingElement.scroll({left: 0, top: 0, behavior: "instant"}); +} + +function resetScrollForWindow(scrollingWindow) { + // Try various methods to ensure the element position is reset immediately. + scrollingWindow.document.scrollingElement.scrollLeft = 0; + scrollingWindow.document.scrollingElement.scrollTop = 0; + scrollingWindow.scroll({left: 0, top: 0, behavior: "instant"}); +} + +function setScrollBehavior(styledElement, className) { + styledElement.classList.remove("autoBehavior", "smoothBehavior"); + styledElement.classList.add(className); +} + +function scrollNode(scrollingElement, scrollFunction, behavior, elementToRevealLeft, elementToRevealTop) { + var args = {}; + if (behavior) + args.behavior = behavior; + switch (scrollFunction) { + case "scrollIntoView": + args.inline = "start"; + args.block = "start"; + elementToReveal.scrollIntoView(args); + break; + default: + args.left = elementToRevealLeft; + args.top = elementToRevealTop; + scrollingElement[scrollFunction](args); + break; + } +} + +function scrollWindow(scrollingWindow, scrollFunction, behavior, elementToRevealLeft, elementToRevealTop) { + var args = {}; + if (behavior) + args.behavior = behavior; + args.left = elementToRevealLeft; + args.top = elementToRevealTop; + scrollingWindow[scrollFunction](args); +} diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-default-css-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-default-css-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8d4ca64155f4f9de8f9e1093d9b1712f417ce690 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-default-css-expected.txt @@ -0,0 +1,4 @@ + +PASS Instant scrolling of an element with default scroll-behavior +PASS Smooth scrolling of an element with default scroll-behavior + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-default-css.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-default-css.html new file mode 100644 index 0000000000000000000000000000000000000000..35c6503ab265035d008c6006685d6cc137181d8a --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-default-css.html @@ -0,0 +1,52 @@ + +Testing default value of scroll-behavior + + + + + + + + +
+
+
+
+ +
+
+ diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-element-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-element-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..53a961ef56a91857c6d2cabb90848c5b2d9f0662 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-element-expected.txt @@ -0,0 +1,36 @@ + +PASS Element with auto scroll-behavior ; scroll() with default behavior +PASS Element with auto scroll-behavior ; scroll() with auto behavior +PASS Element with auto scroll-behavior ; scroll() with instant behavior +PASS Element with auto scroll-behavior ; scroll() with smooth behavior +PASS Element with smooth scroll-behavior ; scroll() with default behavior +PASS Element with smooth scroll-behavior ; scroll() with auto behavior +PASS Element with smooth scroll-behavior ; scroll() with instant behavior +PASS Element with smooth scroll-behavior ; scroll() with smooth behavior +PASS Element with auto scroll-behavior ; scrollTo() with default behavior +PASS Element with auto scroll-behavior ; scrollTo() with auto behavior +PASS Element with auto scroll-behavior ; scrollTo() with instant behavior +PASS Element with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Element with smooth scroll-behavior ; scrollTo() with default behavior +PASS Element with smooth scroll-behavior ; scrollTo() with auto behavior +PASS Element with smooth scroll-behavior ; scrollTo() with instant behavior +PASS Element with smooth scroll-behavior ; scrollTo() with smooth behavior +PASS Element with auto scroll-behavior ; scrollBy() with default behavior +PASS Element with auto scroll-behavior ; scrollBy() with auto behavior +PASS Element with auto scroll-behavior ; scrollBy() with instant behavior +PASS Element with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Element with smooth scroll-behavior ; scrollBy() with default behavior +PASS Element with smooth scroll-behavior ; scrollBy() with auto behavior +PASS Element with smooth scroll-behavior ; scrollBy() with instant behavior +PASS Element with smooth scroll-behavior ; scrollBy() with smooth behavior +PASS Element with auto scroll-behavior ; scrollIntoView() with default behavior +PASS Element with auto scroll-behavior ; scrollIntoView() with auto behavior +PASS Element with auto scroll-behavior ; scrollIntoView() with instant behavior +PASS Element with auto scroll-behavior ; scrollIntoView() with smooth behavior +PASS Element with smooth scroll-behavior ; scrollIntoView() with default behavior +PASS Element with smooth scroll-behavior ; scrollIntoView() with auto behavior +PASS Element with smooth scroll-behavior ; scrollIntoView() with instant behavior +PASS Element with smooth scroll-behavior ; scrollIntoView() with smooth behavior +PASS Aborting an ongoing smooth scrolling on an element with another smooth scrolling +PASS Aborting an ongoing smooth scrolling on an element with an instant scrolling + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-element.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-element.html new file mode 100644 index 0000000000000000000000000000000000000000..d38dffdece59b3750e96f1a2862c5e9497a4238b --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-element.html @@ -0,0 +1,163 @@ + +Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on an element + + + + + + + + +
+
+
+
+ +
+
+ diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-root-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-root-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..97caea27bb53f1a944dca2d6817a3efb85fca772 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-root-expected.txt @@ -0,0 +1,37 @@ + +PASS Page loaded +PASS Main frame with auto scroll-behavior ; scroll() with default behavior +PASS Main frame with auto scroll-behavior ; scroll() with auto behavior +PASS Main frame with auto scroll-behavior ; scroll() with instant behavior +PASS Main frame with auto scroll-behavior ; scroll() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scroll() with default behavior +PASS Main frame with smooth scroll-behavior ; scroll() with auto behavior +PASS Main frame with smooth scroll-behavior ; scroll() with instant behavior +PASS Main frame with smooth scroll-behavior ; scroll() with smooth behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with default behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with auto behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with instant behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with auto behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with instant behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with default behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with auto behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with instant behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with auto behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with instant behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior +PASS Main frame with auto scroll-behavior ; scrollIntoView() with default behavior +PASS Main frame with auto scroll-behavior ; scrollIntoView() with auto behavior +PASS Main frame with auto scroll-behavior ; scrollIntoView() with instant behavior +PASS Main frame with auto scroll-behavior ; scrollIntoView() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollIntoView() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollIntoView() with auto behavior +PASS Main frame with smooth scroll-behavior ; scrollIntoView() with instant behavior +PASS Main frame with smooth scroll-behavior ; scrollIntoView() with smooth behavior +PASS Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling +PASS Aborting an ongoing smooth scrolling on the main frame with an instant scrolling + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-root.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-root.html new file mode 100644 index 0000000000000000000000000000000000000000..d325b4b9e24ef7db7ba69804be2b57f738a369db --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-root.html @@ -0,0 +1,169 @@ + +Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on the root of the main frame + + + + + + + + +
+
+
+
+
+ diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-window-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-window-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..382385aab493514bde7bb595a79a741402640438 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-window-expected.txt @@ -0,0 +1,29 @@ + +PASS Page loaded +PASS Main frame with auto scroll-behavior ; scroll() with default behavior +PASS Main frame with auto scroll-behavior ; scroll() with auto behavior +PASS Main frame with auto scroll-behavior ; scroll() with instant behavior +PASS Main frame with auto scroll-behavior ; scroll() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scroll() with default behavior +PASS Main frame with smooth scroll-behavior ; scroll() with auto behavior +PASS Main frame with smooth scroll-behavior ; scroll() with instant behavior +PASS Main frame with smooth scroll-behavior ; scroll() with smooth behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with default behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with auto behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with instant behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with auto behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with instant behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with default behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with auto behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with instant behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with auto behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with instant behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior +PASS Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling +PASS Aborting an ongoing smooth scrolling on the main frame with an instant scrolling + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-window.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-window.html new file mode 100644 index 0000000000000000000000000000000000000000..9057b0cd1219102aeda00845915569bb7e0ad0d7 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-main-frame-window.html @@ -0,0 +1,170 @@ + +Testing scrollOptions' behavior for Element.scroll* on the window of the main frame + + + + + + + + + +
+
+
+
+
+ diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-scrollintoview-nested-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-scrollintoview-nested-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..443a820e58596d56e3fe892119be03dc48d0b95f --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-scrollintoview-nested-expected.txt @@ -0,0 +1,3 @@ + +PASS scrollIntoView with nested elements with different scroll-behavior + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-scrollintoview-nested.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-scrollintoview-nested.html new file mode 100644 index 0000000000000000000000000000000000000000..45b5d8d7c78445a0d2c072fa17d7fc8c196ce54c --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-scrollintoview-nested.html @@ -0,0 +1,88 @@ + +Testing scrollOptions' behavior with scrollIntoView for nested scrolling nodes + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-smooth-positions-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-smooth-positions-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..855a6a610f3731ac7edfdb0e2dda38b058ec91d0 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-smooth-positions-expected.txt @@ -0,0 +1,20 @@ + +PASS Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scroll() +PASS Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scroll() +PASS Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scroll() +PASS Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scroll() +PASS Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollTo() +PASS Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollTo() +PASS Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollTo() +PASS Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scrollTo() +PASS Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollBy() +PASS Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollBy() +PASS Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollBy() +PASS Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scrollBy() +PASS Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollIntoView() +PASS Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollIntoView() +PASS Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollIntoView() +PASS Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scrollIntoView() +PASS Scroll positions when aborting a smooth scrolling with another smooth scrolling +PASS Scroll positions when aborting a smooth scrolling with an instant scrolling + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-smooth-positions.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-smooth-positions.html new file mode 100644 index 0000000000000000000000000000000000000000..0a41b8b08daf213a9f9a85ff0a40df5cda14e6a0 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-smooth-positions.html @@ -0,0 +1,151 @@ + +Testing scroll positions when scrolling an element with smooth behavior + + + + + + + + +
+
+
+
+ +
+
+ diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-root-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-root-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..2799fdcc29ed56337a89121b0590a09b7bef5c06 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-root-expected.txt @@ -0,0 +1,37 @@ + +PASS iframe loaded +PASS Subframe with auto scroll-behavior ; scroll() with default behavior +PASS Subframe with auto scroll-behavior ; scroll() with auto behavior +PASS Subframe with auto scroll-behavior ; scroll() with instant behavior +PASS Subframe with auto scroll-behavior ; scroll() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scroll() with default behavior +PASS Subframe with smooth scroll-behavior ; scroll() with auto behavior +PASS Subframe with smooth scroll-behavior ; scroll() with instant behavior +PASS Subframe with smooth scroll-behavior ; scroll() with smooth behavior +PASS Subframe with auto scroll-behavior ; scrollTo() with default behavior +PASS Subframe with auto scroll-behavior ; scrollTo() with auto behavior +PASS Subframe with auto scroll-behavior ; scrollTo() with instant behavior +PASS Subframe with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scrollTo() with default behavior +PASS Subframe with smooth scroll-behavior ; scrollTo() with auto behavior +PASS Subframe with smooth scroll-behavior ; scrollTo() with instant behavior +PASS Subframe with smooth scroll-behavior ; scrollTo() with smooth behavior +PASS Subframe with auto scroll-behavior ; scrollBy() with default behavior +PASS Subframe with auto scroll-behavior ; scrollBy() with auto behavior +PASS Subframe with auto scroll-behavior ; scrollBy() with instant behavior +PASS Subframe with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scrollBy() with default behavior +PASS Subframe with smooth scroll-behavior ; scrollBy() with auto behavior +PASS Subframe with smooth scroll-behavior ; scrollBy() with instant behavior +PASS Subframe with smooth scroll-behavior ; scrollBy() with smooth behavior +PASS Subframe with auto scroll-behavior ; scrollIntoView() with default behavior +PASS Subframe with auto scroll-behavior ; scrollIntoView() with auto behavior +PASS Subframe with auto scroll-behavior ; scrollIntoView() with instant behavior +PASS Subframe with auto scroll-behavior ; scrollIntoView() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scrollIntoView() with default behavior +PASS Subframe with smooth scroll-behavior ; scrollIntoView() with auto behavior +PASS Subframe with smooth scroll-behavior ; scrollIntoView() with instant behavior +PASS Subframe with smooth scroll-behavior ; scrollIntoView() with smooth behavior +PASS Aborting an ongoing smooth scrolling on a subframe with another smooth scrolling +PASS Aborting an ongoing smooth scrolling on a subframe with an instant scrolling + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-root.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-root.html new file mode 100644 index 0000000000000000000000000000000000000000..96d11ab962163478429f6f8a8a7a4c222b2ef157 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-root.html @@ -0,0 +1,170 @@ + +Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on the root of a subframe + + + + + + + +
+
+ + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-window-expected.txt b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-window-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..05eb3272f408e5e64d1bb7ec2a07e0bfcc904744 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-window-expected.txt @@ -0,0 +1,29 @@ + +PASS iframe loaded +PASS Main frame with auto scroll-behavior ; scroll() with default behavior +PASS Main frame with auto scroll-behavior ; scroll() with auto behavior +PASS Main frame with auto scroll-behavior ; scroll() with instant behavior +PASS Main frame with auto scroll-behavior ; scroll() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scroll() with default behavior +PASS Main frame with smooth scroll-behavior ; scroll() with auto behavior +PASS Main frame with smooth scroll-behavior ; scroll() with instant behavior +PASS Main frame with smooth scroll-behavior ; scroll() with smooth behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with default behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with auto behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with instant behavior +PASS Main frame with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with auto behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with instant behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with default behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with auto behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with instant behavior +PASS Main frame with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with auto behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with instant behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior +PASS Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling +PASS Aborting an ongoing smooth scrolling on the main frame with an instant scrolling + diff --git a/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-window.html b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-window.html new file mode 100644 index 0000000000000000000000000000000000000000..3333d64f85071670bd47bce86b06559682504937 --- /dev/null +++ b/LayoutTests/fast/scrolling/ios/scroll-behavior-subframe-window.html @@ -0,0 +1,171 @@ + +Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on the root of a subframe + + + + + + + +
+
+ + diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/inheritance-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/inheritance-expected.txt index 3ac0a37cffbd5a155ccebc52728ae6f2130b9414..875a727c9588704463616ea6035e5570e09bd042 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/inheritance-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/inheritance-expected.txt @@ -1,4 +1,4 @@ -FAIL Property scroll-behavior has initial value auto assert_true: scroll-behavior doesn't seem to be supported in the computed style expected true got false -FAIL Property scroll-behavior does not inherit assert_true: expected true got false +PASS Property scroll-behavior has initial value auto +PASS Property scroll-behavior does not inherit diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css-expected.txt index 9068b7975527cf47edde7510498db17a1513bd44..8d4ca64155f4f9de8f9e1093d9b1712f417ce690 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css-expected.txt @@ -1,4 +1,4 @@ PASS Instant scrolling of an element with default scroll-behavior -FAIL Smooth scrolling of an element with default scroll-behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Smooth scrolling of an element with default scroll-behavior diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css.html index 6925cf092c6f2efd455233f2e647cd132a3630f2..fe475b039f5f5a886deeb1cac6e08b9e0e0ac610 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-default-css.html @@ -1,4 +1,4 @@ - + Testing default value of scroll-behavior diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element-expected.txt index 2b9129c1cf48cea7cf8b63c39c8a34962e234970..53a961ef56a91857c6d2cabb90848c5b2d9f0662 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element-expected.txt @@ -2,35 +2,35 @@ PASS Element with auto scroll-behavior ; scroll() with default behavior PASS Element with auto scroll-behavior ; scroll() with auto behavior PASS Element with auto scroll-behavior ; scroll() with instant behavior -FAIL Element with auto scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scroll() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scroll() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with auto scroll-behavior ; scroll() with smooth behavior +PASS Element with smooth scroll-behavior ; scroll() with default behavior +PASS Element with smooth scroll-behavior ; scroll() with auto behavior PASS Element with smooth scroll-behavior ; scroll() with instant behavior -FAIL Element with smooth scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with smooth scroll-behavior ; scroll() with smooth behavior PASS Element with auto scroll-behavior ; scrollTo() with default behavior PASS Element with auto scroll-behavior ; scrollTo() with auto behavior PASS Element with auto scroll-behavior ; scrollTo() with instant behavior -FAIL Element with auto scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scrollTo() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scrollTo() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Element with smooth scroll-behavior ; scrollTo() with default behavior +PASS Element with smooth scroll-behavior ; scrollTo() with auto behavior PASS Element with smooth scroll-behavior ; scrollTo() with instant behavior -FAIL Element with smooth scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with smooth scroll-behavior ; scrollTo() with smooth behavior PASS Element with auto scroll-behavior ; scrollBy() with default behavior PASS Element with auto scroll-behavior ; scrollBy() with auto behavior PASS Element with auto scroll-behavior ; scrollBy() with instant behavior -FAIL Element with auto scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scrollBy() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scrollBy() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Element with smooth scroll-behavior ; scrollBy() with default behavior +PASS Element with smooth scroll-behavior ; scrollBy() with auto behavior PASS Element with smooth scroll-behavior ; scrollBy() with instant behavior -FAIL Element with smooth scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with smooth scroll-behavior ; scrollBy() with smooth behavior PASS Element with auto scroll-behavior ; scrollIntoView() with default behavior PASS Element with auto scroll-behavior ; scrollIntoView() with auto behavior PASS Element with auto scroll-behavior ; scrollIntoView() with instant behavior -FAIL Element with auto scroll-behavior ; scrollIntoView() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scrollIntoView() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Element with smooth scroll-behavior ; scrollIntoView() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with auto scroll-behavior ; scrollIntoView() with smooth behavior +PASS Element with smooth scroll-behavior ; scrollIntoView() with default behavior +PASS Element with smooth scroll-behavior ; scrollIntoView() with auto behavior PASS Element with smooth scroll-behavior ; scrollIntoView() with instant behavior -FAIL Element with smooth scroll-behavior ; scrollIntoView() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Element with smooth scroll-behavior ; scrollIntoView() with smooth behavior PASS Aborting an ongoing smooth scrolling on an element with another smooth scrolling PASS Aborting an ongoing smooth scrolling on an element with an instant scrolling diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element.html index 3cbd722f724d003636bba3aa16ea4d10f1b4e124..6c15929c9f2de8e455e59b01f9294d7549440af0 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-element.html @@ -1,4 +1,4 @@ - + Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on an element diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root-expected.txt index d922258af27b71b56805884f26c915cdb9eed6e0..97caea27bb53f1a944dca2d6817a3efb85fca772 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root-expected.txt @@ -3,35 +3,35 @@ PASS Page loaded PASS Main frame with auto scroll-behavior ; scroll() with default behavior PASS Main frame with auto scroll-behavior ; scroll() with auto behavior PASS Main frame with auto scroll-behavior ; scroll() with instant behavior -FAIL Main frame with auto scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scroll() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scroll() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with auto scroll-behavior ; scroll() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scroll() with default behavior +PASS Main frame with smooth scroll-behavior ; scroll() with auto behavior PASS Main frame with smooth scroll-behavior ; scroll() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with smooth scroll-behavior ; scroll() with smooth behavior PASS Main frame with auto scroll-behavior ; scrollTo() with default behavior PASS Main frame with auto scroll-behavior ; scrollTo() with auto behavior PASS Main frame with auto scroll-behavior ; scrollTo() with instant behavior -FAIL Main frame with auto scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollTo() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollTo() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with auto behavior PASS Main frame with smooth scroll-behavior ; scrollTo() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior PASS Main frame with auto scroll-behavior ; scrollBy() with default behavior PASS Main frame with auto scroll-behavior ; scrollBy() with auto behavior PASS Main frame with auto scroll-behavior ; scrollBy() with instant behavior -FAIL Main frame with auto scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollBy() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollBy() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with auto behavior PASS Main frame with smooth scroll-behavior ; scrollBy() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior PASS Main frame with auto scroll-behavior ; scrollIntoView() with default behavior PASS Main frame with auto scroll-behavior ; scrollIntoView() with auto behavior PASS Main frame with auto scroll-behavior ; scrollIntoView() with instant behavior -FAIL Main frame with auto scroll-behavior ; scrollIntoView() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollIntoView() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollIntoView() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with auto scroll-behavior ; scrollIntoView() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollIntoView() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollIntoView() with auto behavior PASS Main frame with smooth scroll-behavior ; scrollIntoView() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scrollIntoView() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with smooth scroll-behavior ; scrollIntoView() with smooth behavior PASS Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling PASS Aborting an ongoing smooth scrolling on the main frame with an instant scrolling diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html index fcf75aa1ddbd22de423d63e536f58c4bc08e7682..6d9b2242eaf6648d31fc14796aa5ab9dc4c0f11d 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html @@ -1,4 +1,4 @@ - + Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on the root of the main frame diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window-expected.txt index c6be96661c2938eb9db38a11a46757316748cb1d..382385aab493514bde7bb595a79a741402640438 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window-expected.txt @@ -3,27 +3,27 @@ PASS Page loaded PASS Main frame with auto scroll-behavior ; scroll() with default behavior PASS Main frame with auto scroll-behavior ; scroll() with auto behavior PASS Main frame with auto scroll-behavior ; scroll() with instant behavior -FAIL Main frame with auto scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scroll() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scroll() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with auto scroll-behavior ; scroll() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scroll() with default behavior +PASS Main frame with smooth scroll-behavior ; scroll() with auto behavior PASS Main frame with smooth scroll-behavior ; scroll() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with smooth scroll-behavior ; scroll() with smooth behavior PASS Main frame with auto scroll-behavior ; scrollTo() with default behavior PASS Main frame with auto scroll-behavior ; scrollTo() with auto behavior PASS Main frame with auto scroll-behavior ; scrollTo() with instant behavior -FAIL Main frame with auto scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollTo() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollTo() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with auto behavior PASS Main frame with smooth scroll-behavior ; scrollTo() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior PASS Main frame with auto scroll-behavior ; scrollBy() with default behavior PASS Main frame with auto scroll-behavior ; scrollBy() with auto behavior PASS Main frame with auto scroll-behavior ; scrollBy() with instant behavior -FAIL Main frame with auto scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollBy() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 -FAIL Main frame with smooth scroll-behavior ; scrollBy() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with auto behavior PASS Main frame with smooth scroll-behavior ; scrollBy() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 2430 but got 2430 +PASS Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior PASS Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling PASS Aborting an ongoing smooth scrolling on the main frame with an instant scrolling diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html index 8c88ec6861d39579f32afbd867bc324b835fa751..bf387304266f178e1ac10b94d010759e0fa5843c 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html @@ -1,4 +1,4 @@ - + Testing scrollOptions' behavior for Element.scroll* on the window of the main frame diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested-expected.txt index 7ce10c08961b048ce154d3210b2cb8c1aa313c35..443a820e58596d56e3fe892119be03dc48d0b95f 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested-expected.txt @@ -1,3 +1,3 @@ -FAIL scrollIntoView with nested elements with different scroll-behavior assert_less_than: Element with smooth behavior should not scroll immediately expected a number less than 500 but got 500 +PASS scrollIntoView with nested elements with different scroll-behavior diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested.html index 3a8906532b9304aceb6a580674b982ca2524e171..3f3d9b72d00d398e9423142f6f57003174666535 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-scrollintoview-nested.html @@ -1,4 +1,4 @@ - + Testing scrollOptions' behavior with scrollIntoView for nested scrolling nodes diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth-positions.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth-positions.html index 005d2b604d7f6a86dc2a590bf3358e5df6f221e9..eaa0fff019531485e2f407da68ee2bdcac8e5c37 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth-positions.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-smooth-positions.html @@ -1,4 +1,4 @@ - + Testing scroll positions when scrolling an element with smooth behavior diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root-expected.txt index b6fa1c2ec8ba9ee10beafaf664ade47c93c9409a..2799fdcc29ed56337a89121b0590a09b7bef5c06 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root-expected.txt @@ -3,35 +3,35 @@ PASS iframe loaded PASS Subframe with auto scroll-behavior ; scroll() with default behavior PASS Subframe with auto scroll-behavior ; scroll() with auto behavior PASS Subframe with auto scroll-behavior ; scroll() with instant behavior -FAIL Subframe with auto scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scroll() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scroll() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with auto scroll-behavior ; scroll() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scroll() with default behavior +PASS Subframe with smooth scroll-behavior ; scroll() with auto behavior PASS Subframe with smooth scroll-behavior ; scroll() with instant behavior -FAIL Subframe with smooth scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with smooth scroll-behavior ; scroll() with smooth behavior PASS Subframe with auto scroll-behavior ; scrollTo() with default behavior PASS Subframe with auto scroll-behavior ; scrollTo() with auto behavior PASS Subframe with auto scroll-behavior ; scrollTo() with instant behavior -FAIL Subframe with auto scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scrollTo() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scrollTo() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scrollTo() with default behavior +PASS Subframe with smooth scroll-behavior ; scrollTo() with auto behavior PASS Subframe with smooth scroll-behavior ; scrollTo() with instant behavior -FAIL Subframe with smooth scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with smooth scroll-behavior ; scrollTo() with smooth behavior PASS Subframe with auto scroll-behavior ; scrollBy() with default behavior PASS Subframe with auto scroll-behavior ; scrollBy() with auto behavior PASS Subframe with auto scroll-behavior ; scrollBy() with instant behavior -FAIL Subframe with auto scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scrollBy() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scrollBy() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scrollBy() with default behavior +PASS Subframe with smooth scroll-behavior ; scrollBy() with auto behavior PASS Subframe with smooth scroll-behavior ; scrollBy() with instant behavior -FAIL Subframe with smooth scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with smooth scroll-behavior ; scrollBy() with smooth behavior PASS Subframe with auto scroll-behavior ; scrollIntoView() with default behavior PASS Subframe with auto scroll-behavior ; scrollIntoView() with auto behavior PASS Subframe with auto scroll-behavior ; scrollIntoView() with instant behavior -FAIL Subframe with auto scroll-behavior ; scrollIntoView() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scrollIntoView() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Subframe with smooth scroll-behavior ; scrollIntoView() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with auto scroll-behavior ; scrollIntoView() with smooth behavior +PASS Subframe with smooth scroll-behavior ; scrollIntoView() with default behavior +PASS Subframe with smooth scroll-behavior ; scrollIntoView() with auto behavior PASS Subframe with smooth scroll-behavior ; scrollIntoView() with instant behavior -FAIL Subframe with smooth scroll-behavior ; scrollIntoView() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Subframe with smooth scroll-behavior ; scrollIntoView() with smooth behavior PASS Aborting an ongoing smooth scrolling on a subframe with another smooth scrolling PASS Aborting an ongoing smooth scrolling on a subframe with an instant scrolling diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html index e641e53e33e10b98b29df65783673438460c6cad..e8ccb66be6e9221f4eece8b8d0f1db7c218659f7 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html @@ -1,4 +1,4 @@ - + Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on the root of a subframe diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window-expected.txt index cc665ebdb8ba15edb3631f8df82f0623093ba914..05eb3272f408e5e64d1bb7ec2a07e0bfcc904744 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window-expected.txt @@ -3,27 +3,27 @@ PASS iframe loaded PASS Main frame with auto scroll-behavior ; scroll() with default behavior PASS Main frame with auto scroll-behavior ; scroll() with auto behavior PASS Main frame with auto scroll-behavior ; scroll() with instant behavior -FAIL Main frame with auto scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Main frame with smooth scroll-behavior ; scroll() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Main frame with smooth scroll-behavior ; scroll() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Main frame with auto scroll-behavior ; scroll() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scroll() with default behavior +PASS Main frame with smooth scroll-behavior ; scroll() with auto behavior PASS Main frame with smooth scroll-behavior ; scroll() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scroll() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Main frame with smooth scroll-behavior ; scroll() with smooth behavior PASS Main frame with auto scroll-behavior ; scrollTo() with default behavior PASS Main frame with auto scroll-behavior ; scrollTo() with auto behavior PASS Main frame with auto scroll-behavior ; scrollTo() with instant behavior -FAIL Main frame with auto scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Main frame with smooth scroll-behavior ; scrollTo() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Main frame with smooth scroll-behavior ; scrollTo() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Main frame with auto scroll-behavior ; scrollTo() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollTo() with auto behavior PASS Main frame with smooth scroll-behavior ; scrollTo() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior PASS Main frame with auto scroll-behavior ; scrollBy() with default behavior PASS Main frame with auto scroll-behavior ; scrollBy() with auto behavior PASS Main frame with auto scroll-behavior ; scrollBy() with instant behavior -FAIL Main frame with auto scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Main frame with smooth scroll-behavior ; scrollBy() with default behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 -FAIL Main frame with smooth scroll-behavior ; scrollBy() with auto behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Main frame with auto scroll-behavior ; scrollBy() with smooth behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with default behavior +PASS Main frame with smooth scroll-behavior ; scrollBy() with auto behavior PASS Main frame with smooth scroll-behavior ; scrollBy() with instant behavior -FAIL Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior assert_less_than: Should not set scrollLeft immediately expected a number less than 500 but got 500 +PASS Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior PASS Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling PASS Aborting an ongoing smooth scrolling on the main frame with an instant scrolling diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html index d931e003d42127af8e57c52bc796b79c05aee4b9..92684d674eff0e8eac5dc98fafad6f535181402f 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html +++ b/LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html @@ -1,4 +1,4 @@ - + Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on the root of a subframe diff --git a/LayoutTests/platform/mac-wk1/TestExpectations b/LayoutTests/platform/mac-wk1/TestExpectations index 1d097645fb8d9501c64ef0967085a18b1722bf19..93c1a7e5116cdb74edd58b698770978f9cc13f4b 100644 --- a/LayoutTests/platform/mac-wk1/TestExpectations +++ b/LayoutTests/platform/mac-wk1/TestExpectations @@ -744,6 +744,13 @@ webkit.org/b/189594 imported/w3c/web-platform-tests/css/css-animations/pending-s webkit.org/b/188070 imported/w3c/web-platform-tests/streams/piping/error-propagation-backward.html [ Pass Failure ] +# Tests for smooth scroll behavior do not all work and they are slow, so let's just skip them. +webkit.org/b/191357 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html [ Skip ] +webkit.org/b/191357 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html [ Skip ] +webkit.org/b/191357 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-root.html [ Skip ] +webkit.org/b/191357 imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-subframe-window.html [ Skip ] +webkit.org/b/191357 imported/w3c/web-platform-tests/css/cssom-view/inheritance.html [ Skip ] + webkit.org/b/189908 imported/w3c/web-platform-tests/resource-timing/resource_timing.worker.html [ Failure ] webkit.org/b/189756 [ Mojave+ ] compositing/filters/opacity-change-on-filtered-paints-into-ancestor.html [ Pass ImageOnlyFailure ]