diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 8a41c60d2de..386d3e68f30 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. + 2018-11-29 Frederic Wang Separate paint and scroll offsets for RenderLayerBacking::m_scrollingContentsLayer diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog index 0b06b28f398..cb34c5f967b 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: + 2018-11-28 Ryosuke Niwa Update web-platform-tests/shadow-dom 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 d2dfd2800b4..7cb3d565e61 100644 --- a/LayoutTests/platform/mac-wk1/TestExpectations +++ b/LayoutTests/platform/mac-wk1/TestExpectations @@ -642,6 +642,12 @@ imported/w3c/web-platform-tests/css/css-properties-values-api/ [ Skip ] css-custom-properties-api [ 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 b181517d017..5efa7b15c32 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -895,8 +895,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/VisualViewport.idl diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index f3ca220be3f..05fc80439bb 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. + 2018-11-29 Frederic Wang Separate paint and scroll offsets for RenderLayerBacking::m_scrollingContentsLayer diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make index 7791a4c134e..6a242ba45f1 100644 --- a/Source/WebCore/DerivedSources.make +++ b/Source/WebCore/DerivedSources.make @@ -850,8 +850,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/UserMessageHandler.idl \ diff --git a/Source/WebCore/Modules/webgpu/WebGPUTexture.h b/Source/WebCore/Modules/webgpu/WebGPUTexture.h index 1d44a39606a..fd507f35df6 100644 --- a/Source/WebCore/Modules/webgpu/WebGPUTexture.h +++ b/Source/WebCore/Modules/webgpu/WebGPUTexture.h @@ -27,12 +27,12 @@ #if ENABLE(WEBGPU) +#include "GPUTexture.h" #include #include namespace WebCore { -class GPUTexture; class WebGPUTextureView; class WebGPUTexture : public RefCounted { diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt index 79cdc3efae2..d3de16409c0 100644 --- a/Source/WebCore/Sources.txt +++ b/Source/WebCore/Sources.txt @@ -1473,6 +1473,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 @@ -1571,6 +1572,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 @@ -3154,8 +3156,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 5e2356dbb66..85c6bbbbd27 100644 --- a/Source/WebCore/SourcesGTK.txt +++ b/Source/WebCore/SourcesGTK.txt @@ -56,7 +56,6 @@ page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.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 a2e306dab72..3c4ec4c9291 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -2395,6 +2395,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, ); }; }; @@ -2469,6 +2471,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 */; }; @@ -9958,6 +9962,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 = ""; }; @@ -10099,6 +10109,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 = ""; }; @@ -19975,10 +19990,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 */, @@ -24718,10 +24738,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 */, @@ -29669,8 +29693,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 */, @@ -30836,6 +30862,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 */, @@ -30866,6 +30893,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 f1b50fba6d9..bf620febf9b 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -382,6 +382,7 @@ static const CSSPropertyID computedProperties[] = { #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) CSSPropertyWebkitOverflowScrolling, #endif + CSSPropertyScrollBehavior, CSSPropertyPerspective, CSSPropertyPerspectiveOrigin, CSSPropertyWebkitPrintColorAdjust, @@ -3706,6 +3707,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 fe012ba4b22..cd2fb194ad8 100644 --- a/Source/WebCore/css/CSSProperties.json +++ b/Source/WebCore/css/CSSProperties.json @@ -6259,6 +6259,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 86b5e5914f4..9bbaa4b0ad0 100644 --- a/Source/WebCore/css/CSSValueKeywords.in +++ b/Source/WebCore/css/CSSValueKeywords.in @@ -1357,6 +1357,10 @@ scroll-position manipulation #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 e61d1f5472d..404f38dfb12 100644 --- a/Source/WebCore/css/StyleBuilderConverter.h +++ b/Source/WebCore/css/StyleBuilderConverter.h @@ -120,6 +120,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&); @@ -1354,6 +1355,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 1089d22d41b..584acd432f9 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 3835f239b08..3bf88ee01d9 100644 --- a/Source/WebCore/css/parser/CSSParserFastPaths.cpp +++ b/Source/WebCore/css/parser/CSSParserFastPaths.cpp @@ -621,10 +621,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 5cb8945b38f..24be1035de1 100644 --- a/Source/WebCore/css/parser/CSSPropertyParser.cpp +++ b/Source/WebCore/css/parser/CSSPropertyParser.cpp @@ -2326,6 +2326,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); @@ -4015,6 +4023,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(TOUCH_EVENTS) diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp index 88207e54f80..03f394a6c32 100644 --- a/Source/WebCore/dom/Element.cpp +++ b/Source/WebCore/dom/Element.cpp @@ -682,7 +682,6 @@ void Element::scrollIntoView(std::optional> bool insideFixed; LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed); - // FIXME(webkit.org/b/188043): Support ScrollBehavior. ScrollIntoViewOptions options; if (arg) { auto value = arg.value(); @@ -692,9 +691,15 @@ void Element::scrollIntoView(std::optional> 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) @@ -753,7 +758,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) @@ -789,13 +794,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.value_or(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 0c27b6d5f18..5a31395a0b6 100644 --- a/Source/WebCore/page/DOMWindow.cpp +++ b/Source/WebCore/page/DOMWindow.cpp @@ -1542,7 +1542,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 @@ -1564,10 +1564,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; @@ -1580,12 +1580,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.value_or(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 328d2ec3cf2..ebbb013e3c4 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 { std::optional blockPosition { ScrollLogicalPosition::Start }; std::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..b583ba4d487 --- /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 { + std::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 87eeaa9cca9..b7699a439cb 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 { std::optional left; std::optional top; }; +inline ScrollToOptions fromCoordinates(double x, double y) +{ + ScrollToOptions options; + options.left = x; + options.top = y; + return options; +}; + inline double normalizeNonFiniteValueOrFallBackTo(std::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(std::optional value, d // 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 4177fa74904..5f8800de9de 100644 --- a/Source/WebCore/page/Settings.yaml +++ b/Source/WebCore/page/Settings.yaml @@ -566,6 +566,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 ab477937fed..266e7780161 100644 --- a/Source/WebCore/platform/ScrollAnimationKinetic.cpp +++ b/Source/WebCore/platform/ScrollAnimationKinetic.cpp @@ -163,4 +163,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 5458c533075..cffce5992fd 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 98d4ecae887..8b7bcb7a520 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 94629214544..0ee5658399e 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 e15ec3f1359..9a86a51f676 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 d08cc59fff1..0ad23b5c1e5 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -1152,6 +1152,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 bf88bd50e9a..44905b267ef 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -590,6 +590,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 db1094d69e5..692f02f3253 100644 --- a/Source/WebCore/rendering/RenderBox.h +++ b/Source/WebCore/rendering/RenderBox.h @@ -245,6 +245,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 80c1bbe74e3..1a61ac682b0 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" @@ -2337,10 +2338,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(); @@ -2490,6 +2504,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; @@ -2512,9 +2527,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()); @@ -2538,7 +2556,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(); @@ -2563,7 +2586,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 1a86ea78c0f..04d6e2aee86 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 @@ -125,6 +126,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 { @@ -407,6 +409,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 dbaaf0c763e..d6a0169934a 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -739,6 +739,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 @@ -1252,6 +1254,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 @@ -1688,6 +1692,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 a312bdaebd5..b5e5222c976 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp @@ -79,6 +79,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData() #if ENABLE(TOUCH_EVENTS) , touchAction(static_cast(RenderStyle::initialTouchAction())) #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(TOUCH_EVENTS) , touchAction(o.touchAction) #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(TOUCH_EVENTS) && touchAction == o.touchAction #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 f9baa142305..8b2ecd19709 100644 --- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h @@ -178,6 +178,8 @@ public: unsigned touchAction : 1; // 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 b11a32598af..30b448a7973 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -1658,7 +1658,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 ad765ed694f..ccf136421bf 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: + 2018-11-29 Tim Horton Inform clients when editable image attachment backing data changes diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml index 6e6836b0a43..b77cef27603 100644 --- a/Source/WebKit/Shared/WebPreferences.yaml +++ b/Source/WebKit/Shared/WebPreferences.yaml @@ -1193,7 +1193,6 @@ EditableImagesEnabled: # DEFAULT_EXPERIMENTAL_FEATURES_ENABLED (for features that are ready for # wider testing). - SpringTimingFunctionEnabled: type: bool defaultValue: DEFAULT_EXPERIMENTAL_FEATURES_ENABLED @@ -1240,6 +1239,13 @@ CSSOMViewScrollingAPIEnabled: humanReadableDescription: "Implement standard behavior for scrollLeft, scrollTop, scrollWidth, scrollHeight, scrollTo, scrollBy and scrollingElement." category: experimental +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 50e01ad9b05..dceebee1b12 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. + 2018-11-28 Alex Christensen Remove dead code from an earlier attempt at implementing safe browsing diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h index b73f6cb6830..d9ddbe72f61 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h @@ -183,6 +183,7 @@ #define WebKitVisualViewportEnabledPreferenceKey @"WebKitVisualViewportEnabled" #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 7e1cfc1b1e2..db24c54519a 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm +++ b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm @@ -657,6 +657,7 @@ public: [NSNumber numberWithBool:NO], WebKitVisualViewportAPIEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitCSSOMViewScrollingAPIEnabledPreferenceKey, + [NSNumber numberWithBool:NO], WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey, [NSNumber numberWithBool:YES], WebKitNeedsStorageAccessFromFileURLsQuirkKey, [NSNumber numberWithBool:NO], WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey, #if ENABLE(MEDIA_STREAM) @@ -3107,6 +3108,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 20b33429510..934d85b1041 100644 --- a/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h +++ b/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h @@ -588,6 +588,7 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification WEBKIT_DEPR @property (nonatomic) BOOL visualViewportEnabled; @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 893fa08ccf9..866b0c3143f 100644 --- a/Source/WebKitLegacy/mac/WebView/WebView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm @@ -2955,6 +2955,7 @@ static bool needsSelfRetainWhileLoadingQuirk() settings.setVisualViewportEnabled([preferences visualViewportEnabled]); 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 70242b4498f..583a2501713 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): + 2018-11-28 Alex Christensen Remove dead code from an earlier attempt at implementing safe browsing 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 59be0c443f4..b57613bb19c 100644 --- a/Source/WebKitLegacy/win/WebPreferences.cpp +++ b/Source/WebKitLegacy/win/WebPreferences.cpp @@ -328,6 +328,8 @@ void WebPreferences::initializeDefaultSettings() CFDictionaryAddValue(defaults, CFSTR(WebKitCSSOMViewScrollingAPIEnabledPreferenceKey), kCFBooleanFalse); + CFDictionaryAddValue(defaults, CFSTR(WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey), kCFBooleanFalse); + defaultSettings = defaults; } @@ -2198,6 +2200,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 3ce4485b8a0..814d5a9386c 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 acad84edaff..5295f8d8dcb 100644 --- a/Source/WebKitLegacy/win/WebView.cpp +++ b/Source/WebKitLegacy/win/WebView.cpp @@ -5283,6 +5283,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 73d6f2fd706..3fed37b5a53 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. + 2018-11-29 Tim Horton Inform clients when editable image attachment backing data changes diff --git a/Tools/DumpRenderTree/TestOptions.cpp b/Tools/DumpRenderTree/TestOptions.cpp index 81b2487b233..102d166c532 100644 --- a/Tools/DumpRenderTree/TestOptions.cpp +++ b/Tools/DumpRenderTree/TestOptions.cpp @@ -109,6 +109,8 @@ TestOptions::TestOptions(const std::string& pathOrURL, const std::string& absolu jscOptions = value; else if (key == "experimental:WebGPUEnabled") enableWebGPU = 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 8aedb946417..987f3cd4737 100644 --- a/Tools/DumpRenderTree/TestOptions.h +++ b/Tools/DumpRenderTree/TestOptions.h @@ -45,6 +45,7 @@ struct TestOptions { bool enableColorFilter { false }; bool enableSelectionAcrossShadowBoundaries { true }; bool enableWebGPU { 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 5de612c59f3..4234df2eb7c 100644 --- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm @@ -1011,6 +1011,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options) preferences.colorFilterEnabled = options.enableColorFilter; preferences.selectionAcrossShadowBoundariesEnabled = options.enableSelectionAcrossShadowBoundaries; preferences.webGPUEnabled = options.enableWebGPU; + preferences.CSSOMViewSmoothScrollingEnabled = options.enableCSSOMViewSmoothScrolling; } // Called once on DumpRenderTree startup.