From 092f0c4ab07262ae943778ff63b200485815fcf3 Mon Sep 17 00:00:00 2001 From: Frederic Wang Date: Fri, 30 Nov 2018 08:31:28 +0100 Subject: [PATCH xserver] Bug 188043 - Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties --- LayoutTests/ChangeLog | 10 ++ LayoutTests/imported/w3c/ChangeLog | 25 +++ .../scroll-behavior-default-css-expected.txt | 2 +- .../scroll-behavior-default-css.html | 2 +- .../scroll-behavior-element-expected.txt | 32 ++-- .../cssom-view/scroll-behavior-element.html | 2 +- ...roll-behavior-main-frame-root-expected.txt | 32 ++-- .../scroll-behavior-main-frame-root.html | 2 +- ...ll-behavior-main-frame-window-expected.txt | 24 +-- .../scroll-behavior-main-frame-window.html | 2 +- ...ehavior-scrollintoview-nested-expected.txt | 4 +- ...scroll-behavior-scrollintoview-nested.html | 2 +- .../scroll-behavior-smooth-positions.html | 2 +- ...scroll-behavior-subframe-root-expected.txt | 32 ++-- .../scroll-behavior-subframe-root.html | 2 +- ...roll-behavior-subframe-window-expected.txt | 24 +-- .../scroll-behavior-subframe-window.html | 2 +- LayoutTests/platform/mac-wk1/TestExpectations | 6 + Source/WebCore/CMakeLists.txt | 2 + Source/WebCore/ChangeLog | 144 ++++++++++++++++++ Source/WebCore/DerivedSources.make | 2 + Source/WebCore/Sources.txt | 4 + Source/WebCore/SourcesGTK.txt | 1 - .../WebCore/WebCore.xcodeproj/project.pbxproj | 28 ++++ .../css/CSSComputedStyleDeclaration.cpp | 5 + Source/WebCore/css/CSSProperties.json | 16 ++ Source/WebCore/css/CSSValueKeywords.in | 4 + Source/WebCore/css/StyleBuilderConverter.h | 6 + .../WebCore/css/parser/CSSParserContext.cpp | 2 + Source/WebCore/css/parser/CSSParserContext.h | 4 +- .../WebCore/css/parser/CSSParserFastPaths.cpp | 5 - .../WebCore/css/parser/CSSPropertyParser.cpp | 12 ++ Source/WebCore/dom/Element.cpp | 29 +++- Source/WebCore/page/DOMWindow.cpp | 14 +- Source/WebCore/page/ScrollBehavior.cpp | 48 ++++++ Source/WebCore/page/ScrollBehavior.h | 34 +++++ Source/WebCore/page/ScrollBehavior.idl | 20 +++ Source/WebCore/page/ScrollIntoViewOptions.h | 5 +- Source/WebCore/page/ScrollIntoViewOptions.idl | 3 +- Source/WebCore/page/ScrollOptions.h | 30 ++++ Source/WebCore/page/ScrollOptions.idl | 22 +++ Source/WebCore/page/ScrollToOptions.h | 13 +- Source/WebCore/page/ScrollToOptions.idl | 3 +- Source/WebCore/page/Settings.yaml | 3 + Source/WebCore/platform/ScrollAnimation.h | 3 + .../platform/ScrollAnimationKinetic.cpp | 5 + .../WebCore/platform/ScrollAnimationKinetic.h | 1 + .../platform/ScrollAnimationSmooth.cpp | 26 +++- .../WebCore/platform/ScrollAnimationSmooth.h | 8 +- Source/WebCore/platform/ScrollAnimator.cpp | 48 ++++++ Source/WebCore/platform/ScrollAnimator.h | 15 +- Source/WebCore/platform/ScrollView.cpp | 6 +- Source/WebCore/platform/ScrollableArea.cpp | 11 ++ Source/WebCore/platform/ScrollableArea.h | 2 + .../WebCore/platform/mac/ScrollAnimatorMac.mm | 1 + Source/WebCore/rendering/RenderBox.cpp | 8 + Source/WebCore/rendering/RenderBox.h | 1 + Source/WebCore/rendering/RenderLayer.cpp | 39 ++++- Source/WebCore/rendering/RenderLayer.h | 3 + Source/WebCore/rendering/style/RenderStyle.h | 6 + .../style/StyleRareNonInheritedData.cpp | 3 + .../style/StyleRareNonInheritedData.h | 2 + Source/WebCore/testing/Internals.cpp | 2 +- Source/WebKit/ChangeLog | 11 ++ Source/WebKit/Shared/WebPreferences.yaml | 8 +- Source/WebKitLegacy/mac/ChangeLog | 17 +++ .../mac/WebView/WebPreferenceKeysPrivate.h | 1 + .../mac/WebView/WebPreferences.mm | 11 ++ .../mac/WebView/WebPreferencesPrivate.h | 1 + Source/WebKitLegacy/mac/WebView/WebView.mm | 1 + Source/WebKitLegacy/win/ChangeLog | 17 +++ .../win/Interfaces/IWebPreferencesPrivate.idl | 2 + .../win/WebPreferenceKeysPrivate.h | 1 + Source/WebKitLegacy/win/WebPreferences.cpp | 16 ++ Source/WebKitLegacy/win/WebPreferences.h | 2 + Source/WebKitLegacy/win/WebView.cpp | 5 + Tools/ChangeLog | 11 ++ Tools/DumpRenderTree/TestOptions.cpp | 2 + Tools/DumpRenderTree/TestOptions.h | 1 + Tools/DumpRenderTree/mac/DumpRenderTree.mm | 1 + 80 files changed, 832 insertions(+), 132 deletions(-) create mode 100644 Source/WebCore/page/ScrollBehavior.cpp create mode 100644 Source/WebCore/page/ScrollBehavior.h create mode 100644 Source/WebCore/page/ScrollBehavior.idl create mode 100644 Source/WebCore/page/ScrollOptions.h create mode 100644 Source/WebCore/page/ScrollOptions.idl diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 4557ea984db..79b528e96c8 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-02-26 Wenson Hsieh Remove conditional compile guard for InsertIntoTextNodeCommand::doReapply diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog index fe455605b6d..07ca98dd089 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-02-26 Youenn Fablet Move service worker response validation from the service worker client to the service worker itself 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 9068b797552..8d4ca64155f 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 8606b1f3ed4..eed63a06932 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 2b9129c1cf4..53a961ef56a 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 9f60ca77112..556b66c824f 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 d922258af27..97caea27bb5 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 7ef0a4aa0da..188863ff82c 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 c6be96661c2..382385aab49 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 57b0d913461..23e298dfdf0 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 7ce10c08961..a3a51d3e6ab 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 2a97e065663..ece539b3352 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 19e317d5e4b..b610a47b5c7 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 b6fa1c2ec8b..2799fdcc29e 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 32de1b62038..d36c9d03bff 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 cc665ebdb8b..05eb3272f40 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 0a8ed39d1b9..74aec5467ff 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 d270795ca72..437e219c50e 100644 --- a/LayoutTests/platform/mac-wk1/TestExpectations +++ b/LayoutTests/platform/mac-wk1/TestExpectations @@ -642,6 +642,12 @@ css-custom-properties-api [ Skip ] css-typedom [ Skip ] css-dark-mode [ Skip ] +# 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 ] diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index cd63192c4bd..db932b49d27 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -933,8 +933,10 @@ set(WebCore_NON_SVG_IDL_FILES page/PerformanceTiming.idl page/RemoteDOMWindow.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/ChangeLog b/Source/WebCore/ChangeLog index e30a4e0413b..4a3239c5a54 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,147 @@ +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. + * 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-02-26 Wenson Hsieh Remove conditional compile guard for InsertIntoTextNodeCommand::doReapply diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make index 9e1818d8265..aa0da6c9225 100644 --- a/Source/WebCore/DerivedSources.make +++ b/Source/WebCore/DerivedSources.make @@ -881,8 +881,10 @@ JS_BINDING_IDLS = \ $(WebCore)/page/PerformanceTiming.idl \ $(WebCore)/page/RemoteDOMWindow.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/Sources.txt b/Source/WebCore/Sources.txt index 28f66ef7428..c87e638dde1 100644 --- a/Source/WebCore/Sources.txt +++ b/Source/WebCore/Sources.txt @@ -1540,6 +1540,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 @@ -3242,8 +3244,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 15a0ba83ff7..5eb5c8d2b2b 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 ac9c97653a5..d97f911394e 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -2421,6 +2421,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, ); }; }; @@ -2494,6 +2496,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 */; }; @@ -10064,6 +10068,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 = ""; }; @@ -10205,6 +10215,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 = ""; }; @@ -20482,10 +20497,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 */, @@ -25247,10 +25267,14 @@ 46C376612085176D00C73829 /* JSRemoteDOMWindow.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 */, @@ -30308,8 +30332,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 */, @@ -31480,6 +31506,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 */, @@ -31511,6 +31538,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 977eca3a41e..d5cbf7293af 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -383,6 +383,7 @@ static const CSSPropertyID computedProperties[] = { #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) CSSPropertyWebkitOverflowScrolling, #endif + CSSPropertyScrollBehavior, CSSPropertyPerspective, CSSPropertyPerspectiveOrigin, CSSPropertyWebkitPrintColorAdjust, @@ -3737,6 +3738,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 e9f945a7b00..6d25a3bf88f 100644 --- a/Source/WebCore/css/CSSProperties.json +++ b/Source/WebCore/css/CSSProperties.json @@ -6508,6 +6508,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 7e0e1706eeb..ba7526cb63a 100644 --- a/Source/WebCore/css/CSSValueKeywords.in +++ b/Source/WebCore/css/CSSValueKeywords.in @@ -1374,6 +1374,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 50a5f50ab15..989a7391ab8 100644 --- a/Source/WebCore/css/StyleBuilderConverter.h +++ b/Source/WebCore/css/StyleBuilderConverter.h @@ -124,6 +124,7 @@ public: #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) 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 06c702a0db4..005a2605a85 100644 --- a/Source/WebCore/css/parser/CSSParserContext.cpp +++ b/Source/WebCore/css/parser/CSSParserContext.cpp @@ -73,6 +73,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; #if PLATFORM(IOS_FAMILY) @@ -102,6 +103,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 758b6eeb3af..45ac56e3b46 100644 --- a/Source/WebCore/css/parser/CSSParserContext.h +++ b/Source/WebCore/css/parser/CSSParserContext.h @@ -59,6 +59,7 @@ public: bool attachmentEnabled { false }; #endif bool deferredCSSParserEnabled { false }; + bool scrollBehaviorEnabled { false }; // This is only needed to support getMatchedCSSRules. bool hasDocumentSecurityOrigin { false }; @@ -106,7 +107,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 9020f45216f..1d0956fafde 100644 --- a/Source/WebCore/css/parser/CSSParserFastPaths.cpp +++ b/Source/WebCore/css/parser/CSSParserFastPaths.cpp @@ -625,10 +625,6 @@ bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId return valueID == CSSValueStatic || valueID == CSSValueRelative || valueID == CSSValueAbsolute || valueID == CSSValueFixed || 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: @@ -926,7 +922,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 34a2d63d0d3..2eeafd9a949 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); @@ -4038,6 +4046,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 1e60b7186d7..77a4c276189 100644 --- a/Source/WebCore/dom/Element.cpp +++ b/Source/WebCore/dom/Element.cpp @@ -686,7 +686,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(); @@ -696,9 +695,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) @@ -757,7 +762,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) @@ -793,13 +798,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()), clamping); - renderer->setScrollTop(clampToInteger(scrollToOptions.top.value() * renderer->style().effectiveZoom()), 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(), clamping); + renderer->setScrollTop(scrollPosition.y(), 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 fa75ac54ead..50bd05b6294 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -1550,7 +1550,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 @@ -1572,10 +1572,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; @@ -1588,12 +1588,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 00000000000..5328c9b83a8 --- /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 00000000000..f01497b0307 --- /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 00000000000..a865fbe665b --- /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 939cd73425a..f275f2fbd1a 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 cf9d1fd7678..1b24c686fc7 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 00000000000..e7f63b9ff1c --- /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 00000000000..140f5c70ed1 --- /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 ce1cba1c7c0..65b6e571db9 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 510bc071a68..2b9b554122a 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 303d7f82d4b..3f4195f7fe3 100644 --- a/Source/WebCore/page/Settings.yaml +++ b/Source/WebCore/page/Settings.yaml @@ -580,6 +580,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 2e5f63bcef2..072e94bc13b 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; 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 ac9f2f0f37f..50fb6098409 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 cfd33ce5b49..291fa9c19a7 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 d064e69379f..7cc1958a1c5 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 02cc4ee2bd7..505b2ef4105 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; 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 d9154d9351a..e6c95f9062a 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 6e2a884abb2..6914483d730 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 a598947fb3b..effef45f6bd 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() || !inProgrammaticScroll()) && newScrollPosition == this->scrollPosition()) + bool scrollInProgress = isScrollInProgress(); + if ((!delegatesScrolling() || !inProgrammaticScroll()) && !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 efb76e8bef6..e0247915c0b 100644 --- a/Source/WebCore/platform/ScrollableArea.cpp +++ b/Source/WebCore/platform/ScrollableArea.cpp @@ -100,6 +100,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; @@ -138,6 +143,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 01b64e99efc..422f693ab22 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 e4efb5b7225..e7d95895004 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -1148,6 +1148,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 24f208d7ea1..7a4fcc8f97d 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -591,6 +591,14 @@ void RenderBox::setScrollTop(int newTop, ScrollClamping clamping) layer()->scrollToYPosition(newTop, 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 9fcd239911a..40c32968c31 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, ScrollClamping = ScrollClamping::Clamped); virtual void setScrollTop(int, 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 47a9e4df1eb..14fc314fed9 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" @@ -2335,10 +2336,23 @@ ScrollOffset RenderLayer::clampScrollOffset(const ScrollOffset& scrollOffset) co void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollClamping clamping) { ScrollOffset newScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset; - if (newScrollOffset != this->scrollOffset()) + bool scrollInProgress = isScrollInProgress(); + if (scrollInProgress) + scrollAnimator().cancelAnimations(); + if (scrollInProgress || newScrollOffset != this->scrollOffset()) scrollToOffsetWithoutAnimation(newScrollOffset, clamping); } +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(); @@ -2484,6 +2498,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; @@ -2506,9 +2521,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()); @@ -2532,7 +2550,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(); @@ -2557,7 +2580,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 88b3255e571..e76b47b68e0 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 @@ -120,6 +121,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 { @@ -409,6 +411,7 @@ public: void scrollByRecursively(const IntSize& delta, ScrollableArea** scrolledArea = nullptr); WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollClamping = ScrollClamping::Clamped); + WEBCORE_EXPORT void scrollToOffsetWithAnimation(const ScrollOffset&, ScrollClamping = ScrollClamping::Clamped); void scrollToXOffset(int x, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), clamping); } void scrollToYOffset(int y, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(scrollOffset().x(), y), clamping); } diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 69650df20f0..229cfd88cb2 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -740,6 +740,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 @@ -1253,6 +1255,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 @@ -1689,6 +1693,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 19e3372e13c..004a4f55e4d 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp @@ -79,6 +79,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())) @@ -173,6 +174,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) @@ -288,6 +290,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 2133b885c32..73fce0351c3 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h @@ -178,6 +178,8 @@ public: unsigned touchActions : 5; // 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 a0c3359420b..298a33cb407 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -1681,7 +1681,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/ChangeLog b/Source/WebKit/ChangeLog index 71723f91e2b..b051a95b6fd 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-02-26 Chris Dumez [PSON] Add mechanism to clear suspended pages while bypassing the WebProcess cache diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml index b9084beb90a..e0fad3c0313 100644 --- a/Source/WebKit/Shared/WebPreferences.yaml +++ b/Source/WebKit/Shared/WebPreferences.yaml @@ -1191,7 +1191,6 @@ EditableImagesEnabled: # DEFAULT_EXPERIMENTAL_FEATURES_ENABLED (for features that are ready for # wider testing). - SpringTimingFunctionEnabled: type: bool defaultValue: DEFAULT_EXPERIMENTAL_FEATURES_ENABLED @@ -1238,6 +1237,13 @@ CSSOMViewScrollingAPIEnabled: humanReadableDescription: "Implement standard behavior for scrollLeft, scrollTop, scrollWidth, scrollHeight, scrollTo, scrollBy and scrollingElement." 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/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog index 75e79565301..45a1cafb2ec 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-02-23 Keith Miller Add new mac target numbers diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h index ced335586db..926533079d2 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h @@ -183,6 +183,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 58d79b8352d..c9ea1e105c8 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm +++ b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm @@ -657,6 +657,7 @@ public: #endif [NSNumber numberWithBool:NO], WebKitCSSOMViewScrollingAPIEnabledPreferenceKey, + [NSNumber numberWithBool:NO], WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey, [NSNumber numberWithBool:YES], WebKitNeedsStorageAccessFromFileURLsQuirkKey, [NSNumber numberWithBool:NO], WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey, #if ENABLE(MEDIA_STREAM) @@ -3138,6 +3139,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 6b9d7a51bde..9a6a7a8a5b6 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h @@ -590,6 +590,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 f1a2dbac8c1..01644336df2 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/ChangeLog b/Source/WebKitLegacy/win/ChangeLog index 1b61b557145..398d88ffbef 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-02-26 Philippe Normand [WPE] Add API for webview background color configuration diff --git a/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl b/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl index 19882cdd0f0..4def57bce90 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 940d5cf55d1..ae6ef274ecb 100644 --- a/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h @@ -205,4 +205,5 @@ #define WebKitServerTimingEnabledPreferenceKey "WebKitServerTimingEnabled" #define WebKitCSSOMViewScrollingAPIEnabledPreferenceKey "WebKitCSSOMViewScrollingAPIEnabled" +#define WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey "WebKitCSSOMViewSmoothScrollingEnabled" diff --git a/Source/WebKitLegacy/win/WebPreferences.cpp b/Source/WebKitLegacy/win/WebPreferences.cpp index 025c20bea23..49e66185fef 100644 --- a/Source/WebKitLegacy/win/WebPreferences.cpp +++ b/Source/WebKitLegacy/win/WebPreferences.cpp @@ -329,6 +329,8 @@ void WebPreferences::initializeDefaultSettings() CFDictionaryAddValue(defaults, CFSTR(WebKitCSSOMViewScrollingAPIEnabledPreferenceKey), kCFBooleanFalse); + CFDictionaryAddValue(defaults, CFSTR(WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey), kCFBooleanFalse); + defaultSettings = defaults; } @@ -2199,6 +2201,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 2906b36b188..2402d82dc81 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 3ff81cf2089..0fb0d05d2db 100644 --- a/Source/WebKitLegacy/win/WebView.cpp +++ b/Source/WebKitLegacy/win/WebView.cpp @@ -5300,6 +5300,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 aed1ddf0e40..654f4a1b233 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-02-26 Mark Lam Remove remaining poisoning code. diff --git a/Tools/DumpRenderTree/TestOptions.cpp b/Tools/DumpRenderTree/TestOptions.cpp index c926612b1b1..39e64fe5760 100644 --- a/Tools/DumpRenderTree/TestOptions.cpp +++ b/Tools/DumpRenderTree/TestOptions.cpp @@ -111,6 +111,8 @@ TestOptions::TestOptions(const std::string& pathOrURL, const std::string& absolu enableCSSLogical = parseBooleanTestHeaderValue(value); else if (key == "internal:AdClickAttributionEnabled") adClickAttributionEnabled = 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 c27e842a48f..0cbf040cceb 100644 --- a/Tools/DumpRenderTree/TestOptions.h +++ b/Tools/DumpRenderTree/TestOptions.h @@ -46,6 +46,7 @@ struct TestOptions { bool enableWebGPU { false }; bool enableCSSLogical { false }; bool adClickAttributionEnabled { 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 b052412b0fc..272ce3fffcc 100644 --- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm @@ -1018,6 +1018,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options) preferences.webGPUEnabled = options.enableWebGPU; preferences.CSSLogicalEnabled = options.enableCSSLogical; preferences.adClickAttributionEnabled = options.adClickAttributionEnabled; + preferences.CSSOMViewSmoothScrollingEnabled = options.enableCSSOMViewSmoothScrolling; } // Called once on DumpRenderTree startup. -- 2.20.1