Subversion Revision: 244731 diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index d3c94590602595c42527d99f8caad2d74a933749..5ad664e23c8748b16dd524021a9e112e62818307 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,148 @@ +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 relies on the existing ScrollAnimationSmooth. + + [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 + + * CMakeLists.txt: Add IDL files for ScrollOptions and ScrollBehavior. + * DerivedSources.make: Ditto. + * Sources.txt: Add ScrollBehavor and ScrollOptions implementation. Also build + ScrollAnimationSmooth.cpp on all platforms. + * Headers.cmake: Add headers for ScrollBehavor and ScrollOptions. + * 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/StyleBuilderConverter.h: + (WebCore::StyleBuilderConverter::convertSmoothScrolling): New function to convert + scroll-behavior into a "is smooth" boolean. + * 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::CSSPropertyParser::parseSingleValue): Parse scroll-behavior (only if enabled). + * dom/Element.cpp: + (WebCore::Element::scrollIntoView): Pass scroll behavior, if any. + (WebCore::Element::scrollBy): Use fromCoordinates helper function. + (WebCore::Element::scrollTo): Handle the case when scroll behavior is smooth. Use + fromCoordinates helper function. + * page/DOMWindow.cpp: + (WebCore::DOMWindow::scrollBy const): Use fromCoordinates helper function. + (WebCore::DOMWindow::scrollTo const): Use fromCoordinates helper function. 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/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::fromCoordinates): New helper function to generate a ScrollToOptions with undefined + behavior. This is necessary to replace curly brace { x, y } declarations now that there is + an extra behavior member from the parent class. + (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. + * 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/ScrollAnimatorMac.mm: + (WebCore::ScrollAnimatorMac::cancelAnimations): Call parent member to handle programmatic scrolling. + * 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::isScrollInProgress const): Helper function to check whether scroll + is in progress on the animator. If m_scrollAnimator does not exist we don't construct it. + (WebCore::ScrollableArea::scrollToOffsetWithAnimation): + * platform/ScrollableArea.h: + * rendering/RenderBox.cpp: + (WebCore::RenderBox::scrollToPositionWithAnimation): Similar to setScrollTop/setScrollLeft + but animate the scrolling. + * rendering/RenderBox.h: + * rendering/RenderLayer.cpp: + (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). + (WebCore::RenderLayer::scrollToOffsetWithAnimation): Ditto. This is similar to scrollToOffset + but animates the scroll. + (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/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. + * testing/Internals.cpp: + (WebCore::Internals::unconstrainedScrollTo): Use fromCoordinates helper function. + 2019-04-25 Carlos Garcia Campos REGRESSION(r244635): [GTK] Wrong background color used in non-dark mode diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index d66faca1bbc5a977a5dd754edcb64eaa685bce0f..2b8fcff633ca34586b0e18b5fa24b09bcc7c70ed 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,14 @@ +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!). + + Add CSSOM smooth scrolling as an experimental feature. + + * Shared/WebPreferences.yaml: + 2019-04-29 Michael Catanzaro [WPE][GTK] window-object-cleared documentation should reference webkit_frame_get_js_context_for_script_world() diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog index e13f9ccc50e8ca83b839742fff3e755b1155758b..1e758e8f31ef9e5652c8c31791d93ecb46a6b4ed 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/WebPreferencesPrivate.h: Ditto. + * WebView/WebView.mm: + (-[WebView _preferencesChanged:]): Ditto. + + * WebView/WebPreferences.mm: + (+[WebPreferences initialize]): Disable CSSOMViewSmoothScrolling by default. + (-[WebPreferences CSSOMViewSmoothScrollingEnabled]): Getter. + (-[WebPreferences setCSSOMViewSmoothScrollingEnabled:]): Setter. + 2019-04-26 Keith Rollin Enable new build rule for post-processing headers when using XCBuild diff --git a/Source/WebKitLegacy/win/ChangeLog b/Source/WebKitLegacy/win/ChangeLog index b0d1ee444af538687788ec858704d27a813454eb..f488b7e8f2a56fbaf2fc166dc343ded9a24cf1fc 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-04-24 Zalan Bujtas Regression (r244291): Broken API Test AutoLayoutRenderingProgressRelativeOrdering diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index 2a83ee00e8f3af711135cf7476907ba666eec553..43f097565909a6a8118e6526c1a2ed496c7bdee8 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -930,8 +930,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 8e1009fbe77f4b3736b4b7850bdafb1121cd6b87..72d724be43c2ae6740007735b3d5ebbbd1a02c3e 100644 --- a/Source/WebCore/DerivedSources.make +++ b/Source/WebCore/DerivedSources.make @@ -875,8 +875,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 015584542ef0286bfd5179119982f413e48eda03..f0b8d34944fb7dfd049bf8bf1cf7b981777343cb 100644 --- a/Source/WebCore/Headers.cmake +++ b/Source/WebCore/Headers.cmake @@ -791,8 +791,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 3606acbf1dfefbb604b084157128c3271ee9d679..9d577392fb2e997454cebe5637272002f09f9b08 100644 --- a/Source/WebCore/Sources.txt +++ b/Source/WebCore/Sources.txt @@ -1539,6 +1539,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 @@ -1641,6 +1642,7 @@ platform/RuntimeApplicationChecks.cpp platform/SSLKeyGenerator.cpp platform/SchemeRegistry.cpp platform/ScrollAnimator.cpp +platform/ScrollAnimationSmooth.cpp platform/ScrollView.cpp platform/ScrollableArea.cpp platform/Scrollbar.cpp @@ -3214,8 +3216,10 @@ JSSVGZoomEvent.cpp JSScreen.cpp JSScreenLuminance.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 17e7b4c027217314556203faa2243d7690a7a10c..6557b088848a4da212567b75240dd2134814f531 100644 --- a/Source/WebCore/SourcesGTK.txt +++ b/Source/WebCore/SourcesGTK.txt @@ -56,7 +56,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 d717275a8b79aaa462797c96125a5b87ddf62554..de5007530669951fcd550a29758294c5a74f8297 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -2382,6 +2382,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, ); }; }; @@ -2437,6 +2439,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 */; }; @@ -9952,6 +9956,12 @@ 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 = ""; }; + 8350C3E81DA59B6200355435 /* ScrollIntoViewOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollIntoViewOptions.idl; 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 = ""; }; + 8350C3E81DA59B6200356424 /* ScrollBehavior.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollBehavior.idl; sourceTree = ""; }; + 8350C3E71DA59B6200356435 /* ScrollOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollOptions.h; sourceTree = ""; }; + 8350C3E81DA59B6200356435 /* ScrollOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollOptions.idl; 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 = ""; }; @@ -10073,6 +10083,11 @@ 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 = ""; }; + 83E9B3011DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollIntoViewOptions.h; sourceTree = ""; }; + 83E9B3001DA5A51E00FFE8D4 /* JSScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollBehavior.cpp; sourceTree = ""; }; + 83E9B3011DA5A51E00FFE8D4 /* JSScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollBehavior.h; sourceTree = ""; }; + 83E9B3001DA5A51E00FFE8E5 /* JSScrollOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollOptions.cpp; sourceTree = ""; }; + 83E9B3011DA5A51E00FFE8E5 /* JSScrollOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollOptions.h; 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 = ""; }; @@ -20241,10 +20256,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 */, @@ -24932,10 +24952,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 */, @@ -30032,8 +30056,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 */, @@ -31212,6 +31238,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 */, @@ -31246,6 +31273,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 2932ba3dfbb1319f22f837a49e7afdadfb1c5fb5..28e139847b6a9050f54c0953a1ac4e14d2f08b62 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -386,6 +386,7 @@ static const CSSPropertyID computedProperties[] = { #if ENABLE(OVERFLOW_SCROLLING_TOUCH) CSSPropertyWebkitOverflowScrolling, #endif + CSSPropertyScrollBehavior, CSSPropertyPerspective, CSSPropertyPerspectiveOrigin, CSSPropertyWebkitPrintColorAdjust, @@ -3740,6 +3741,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 d7c7656a252e02ca4124b820d15c3cf1654df223..c65d19f5776e8505c69d81029990fb59b821e51d 100644 --- a/Source/WebCore/css/CSSProperties.json +++ b/Source/WebCore/css/CSSProperties.json @@ -6516,6 +6516,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 aa2d8545f6f922f6ee0546c66aea66d0a84ffc0b..2827e62904c6a548fdb206d99fad039c40f8e02a 100644 --- a/Source/WebCore/css/CSSValueKeywords.in +++ b/Source/WebCore/css/CSSValueKeywords.in @@ -1383,6 +1383,10 @@ pan-y pinch-zoom #endif +// scroll-behavior +// auto +smooth + // hanging-punctuation allow-end first diff --git a/Source/WebCore/css/StyleBuilderConverter.h b/Source/WebCore/css/StyleBuilderConverter.h index abf5caa3a8ab0215be860c52789da39302458023..74819d92eec093c00d09f9b7a1b7b24333e05033 100644 --- a/Source/WebCore/css/StyleBuilderConverter.h +++ b/Source/WebCore/css/StyleBuilderConverter.h @@ -124,6 +124,7 @@ public: #if ENABLE(OVERFLOW_SCROLLING_TOUCH) static bool convertOverflowScrolling(StyleResolver&, const CSSValue&); #endif + static bool convertSmoothScrolling(StyleResolver&, const CSSValue&); static FontFeatureSettings convertFontFeatureSettings(StyleResolver&, const CSSValue&); static FontSelectionValue convertFontWeightFromValue(const CSSValue&); static FontSelectionValue convertFontStretchFromValue(const CSSValue&); @@ -1380,6 +1381,11 @@ inline bool StyleBuilderConverter::convertOverflowScrolling(StyleResolver&, cons } #endif +inline bool StyleBuilderConverter::convertSmoothScrolling(StyleResolver&, const CSSValue& value) +{ + return downcast(value).valueID() == CSSValueSmooth; +} + inline SVGLengthValue StyleBuilderConverter::convertSVGLengthValue(StyleResolver&, const CSSValue& value) { return SVGLengthValue::fromCSSPrimitiveValue(downcast(value)); diff --git a/Source/WebCore/css/parser/CSSParserContext.cpp b/Source/WebCore/css/parser/CSSParserContext.cpp index 29f231c44225f8aa682d17330cbffa22e51ad4ab..76923b62485648bb00d2712ea068975540a97ab3 100644 --- a/Source/WebCore/css/parser/CSSParserContext.cpp +++ b/Source/WebCore/css/parser/CSSParserContext.cpp @@ -68,6 +68,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; } @@ -92,6 +93,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 a302b3878daa021c478cd5e3040bdada21ca8b41..4a15b136a0446c51ed96c3b345fa3adec975896c 100644 --- a/Source/WebCore/css/parser/CSSParserContext.h +++ b/Source/WebCore/css/parser/CSSParserContext.h @@ -61,6 +61,7 @@ public: bool attachmentEnabled { false }; #endif bool deferredCSSParserEnabled { false }; + bool scrollBehaviorEnabled { false }; // This is only needed to support getMatchedCSSRules. bool hasDocumentSecurityOrigin { false }; @@ -110,7 +111,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 72c586719acaa709fefa01f60a27ebf4b40ef793..b43cfb0cb447e9ef1529622602df74eff827e6e6 100644 --- a/Source/WebCore/css/parser/CSSParserFastPaths.cpp +++ b/Source/WebCore/css/parser/CSSParserFastPaths.cpp @@ -634,10 +634,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: @@ -937,7 +933,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 3eeaa080fae12947965a7ea3d3b01597486bdcf2..52adf63ff3ecec323d3ee91a5b217a9066efe5d9 100644 --- a/Source/WebCore/css/parser/CSSPropertyParser.cpp +++ b/Source/WebCore/css/parser/CSSPropertyParser.cpp @@ -2343,6 +2343,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); @@ -4039,6 +4047,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 c4913bebf58c05ef9ff2c594e684514f943f490e..6f31dd185513808fb1ddbe2d4e08c51f48178fe7 100644 --- a/Source/WebCore/dom/Element.cpp +++ b/Source/WebCore/dom/Element.cpp @@ -711,7 +711,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(); @@ -721,9 +720,15 @@ void Element::scrollIntoView(Optional>&& ar options.blockPosition = ScrollLogicalPosition::End; } - ScrollAlignment alignX = toScrollAlignment(options.inlinePosition, false); - ScrollAlignment alignY = toScrollAlignment(options.blockPosition, true); - renderer()->scrollRectToVisible(absoluteBounds, insideFixed, { SelectionRevealMode::Reveal, alignX, alignY, ShouldAllowCrossOriginScrolling::No }); + ScrollRectToVisibleOptions scrollRectToVisibleOptions { + SelectionRevealMode::Reveal, + toScrollAlignment(options.inlinePosition, false), + toScrollAlignment(options.blockPosition, true), + ShouldAllowCrossOriginScrolling::No, + }; + if (options.behavior) + scrollRectToVisibleOptions.behavior = options.behavior.value(); + renderer()->scrollRectToVisible(absoluteBounds, insideFixed, scrollRectToVisibleOptions); } void Element::scrollIntoView(bool alignToTop) @@ -782,7 +787,7 @@ void Element::scrollBy(const ScrollToOptions& options) void Element::scrollBy(double x, double y) { - scrollBy({ x, y }); + scrollBy(fromCoordinates(x, y)); } void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) @@ -818,13 +823,21 @@ 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()) + ); + if (useSmoothScrolling(scrollToOptions.behavior.valueOr(ScrollBehavior::Auto), *this)) { + renderer->scrollToPositionWithAnimation(scrollPosition, clamping); + return; + } + renderer->setScrollLeft(scrollPosition.x(), ScrollType::Programmatic, clamping); + renderer->setScrollTop(scrollPosition.y(), ScrollType::Programmatic, clamping); } void Element::scrollTo(double x, double y) { - scrollTo({ x, y }); + scrollTo(fromCoordinates(x, y)); } void Element::scrollByUnits(int units, ScrollGranularity granularity) diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp index 7197b118313e1598c6c77c971e84a2ae67ab9838..970142c8e11d54ddaf64f3705e6c639a269bab56 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -1543,7 +1543,7 @@ double DOMWindow::devicePixelRatio() const void DOMWindow::scrollBy(double x, double y) const { - scrollBy({ x, y }); + scrollBy(fromCoordinates(x, y)); } void DOMWindow::scrollBy(const ScrollToOptions& options) const @@ -1565,10 +1565,10 @@ void DOMWindow::scrollBy(const ScrollToOptions& options) const void DOMWindow::scrollTo(double x, double y, ScrollClamping clamping) const { - scrollTo({ x, y }, clamping); + scrollTo(fromCoordinates(x, y), clamping); } -void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping) const +void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) const { if (!isCurrentlyDisplayedInFrame()) return; @@ -1581,12 +1581,18 @@ 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, clamping); + return; + } view->setContentsScrollPosition(layoutPos); } diff --git a/Source/WebCore/page/ScrollBehavior.cpp b/Source/WebCore/page/ScrollBehavior.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5328c9b83a825718d2b70e64cc09b754f40b5e5c --- /dev/null +++ b/Source/WebCore/page/ScrollBehavior.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2018 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#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..f01497b0307e380cd41cb5c5bf439fa9a08e31dc --- /dev/null +++ b/Source/WebCore/page/ScrollBehavior.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#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..a865fbe665b3ce26348d8a51a706a8d0ddec04e7 --- /dev/null +++ b/Source/WebCore/page/ScrollBehavior.idl @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2018 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +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..e7f63b9ff1c942f8897be26c75bb2cd30e7e1369 --- /dev/null +++ b/Source/WebCore/page/ScrollOptions.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2018 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#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..140f5c70ed174ae47081e75a99547b09b76eeb79 --- /dev/null +++ b/Source/WebCore/page/ScrollOptions.idl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2018 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +dictionary ScrollOptions { + ScrollBehavior behavior = "auto"; +}; diff --git a/Source/WebCore/page/ScrollToOptions.h b/Source/WebCore/page/ScrollToOptions.h index ce1cba1c7c010403bdb3e99446f656f604416d7f..65b6e571db925dd6645bbc9c1eab9345a0cf2c3d 100644 --- a/Source/WebCore/page/ScrollToOptions.h +++ b/Source/WebCore/page/ScrollToOptions.h @@ -28,16 +28,25 @@ #pragma once +#include "ScrollOptions.h" #include #include namespace WebCore { -struct ScrollToOptions { +struct ScrollToOptions : ScrollOptions { Optional left; Optional top; }; +inline ScrollToOptions fromCoordinates(double x, double y) +{ + ScrollToOptions options; + options.left = x; + options.top = y; + return options; +}; + inline double normalizeNonFiniteValueOrFallBackTo(Optional value, double fallbackValue) { // Normalize non-finite values (https://drafts.csswg.org/cssom-view/#normalize-non-finite-values). @@ -47,7 +56,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 e47d7eb4cb5d7c4ab3a121eb3ffe67a3a9accf59..abafa0f7eaeb8e6ed26c483764cebce6893ca448 100644 --- a/Source/WebCore/page/Settings.yaml +++ b/Source/WebCore/page/Settings.yaml @@ -592,6 +592,9 @@ visualViewportAPIEnabled: CSSOMViewScrollingAPIEnabled: initial: false +CSSOMViewSmoothScrollingEnabled: + initial: false + inputEventsEnabled: initial: true diff --git a/Source/WebCore/platform/ScrollAnimation.h b/Source/WebCore/platform/ScrollAnimation.h index 2e5f63bcef2bfdfcff9216d986b0f4360c680b41..501007e04d28db8032b32a573a756805b18eb1e7 100644 --- a/Source/WebCore/platform/ScrollAnimation.h +++ b/Source/WebCore/platform/ScrollAnimation.h @@ -32,15 +32,18 @@ namespace WebCore { class FloatPoint; class ScrollableArea; +enum class ScrollClamping : uint8_t; class ScrollAnimation { public: virtual ~ScrollAnimation() { }; virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float /* step */, float /* multiplier */) { return true; }; + virtual void scroll(const FloatPoint&, ScrollClamping) { }; 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..7cc1958a1c5d8e2047b8d89516803fb9933d3bbb 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,19 @@ bool ScrollAnimationSmooth::scroll(ScrollbarOrientation orientation, ScrollGranu return needToScroll; } +void ScrollAnimationSmooth::scroll(const FloatPoint& position, ScrollClamping) +{ + // FIXME: Consider clamping? + 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 +259,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 +276,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 +425,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..351889f32443a359f1bf0be17bf21d016eed4ec9 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&, ScrollClamping) 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 d9154d9351a2f3366ddd05fe60fdebb9c1a1e738..e6c95f9062aedc3f42dcacfbdc13c67f1feea2ad 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,22 @@ ScrollAnimator::ScrollAnimator(ScrollableArea& scrollableArea) #if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING) , m_scrollController(*this) #endif + , m_animationProgrammaticScroll(std::make_unique(scrollableArea, m_currentPosition, [this](FloatPoint&& position) { + 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 +87,13 @@ bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, return true; } +void ScrollAnimator::scrollToOffset(const FloatPoint& offset, ScrollClamping clamping) +{ + m_animationProgrammaticScroll->setCurrentPosition(m_currentPosition); + auto newPosition = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); + m_animationProgrammaticScroll->scroll(newPosition, clamping); +} + void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping) { FloatPoint newPositon = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin())); @@ -245,4 +264,33 @@ void ScrollAnimator::removeTestDeferralForReason(WheelEventTestTrigger::Scrollab } #endif +void ScrollAnimator::cancelAnimations() +{ +#if !USE(REQUEST_ANIMATION_FRAME_TIMER) + m_animationProgrammaticScroll->stop(); +#endif +} + +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 6e2a884abb2f71301ec9d5f7e9656f3d7c919f6b..6914483d7306f27d99612895318213e5626ba22c 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 WheelEventTestTrigger; @@ -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&, ScrollClamping = ScrollClamping::Clamped); 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 setWheelEventTestTrigger(RefPtr&& testTrigger) { m_wheelEventTestTrigger = testTrigger; } #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC) @@ -150,6 +153,8 @@ protected: ScrollController m_scrollController; #endif FloatPoint m_currentPosition; + + std::unique_ptr m_animationProgrammaticScroll; }; } // namespace WebCore diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp index 255ff67f45686e97db110a216385c7a48f487356..06cf657b601e13c4a935c7d48e04450d0204ebe5 100644 --- a/Source/WebCore/platform/ScrollView.cpp +++ b/Source/WebCore/platform/ScrollView.cpp @@ -501,9 +501,13 @@ void ScrollView::setScrollPosition(const ScrollPosition& scrollPosition) ScrollPosition newScrollPosition = !delegatesScrolling() ? adjustScrollPositionWithinRange(scrollPosition) : scrollPosition; - if ((!delegatesScrolling() || currentScrollType() == ScrollType::User) && newScrollPosition == this->scrollPosition()) + bool scrollInProgress = isScrollInProgress(); + if ((!delegatesScrolling() || currentScrollType() == ScrollType::User) && !scrollInProgress && newScrollPosition == this->scrollPosition()) return; + if (scrollInProgress) + scrollAnimator().cancelAnimations(); + if (requestScrollPositionUpdate(newScrollPosition)) return; diff --git a/Source/WebCore/platform/ScrollableArea.cpp b/Source/WebCore/platform/ScrollableArea.cpp index a98e5dab6ef60dcab2f97719d5f0d8ece5ef131b..8dd9565cb363608c4606291dacf7bfd3f7b89ec4 100644 --- a/Source/WebCore/platform/ScrollableArea.cpp +++ b/Source/WebCore/platform/ScrollableArea.cpp @@ -101,6 +101,11 @@ float ScrollableArea::adjustScrollStepForFixedContent(float step, ScrollbarOrien return step; } +bool ScrollableArea::isScrollInProgress() const +{ + return m_scrollAnimator && scrollAnimator().isScrollInProgress(); +} + bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) { ScrollbarOrientation orientation; @@ -139,6 +144,12 @@ bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula return scrollAnimator().scroll(orientation, granularity, step, multiplier); } +void ScrollableArea::scrollToOffsetWithAnimation(const FloatPoint& offset, ScrollClamping clamping) +{ + LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToOffset " << offset); + scrollAnimator().scrollToOffset(offset, clamping); +} + void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping) { LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToOffsetWithoutAnimation " << offset); diff --git a/Source/WebCore/platform/ScrollableArea.h b/Source/WebCore/platform/ScrollableArea.h index fde607f38682e390b914e4861781fffa13ea28af..109dacb0c2a55582f945bcd561bf254c44721d44 100644 --- a/Source/WebCore/platform/ScrollableArea.h +++ b/Source/WebCore/platform/ScrollableArea.h @@ -50,7 +50,9 @@ typedef IntPoint ScrollOffset; class ScrollableArea : public CanMakeWeakPtr { public: + WEBCORE_EXPORT bool isScrollInProgress() const; 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); diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm index a83175122ec2e4b6b6de51be6df5264b41a1f8c4..ff07619c69253309f04369221a4bbc4270ff672c 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -1151,6 +1151,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 fbfb3cae45e9cee9e75a4e72e82cd17e7a3724b4..895b22834c11963f7eb81b77f95925135bb9b450 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -591,6 +591,14 @@ void RenderBox::setScrollTop(int newTop, ScrollType scrollType, ScrollClamping c layer()->scrollToYPosition(newTop, scrollType, clamping); } +void RenderBox::scrollToPositionWithAnimation(ScrollPosition scrollPosition, ScrollClamping clamping) +{ + if (!hasOverflowClip() || !layer()) + return; + setupWheelEventTestTrigger(*layer()); + layer()->scrollToOffsetWithAnimation(scrollPosition, clamping); +} + void RenderBox::absoluteRects(Vector& rects, const LayoutPoint& accumulatedOffset) const { rects.append(snappedIntRect(accumulatedOffset, size())); diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h index 8bcc848a3b34988417740d178e749cc4d3e2db79..231c8adb8064291ec7077f1e2b305c3f8599e4ea 100644 --- a/Source/WebCore/rendering/RenderBox.h +++ b/Source/WebCore/rendering/RenderBox.h @@ -249,6 +249,7 @@ public: virtual int scrollHeight() const; virtual void setScrollLeft(int, ScrollType, ScrollClamping = ScrollClamping::Clamped); virtual void setScrollTop(int, ScrollType, ScrollClamping = ScrollClamping::Clamped); + void scrollToPositionWithAnimation(ScrollPosition, 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 0485c29deba9a64255e3c6cfb65c2da7cebdce49..bbb61322f2337410e896775510455aa919467bfc 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -114,6 +114,7 @@ #include "ScaleTransformOperation.h" #include "ScriptDisallowedScope.h" #include "ScrollAnimator.h" +#include "ScrollBehavior.h" #include "Scrollbar.h" #include "ScrollbarTheme.h" #include "ScrollingCoordinator.h" @@ -2373,12 +2374,25 @@ void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollType sc handled = scrollingCoordinator->requestScrollPositionUpdate(*this, scrollPositionFromOffset(scrollOffset)); #endif - if (!handled) + bool scrollInProgress = isScrollInProgress(); + if (scrollInProgress) + scrollAnimator().cancelAnimations(); + if (scrollInProgress || !handled) scrollToOffsetWithoutAnimation(newScrollOffset, clamping); setCurrentScrollType(previousScrollType); } +void RenderLayer::scrollToOffsetWithAnimation(const ScrollOffset& scrollOffset, ScrollClamping clamping) +{ + ScrollOffset newScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset; + bool scrollInProgress = isScrollInProgress(); + if (scrollInProgress) + scrollAnimator().cancelAnimations(); + if (scrollInProgress || newScrollOffset != this->scrollOffset()) + ScrollableArea::scrollToOffsetWithAnimation(newScrollOffset, clamping); +} + void RenderLayer::scrollTo(const ScrollPosition& position) { RenderBox* box = renderBox(); @@ -2524,6 +2538,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; @@ -2546,9 +2561,12 @@ 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); + if (box->element() && useSmoothScrolling(options.behavior, *box->element())) + scrollToOffsetWithAnimation(clampedScrollOffset); + else + scrollToOffset(clampedScrollOffset); IntSize scrollOffsetDifference = scrollOffset() - oldScrollOffset; localExposeRect.move(-scrollOffsetDifference); newRect = LayoutRect(box->localToAbsoluteQuad(FloatQuad(FloatRect(localExposeRect)), UseTransforms).boundingBox()); @@ -2572,7 +2590,12 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insid IntPoint scrollOffset(roundedIntPoint(exposeRect.location())); // Adjust offsets if they're outside of the allowable range. scrollOffset = scrollOffset.constrainedBetween(IntPoint(), IntPoint(frameView.contentsSize())); - frameView.setScrollPosition(scrollOffset); + // FIXME: Should we use contentDocument()->scrollingElement()? + // See https://github.com/w3c/csswg-drafts/issues/2977 + if (ownerElement->contentDocument() && ownerElement->contentDocument()->documentElement() && useSmoothScrolling(options.behavior, *ownerElement->contentDocument()->documentElement())) + frameView.scrollToOffsetWithAnimation(scrollOffset); + else + frameView.setScrollPosition(scrollOffset); if (options.shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) { parentLayer = ownerElement->renderer()->enclosingLayer(); @@ -2597,7 +2620,13 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insid LayoutRect revealRect = getRectToExpose(viewRect, targetRect, insideFixed, options.alignX, options.alignY); - frameView.setScrollPosition(roundedIntPoint(revealRect.location())); + IntPoint scrollOffset(roundedIntPoint(revealRect.location())); + // FIXME: Should we use document()->scrollingElement()? + // See https://github.com/w3c/csswg-drafts/issues/2977 + if (renderer().document().documentElement() && useSmoothScrolling(options.behavior, *renderer().document().documentElement())) + frameView.scrollToOffsetWithAnimation(scrollOffset); + else + frameView.setScrollPosition(scrollOffset); // This is the outermost view of a web page, so after scrolling this view we // scroll its container by calling Page::scrollRectIntoView. diff --git a/Source/WebCore/rendering/RenderLayer.h b/Source/WebCore/rendering/RenderLayer.h index 7aad1961473ef25c1eae08115b1a272b7b2682fc..2eeabfca2d2996a7983a8dd5c0edd43f435dde36 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 @@ -122,6 +123,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 { @@ -420,6 +422,7 @@ 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&, ScrollClamping = ScrollClamping::Clamped); void scrollToXPosition(int x, ScrollType, ScrollClamping = ScrollClamping::Clamped); void scrollToYPosition(int y, ScrollType, ScrollClamping = ScrollClamping::Clamped); diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 68576ac4caf2fa7607649cc99aaaf9551c3a65a2..ce1e5bfbe87f9c4939ace41ef4110a9e73ef54b3 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -742,6 +742,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; } #endif @@ -1256,6 +1258,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); } #endif @@ -1692,6 +1696,8 @@ public: static bool initialUseTouchOverflowScrolling() { return false; } #endif + static bool initialUseSmoothScrolling() { return false; } + #if ENABLE(DASHBOARD_SUPPORT) static const Vector& initialDashboardRegions(); static const Vector& noneDashboardRegions(); diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp index e560a925bcfa9291f75bacfd6e520ef8b6c1a66b..9da5a61d1fa1a46a933a207c8201dc40b42dd9a7 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp @@ -80,6 +80,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())) @@ -174,6 +175,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) @@ -289,6 +291,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 395849215baec6208a9dda9fd52e194b21d7c238..8126022af010a2784b78cca4136981baf23b3280 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h @@ -180,6 +180,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/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp index 64e03d849cb3b8f5ed6551c50e587fe30d1ba755..a0f1f9664190dce55ce2cc9cd7c7fb9eb92f7fe6 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -1686,7 +1686,7 @@ ExceptionOr Internals::unconstrainedScrollTo(Element& element, double x, d if (!document || !document->view()) return Exception { InvalidAccessError }; - element.scrollTo({ x, y }, ScrollClamping::Unclamped); + element.scrollTo(fromCoordinates(x, y), ScrollClamping::Unclamped); return { }; } diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml index ff9da3b51ae89d7bf38f5f9cd8116fb81b711c1c..9b68b6c82caf38c4372b217c30e094a9a0c6fd4b 100644 --- a/Source/WebKit/Shared/WebPreferences.yaml +++ b/Source/WebKit/Shared/WebPreferences.yaml @@ -1216,7 +1216,6 @@ ShouldDecidePolicyBeforeLoadingQuickLookPreview: # DEFAULT_EXPERIMENTAL_FEATURES_ENABLED (for features that are ready for # wider testing). - SpringTimingFunctionEnabled: type: bool defaultValue: DEFAULT_EXPERIMENTAL_FEATURES_ENABLED @@ -1270,6 +1269,13 @@ BlockingOfSmallPluginsEnabled: humanReadableDescription: "Stop plugins smaller than a certain threshold from loading." category: internal +CSSOMViewSmoothScrollingEnabled: + type: bool + defaultValue: false + humanReadableName: "CSSOM View Smooth Scrolling" + humanReadableDescription: "Enable DOM API and CSS property for 'smooth' scroll behavior" + category: experimental + WebAnimationsEnabled: type: bool defaultValue: DEFAULT_EXPERIMENTAL_FEATURES_ENABLED diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h index 2b5e73f0926215fff7f8b14af94623b6305aedae..ed8aff36b6b3511fa0e8e75675be06e4b98ef09c 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h @@ -184,6 +184,7 @@ #define WebKitDirectoryUploadEnabledPreferenceKey @"WebKitDirectoryUploadEnabled" #define WebKitVisualViewportAPIEnabledPreferenceKey @"WebKitVisualViewportAPIEnabled" #define WebKitCSSOMViewScrollingAPIEnabledPreferenceKey @"WebKitCSSOMViewScrollingAPIEnabled" +#define WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey @"WebKitCSSOMViewSmoothScrollingEnabled" #define WebKitModernMediaControlsEnabledPreferenceKey @"WebKitModernMediaControlsEnabled" #define WebKitSubtleCryptoEnabledPreferenceKey @"WebKitSubtleCryptoEnabled" #define WebKitMediaDevicesEnabledPreferenceKey @"WebKitMediaDevicesEnabled" diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm index fc524f7f6e8f1ecfa271686b18b8263eab109a5b..9814c49d5413e584594940f3a0d3f577a6b1b456 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm +++ b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm @@ -652,6 +652,7 @@ public: #endif [NSNumber numberWithBool:NO], WebKitCSSOMViewScrollingAPIEnabledPreferenceKey, + [NSNumber numberWithBool:NO], WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey, [NSNumber numberWithBool:YES], WebKitNeedsStorageAccessFromFileURLsQuirkKey, [NSNumber numberWithBool:NO], WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey, #if ENABLE(MEDIA_STREAM) @@ -3135,6 +3136,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 f4c5ff37f56e9e2b538438fed007309fdb93aa85..212788e026008ddc73caf932904e18069d06e914 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h @@ -605,6 +605,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 3998a5b9591d631df5a8b0a982a6b73632d607b6..fc0706e19067b3ae64dbbf273a1115b2ea9a1761 100644 --- a/Source/WebKitLegacy/mac/WebView/WebView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm @@ -2972,6 +2972,7 @@ static bool needsSelfRetainWhileLoadingQuirk() settings.setVisualViewportAPIEnabled([preferences visualViewportAPIEnabled]); 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 ed8b1ccaa9dc3905183da7015705d39c117aa35b..10a8ff6a4c45b92c0dd84e934240a1cd4d47d8ef 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 413a6fdf2953fb62b3491481212c95d5468b1c60..959cd6b6258aa4badc1afb18b3c5bc0ef65fb660 100644 --- a/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h @@ -205,5 +205,6 @@ #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 9023e3f4153109d771455c22ddd2a56f7e18a629..f238a2f855f6993d8299602ce32dedcef0e584f9 100644 --- a/Source/WebKitLegacy/win/WebPreferences.cpp +++ b/Source/WebKitLegacy/win/WebPreferences.cpp @@ -331,6 +331,8 @@ void WebPreferences::initializeDefaultSettings() CFDictionaryAddValue(defaults, CFSTR(WebKitResizeObserverEnabledPreferenceKey), kCFBooleanFalse); + CFDictionaryAddValue(defaults, CFSTR(WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey), kCFBooleanFalse); + defaultSettings = defaults; } @@ -2201,6 +2203,20 @@ HRESULT WebPreferences::setCSSOMViewScrollingAPIEnabled(BOOL 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::setApplicationId(BSTR applicationId) { m_applicationId = String(applicationId).createCFString(); diff --git a/Source/WebKitLegacy/win/WebPreferences.h b/Source/WebKitLegacy/win/WebPreferences.h index 6eba17c3e876595a9f0b491a8ecbef0c76633273..1b25c0d7cce313d700f4634837b84b696d34eb92 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 381f1a6ad6fd900933e552d1023a2ac581b7a27b..ea9241e00219561251647ddf0dbd71926db99b14 100644 --- a/Source/WebKitLegacy/win/WebView.cpp +++ b/Source/WebKitLegacy/win/WebView.cpp @@ -5297,6 +5297,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 c89195bfb8a245ac4ff9b1bf7da6376b41b35181..1bbcf2c57fea0b7eab0012b7745b87786115eb44 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,14 @@ +2018-11-06 Frederic Wang + + Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties + https://bugs.webkit.org/show_bug.cgi?id=188043 + + * 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-04-26 Stephanie Lewis run-benchmarks should have an intial prep and restore env call for tasks that are too expensive to do for every iteration diff --git a/Tools/DumpRenderTree/TestOptions.cpp b/Tools/DumpRenderTree/TestOptions.cpp index 0c93c80efd1483e96f350ee4f95318f0eab0ecf7..c1022191b2f76a866c22071da52e12ada52bb143 100644 --- a/Tools/DumpRenderTree/TestOptions.cpp +++ b/Tools/DumpRenderTree/TestOptions.cpp @@ -113,6 +113,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); pairStart = pairEnd + 1; } } diff --git a/Tools/DumpRenderTree/TestOptions.h b/Tools/DumpRenderTree/TestOptions.h index d885edbdeb06a8bb67f4a01baf2b2bc53fc4c7d1..fbee0f13af0f78d84578002b5f66f1fd8c2ca6cf 100644 --- a/Tools/DumpRenderTree/TestOptions.h +++ b/Tools/DumpRenderTree/TestOptions.h @@ -47,6 +47,7 @@ struct TestOptions { bool enableCSSLogical { false }; bool adClickAttributionEnabled { false }; bool enableResizeObserver { false }; + bool enableCSSOMViewSmoothScrolling { false }; std::string jscOptions; TestOptions(const std::string& pathOrURL, const std::string& absolutePath); diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm index 49353229f7d521e3607e32285595975d54e8a90a..824dd4a8cb4f2e72dfd1e13f498f47a07bcad875 100644 --- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm @@ -1019,6 +1019,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options) preferences.CSSLogicalEnabled = options.enableCSSLogical; preferences.adClickAttributionEnabled = options.adClickAttributionEnabled; preferences.resizeObserverEnabled = options.enableResizeObserver; + preferences.CSSOMViewSmoothScrollingEnabled = options.enableCSSOMViewSmoothScrolling; } // Called once on DumpRenderTree startup. diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 218f6d5781da168399c2ff4f488a0ee304b303ed..9e4c2d713d3bcb798a371cee02cf9ef243de3416 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +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!). + + * platform/mac-wk1/TestExpectations: Skip these tests on WK1 as they don't work for now and + are slow anyway. + 2019-04-29 Javier Fernandez Update the CSS Text WPT test suite diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog index c03dff3ed1bef6bdc353647eb59de5fcf8d5ec92..5d0b3c120eb3453b7c676cb92ec6c0c132fec421 100644 --- a/LayoutTests/imported/w3c/ChangeLog +++ b/LayoutTests/imported/w3c/ChangeLog @@ -1,3 +1,28 @@ +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-04-29 Javier Fernandez Update the CSS Text WPT test suite 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 8606b1f3ed40b49c693213e02df69d088d93b979..eed63a069322836f5df6961d800a01f8afaf233f 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 9f60ca771121c82237f2be2097d089f582918fe5..556b66c824fa5cb3d404a98b8e35a171212972ae 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 7ef0a4aa0da74a724a851cb1b2f16305712f7b7f..188863ff82c01307166fc013178919052dcf4151 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 57b0d913461a3d374afeb204ed164b97e7d82b38..23e298dfdf04f300a40b6354e13ae0c2188cc564 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..a3a51d3e6ababaeba4114b4b5c670e9d44851e1b 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,5 @@ -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 +FAIL scrollIntoView with nested elements with different scroll-behavior assert_equals: Element with instant behavior should jump to the final position expected 0 but got 1000 + +assert_equals: Element with instant behavior should jump to the final position expected 500 but got 1000 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 2a97e0656637d12a2451fecd2985cd3370bb75cf..ece539b33524302137a55942d6cbc36272d4f2c9 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 19e317d5e4b9e65aca7df6becb35481ad8125bac..b610a47b5c712a8647cc95dc7c21c0102d6fbf03 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 32de1b62038e0db017b7416554fbf5e92485d3ea..d36c9d03bff63dff2990be32f663358b85681668 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 0a8ed39d1b97d493e9f8ffe0710e711afa491f43..74aec5467ff25754a689d5beca8414ea3a9c7d9b 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 18511a196346a7dfea0a1970f84f6da500c4c5a5..b18a1677cd437e9513ff8edc44335c0f33370118 100644 --- a/LayoutTests/platform/mac-wk1/TestExpectations +++ b/LayoutTests/platform/mac-wk1/TestExpectations @@ -665,6 +665,12 @@ 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/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 ]