WebKit Bugzilla
Attachment 346381 Details for
Bug 188043
: Add support for ScrollOptions' ScrollBehavior and CSS scroll-behavior properties
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP Patch
smooth-scrolling.patch (text/plain), 32.23 KB, created by
Frédéric Wang (:fredw)
on 2018-08-02 08:05:54 PDT
(
hide
)
Description:
WIP Patch
Filename:
MIME Type:
Creator:
Frédéric Wang (:fredw)
Created:
2018-08-02 08:05:54 PDT
Size:
32.23 KB
patch
obsolete
>diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 2f04d538df0..717600a78f9 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -826,6 +826,8 @@ set(WebCore_NON_SVG_IDL_FILES > page/PerformanceTiming.idl > page/RemoteDOMWindow.idl > page/Screen.idl >+ page/ScrollBehavior.idl >+ page/ScrollOptions.idl > page/ScrollToOptions.idl > page/VisualViewport.idl > page/WebKitPoint.idl >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index 6c9b2ce6b61..898af04c0a0 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -790,6 +790,8 @@ JS_BINDING_IDLS = \ > $(WebCore)/page/PerformanceTiming.idl \ > $(WebCore)/page/RemoteDOMWindow.idl \ > $(WebCore)/page/Screen.idl \ >+ $(WebCore)/page/ScrollBehavior.idl \ >+ $(WebCore)/page/ScrollOptions.idl \ > $(WebCore)/page/ScrollToOptions.idl \ > $(WebCore)/page/UserMessageHandler.idl \ > $(WebCore)/page/UserMessageHandlersNamespace.idl \ >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index f996d273967..b63bd9500e7 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1417,6 +1417,7 @@ page/ResourceUsageOverlay.cpp > page/ResourceUsageThread.cpp > page/RuntimeEnabledFeatures.cpp > page/Screen.cpp >+page/ScrollOptions.cpp > page/SecurityOrigin.cpp > page/SecurityOriginData.cpp > page/SecurityPolicy.cpp >@@ -3042,6 +3043,8 @@ JSSVGZoomEvent.cpp > JSScreen.cpp > JSScreenLuminance.cpp > JSScriptProcessorNode.cpp >+JSScrollBehavior.cpp >+JSScrollOptions.cpp > JSScrollToOptions.cpp > JSSecurityPolicyViolationEvent.cpp > JSServiceWorker.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 4876ac80c14..6f4d81295a6 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2330,6 +2330,8 @@ > 833B9E341F508D8500E0E428 /* JSFileSystemEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 833B9E2A1F508D8000E0E428 /* JSFileSystemEntry.h */; }; > 833B9E361F508D8500E0E428 /* JSFileSystemFileEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 833B9E2C1F508D8000E0E428 /* JSFileSystemFileEntry.h */; }; > 83407FC11E8D9C1700E048D3 /* VisibilityChangeClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83407FC01E8D9C1200E048D3 /* VisibilityChangeClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 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, ); }; }; >@@ -2402,6 +2404,8 @@ > 83C1D436178D5AB500141E68 /* SVGPathSegMovetoRel.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1D424178D5AB400141E68 /* SVGPathSegMovetoRel.h */; }; > 83C1F5941EDF69D300410D27 /* QualifiedNameCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1F5921EDF69D300410D27 /* QualifiedNameCache.h */; }; > 83C45B8E1DC2B68A008871BA /* ValidationBubble.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C45B8D1DC2B67C008871BA /* ValidationBubble.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 */; }; >@@ -9852,6 +9856,11 @@ > 834DD4F31BE08989002C9C3E /* PageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageMac.mm; sourceTree = "<group>"; }; > 834DFACC1F7DAE5600C2725B /* SharedStringHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedStringHash.h; sourceTree = "<group>"; }; > 834DFACE1F7DAE5700C2725B /* SharedStringHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedStringHash.cpp; sourceTree = "<group>"; }; >+ 8350C3E71DA59B6200356424 /* ScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBehavior.h; sourceTree = "<group>"; }; >+ 8350C3E81DA59B6200356424 /* ScrollBehavior.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollBehavior.idl; sourceTree = "<group>"; }; >+ 8350C3E71DA59B6200356434 /* ScrollOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollOptions.cpp; sourceTree = "<group>"; }; >+ 8350C3E71DA59B6200356435 /* ScrollOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollOptions.h; sourceTree = "<group>"; }; >+ 8350C3E81DA59B6200356435 /* ScrollOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollOptions.idl; sourceTree = "<group>"; }; > 8350C3E71DA59B6200356446 /* ScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollToOptions.h; sourceTree = "<group>"; }; > 8350C3E81DA59B6200356446 /* ScrollToOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollToOptions.idl; sourceTree = "<group>"; }; > 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = "<group>"; }; >@@ -9989,6 +9998,10 @@ > 83E8667D1FBA563F008855C5 /* ServiceWorkerData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerData.h; sourceTree = "<group>"; }; > 83E8667F1FBA5640008855C5 /* ServiceWorkerData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerData.cpp; sourceTree = "<group>"; }; > 83E959E11B8BC22B004D9385 /* NativeNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeNodeFilter.h; sourceTree = "<group>"; }; >+ 83E9B3001DA5A51E00FFE8D4 /* JSScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollBehavior.cpp; sourceTree = "<group>"; }; >+ 83E9B3011DA5A51E00FFE8D4 /* JSScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollBehavior.h; sourceTree = "<group>"; }; >+ 83E9B3001DA5A51E00FFE8E5 /* JSScrollOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollOptions.cpp; sourceTree = "<group>"; }; >+ 83E9B3011DA5A51E00FFE8E5 /* JSScrollOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollOptions.h; sourceTree = "<group>"; }; > 83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollToOptions.cpp; sourceTree = "<group>"; }; > 83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollToOptions.h; sourceTree = "<group>"; }; > 83EE598B1F50958B003E8B30 /* JSErrorCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorCallback.h; sourceTree = "<group>"; }; >@@ -19436,6 +19449,11 @@ > BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */, > BCEC01BB0C274DAC009F4EC9 /* Screen.h */, > BCEC01BC0C274DAC009F4EC9 /* Screen.idl */, >+ 8350C3E71DA59B6200356424 /* ScrollBehavior.h */, >+ 8350C3E81DA59B6200356424 /* ScrollBehavior.idl */, >+ 8350C3E71DA59B6200356434 /* ScrollOptions.cpp */, >+ 8350C3E71DA59B6200356435 /* ScrollOptions.h */, >+ 8350C3E81DA59B6200356435 /* ScrollOptions.idl */, > 8350C3E71DA59B6200356446 /* ScrollToOptions.h */, > 8350C3E81DA59B6200356446 /* ScrollToOptions.idl */, > BCD0E0F70E972C3500265DEA /* SecurityOrigin.cpp */, >@@ -24202,6 +24220,10 @@ > 46C376612085176D00C73829 /* JSRemoteDOMWindow.h */, > BCEC01C00C274DDD009F4EC9 /* JSScreen.cpp */, > BCEC01C10C274DDD009F4EC9 /* JSScreen.h */, >+ 83E9B3001DA5A51E00FFE8D4 /* JSScrollBehavior.cpp */, >+ 83E9B3011DA5A51E00FFE8D4 /* JSScrollBehavior.h */, >+ 83E9B3001DA5A51E00FFE8E5 /* JSScrollOptions.cpp */, >+ 83E9B3011DA5A51E00FFE8E5 /* JSScrollOptions.h */, > 83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */, > 83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */, > 7C73FB0F191EF6F4007DE061 /* JSUserMessageHandler.cpp */, >@@ -28971,6 +28993,8 @@ > 5E2C436C1BCF071E0001E2BC /* JSRTCTrackEvent.h in Headers */, > BCEC01C30C274DDD009F4EC9 /* JSScreen.h in Headers */, > FDA15ECE12B03F61003A583A /* JSScriptProcessorNode.h in Headers */, >+ 834476EF1DA5BC5E002B6EB0 /* JSScrollBehavior.h in Headers */, >+ 834476EF1DA5BC5E002B6EC1 /* JSScrollOptions.h in Headers */, > 834476EF1DA5BC5E002B6ED2 /* JSScrollToOptions.h in Headers */, > CED06AD11C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.h in Headers */, > 5182C2561F3143CD0059BA7C /* JSServiceWorker.h in Headers */, >@@ -30155,6 +30179,8 @@ > 7AAFE8D019CB8672000F56D8 /* ScrollLatchingState.h in Headers */, > F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */, > F46729281E0DE68500ACC3D8 /* ScrollSnapOffsetsInfo.h in Headers */, >+ 83C5795D1DA5C301006FAC86 /* ScrollBehavior.h in Headers */, >+ 83C5795D1DA5C301006FAC97 /* ScrollOptions.h in Headers */, > 83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */, > 93C09C860B0657AA005ABD4D /* ScrollTypes.h in Headers */, > BC6D6E2609AF943500F59759 /* ScrollView.h in Headers */, >diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >index 6e54eabb770..3c6e2865e1c 100644 >--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >@@ -3680,6 +3680,10 @@ RefPtr<CSSValue> 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 a51b2e6d322..d05f6399ac4 100644 >--- a/Source/WebCore/css/CSSProperties.json >+++ b/Source/WebCore/css/CSSProperties.json >@@ -6089,6 +6089,19 @@ > "url": "https://www.w3.org/TR/css-ui-4/#propdef-user-select" > } > }, >+ "scroll-behavior": { >+ "values": [ >+ "auto", >+ "smooth" >+ ], >+ "codegen-properties": { >+ "name-for-methods": "UseSmoothScrolling", >+ "converter": "SmoothScrolling" >+ }, >+ "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 02047b517bb..ec4b88830f9 100644 >--- a/Source/WebCore/css/CSSValueKeywords.in >+++ b/Source/WebCore/css/CSSValueKeywords.in >@@ -1344,6 +1344,9 @@ scroll-position > manipulation > #endif > >+// scroll-behavior >+smooth >+ > // hanging-punctuation > allow-end > first >diff --git a/Source/WebCore/css/StyleBuilderConverter.h b/Source/WebCore/css/StyleBuilderConverter.h >index 481c458ee3a..d10f0399ca6 100644 >--- a/Source/WebCore/css/StyleBuilderConverter.h >+++ b/Source/WebCore/css/StyleBuilderConverter.h >@@ -115,6 +115,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&); >@@ -1276,6 +1277,11 @@ inline bool StyleBuilderConverter::convertOverflowScrolling(StyleResolver&, cons > } > #endif > >+inline bool StyleBuilderConverter::convertSmoothScrolling(StyleResolver&, const CSSValue& value) >+{ >+ return downcast<CSSPrimitiveValue>(value).valueID() == CSSValueSmooth; >+} >+ > inline SVGLengthValue StyleBuilderConverter::convertSVGLengthValue(StyleResolver&, const CSSValue& value) > { > return SVGLengthValue::fromCSSPrimitiveValue(downcast<CSSPrimitiveValue>(value)); >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index 2263349c220..418213d3735 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -692,17 +692,16 @@ void Element::scrollIntoViewIfNotVisible(bool centerIfNotVisible) > > void Element::scrollBy(const ScrollToOptions& options) > { >- return scrollBy(options.left.value_or(0), options.top.value_or(0)); >-} >- >-static inline double normalizeNonFiniteValue(double f) >-{ >- return std::isfinite(f) ? f : 0; >+ ScrollToOptions scrollToOptions = options; >+ scrollToOptions.normalizeNonFiniteCoordinatesOrFallbackTo(0, 0); >+ scrollToOptions.left = scrollToOptions.left.value() + scrollLeft(); >+ scrollToOptions.top = scrollToOptions.top.value() + scrollTop(); >+ return scrollTo(scrollToOptions); > } > > void Element::scrollBy(double x, double y) > { >- scrollTo(scrollLeft() + normalizeNonFiniteValue(x), scrollTop() + normalizeNonFiniteValue(y)); >+ scrollBy(ScrollToOptions::fromCoordinates(x, y)); > } > > void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) >@@ -720,17 +719,24 @@ void Element::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) > if (!renderer || !renderer->hasOverflowClip()) > return; > >- // Normalize non-finite values for left and top dictionary members of options, if present. >- double x = options.left ? normalizeNonFiniteValue(options.left.value()) : adjustForAbsoluteZoom(renderer->scrollLeft(), *renderer); >- double y = options.top ? normalizeNonFiniteValue(options.top.value()) : adjustForAbsoluteZoom(renderer->scrollTop(), *renderer); >+ ScrollToOptions scrollToOptions = options; >+ scrollToOptions.normalizeNonFiniteCoordinatesOrFallbackTo( >+ adjustForAbsoluteZoom(renderer->scrollLeft(), *renderer), >+ adjustForAbsoluteZoom(renderer->scrollTop(), *renderer) >+ ); > >- renderer->setScrollLeft(clampToInteger(x * renderer->style().effectiveZoom()), clamping); >- renderer->setScrollTop(clampToInteger(y * renderer->style().effectiveZoom()), clamping); >+ if (scrollToOptions.useSmoothScrolling(this)) { >+ ASSERT_NOT_IMPLEMENTED_YET(); >+ return; >+ } >+ >+ renderer->setScrollLeft(clampToInteger(scrollToOptions.left.value() * renderer->style().effectiveZoom()), clamping); >+ renderer->setScrollTop(clampToInteger(scrollToOptions.top.value() * renderer->style().effectiveZoom()), clamping); > } > > void Element::scrollTo(double x, double y) > { >- scrollTo({ x, y }); >+ scrollTo(ScrollToOptions::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 813fcaf5525..3f9be7d70f6 100644 >--- a/Source/WebCore/page/DOMWindow.cpp >+++ b/Source/WebCore/page/DOMWindow.cpp >@@ -1574,12 +1574,12 @@ double DOMWindow::devicePixelRatio() const > return page->deviceScaleFactor(); > } > >-void DOMWindow::scrollBy(const ScrollToOptions& options) const >+void DOMWindow::scrollBy(double x, double y) const > { >- return scrollBy(options.left.value_or(0), options.top.value_or(0)); >+ return scrollBy(ScrollToOptions::fromCoordinates(x, y)); > } > >-void DOMWindow::scrollBy(double x, double y) const >+void DOMWindow::scrollBy(const ScrollToOptions& options) const > { > if (!isCurrentlyDisplayedInFrame()) > return; >@@ -1590,29 +1590,26 @@ void DOMWindow::scrollBy(double x, double y) const > if (!view) > return; > >- // Normalize non-finite values (https://drafts.csswg.org/cssom-view/#normalize-non-finite-values). >- x = std::isfinite(x) ? x : 0; >- y = std::isfinite(y) ? y : 0; >+ ScrollToOptions scrollToOptions = options; >+ scrollToOptions.normalizeNonFiniteCoordinatesOrFallbackTo(0, 0); > >- IntSize scaledOffset(view->mapFromCSSToLayoutUnits(x), view->mapFromCSSToLayoutUnits(y)); >+ // FIXME: should we use document()->scrollingElement()? >+ // See https://github.com/w3c/csswg-drafts/issues/2977 >+ if (scrollToOptions.useSmoothScrolling(document()->documentElement())) { >+ ASSERT_NOT_IMPLEMENTED_YET(); >+ return; >+ } >+ >+ IntSize scaledOffset(view->mapFromCSSToLayoutUnits(*scrollToOptions.left), view->mapFromCSSToLayoutUnits(*scrollToOptions.top)); > view->setContentsScrollPosition(view->contentsScrollPosition() + scaledOffset); > } > >-void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping clamping) const >+void DOMWindow::scrollTo(double x, double y, ScrollClamping clamping) const > { >- if (!isCurrentlyDisplayedInFrame()) >- return; >- >- RefPtr<FrameView> view = m_frame->view(); >- if (!view) >- return; >- >- double x = options.left ? options.left.value() : view->contentsScrollPosition().x(); >- double y = options.top ? options.top.value() : view->contentsScrollPosition().y(); >- return scrollTo(x, y, clamping); >+ return scrollTo(ScrollToOptions::fromCoordinates(x, y), clamping); > } > >-void DOMWindow::scrollTo(double x, double y, ScrollClamping) const >+void DOMWindow::scrollTo(const ScrollToOptions& options, ScrollClamping) const > { > if (!isCurrentlyDisplayedInFrame()) > return; >@@ -1621,16 +1618,25 @@ void DOMWindow::scrollTo(double x, double y, ScrollClamping) const > if (!view) > return; > >- // Normalize non-finite values (https://drafts.csswg.org/cssom-view/#normalize-non-finite-values). >- x = std::isfinite(x) ? x : 0; >- y = std::isfinite(y) ? y : 0; >+ ScrollToOptions scrollToOptions = options; >+ scrollToOptions.normalizeNonFiniteCoordinatesOrFallbackTo( >+ view->contentsScrollPosition().x(), >+ view->contentsScrollPosition().y() >+ ); > >- if (!x && !y && view->contentsScrollPosition() == IntPoint(0, 0)) >+ if (!scrollToOptions.left.value() && !scrollToOptions.top.value() && view->contentsScrollPosition() == IntPoint(0, 0)) > return; > > document()->updateLayoutIgnorePendingStylesheets(); > >- IntPoint layoutPos(view->mapFromCSSToLayoutUnits(x), view->mapFromCSSToLayoutUnits(y)); >+ // FIXME: should we use document()->scrollingElement()? >+ // See https://github.com/w3c/csswg-drafts/issues/2977 >+ if (scrollToOptions.useSmoothScrolling(document()->documentElement())) { >+ ASSERT_NOT_IMPLEMENTED_YET(); >+ return; >+ } >+ >+ IntPoint layoutPos(view->mapFromCSSToLayoutUnits(*scrollToOptions.left), view->mapFromCSSToLayoutUnits(*scrollToOptions.top)); > view->setContentsScrollPosition(layoutPos); > } > >diff --git a/Source/WebCore/page/ScrollBehavior.h b/Source/WebCore/page/ScrollBehavior.h >new file mode 100644 >index 00000000000..a3103ba4e19 >--- /dev/null >+++ b/Source/WebCore/page/ScrollBehavior.h >@@ -0,0 +1,31 @@ >+/* >+ * 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 { >+ >+enum class ScrollBehavior { >+ Auto = 0, >+ Instant, >+ Smooth >+}; >+ >+} >+ >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/ScrollOptions.cpp b/Source/WebCore/page/ScrollOptions.cpp >new file mode 100644 >index 00000000000..67b02fa2d7f >--- /dev/null >+++ b/Source/WebCore/page/ScrollOptions.cpp >@@ -0,0 +1,47 @@ >+/* >+ * 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 "ScrollOptions.h" >+ >+#include "Element.h" >+#include "RenderElement.h" >+#include "RenderStyle.h" >+ >+namespace WebCore { >+ >+bool ScrollOptions::useSmoothScrolling(Element* associatedElement) const >+{ >+ if (!associatedElement || !associatedElement->renderer()) >+ return false; >+ >+ // https://drafts.csswg.org/cssom-view/#scrolling >+ switch (behavior.value_or(ScrollBehavior::Auto)) { >+ case ScrollBehavior::Auto: >+ return associatedElement->renderer()->style().useSmoothScrolling(); >+ case ScrollBehavior::Instant: >+ return false; >+ case ScrollBehavior::Smooth: >+ return true; >+ } >+ ASSERT_NOT_REACHED(); >+ return false; >+} >+ >+} >diff --git a/Source/WebCore/page/ScrollOptions.h b/Source/WebCore/page/ScrollOptions.h >new file mode 100644 >index 00000000000..3b5e95ad177 >--- /dev/null >+++ b/Source/WebCore/page/ScrollOptions.h >@@ -0,0 +1,33 @@ >+/* >+ * 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 { >+ >+class Element; >+ >+struct ScrollOptions { >+ std::optional<ScrollBehavior> behavior { ScrollBehavior::Auto }; >+ bool useSmoothScrolling(Element*) const; >+}; >+ >+} >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 84a9d9ddb28..5540202557f 100644 >--- a/Source/WebCore/page/ScrollToOptions.h >+++ b/Source/WebCore/page/ScrollToOptions.h >@@ -28,13 +28,30 @@ > > #pragma once > >+#include "ScrollOptions.h" >+#include <math.h> > #include <wtf/Optional.h> > > namespace WebCore { > >-struct ScrollToOptions { >+struct ScrollToOptions : ScrollOptions { > std::optional<double> left; > std::optional<double> top; >+ >+ static ScrollToOptions fromCoordinates(double x, double y) >+ { >+ ScrollToOptions options; >+ options.left = x; >+ options.top = y; >+ return options; >+ }; >+ >+ void normalizeNonFiniteCoordinatesOrFallbackTo(double x, double y) >+ { >+ // Normalize non-finite values (https://drafts.csswg.org/cssom-view/#normalize-non-finite-values). >+ left = left ? (std::isfinite(left.value()) ? left.value() : 0) : x; >+ top = top ? (std::isfinite(top.value()) ? top.value() : 0) : y; >+ }; > }; > > } >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/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h >index 327dd2b3de1..1c69fbeaf52 100644 >--- a/Source/WebCore/rendering/style/RenderStyle.h >+++ b/Source/WebCore/rendering/style/RenderStyle.h >@@ -723,6 +723,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 >@@ -1232,6 +1234,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 >@@ -1658,6 +1662,8 @@ public: > static bool initialUseTouchOverflowScrolling() { return false; } > #endif > >+ static bool initialUseSmoothScrolling() { return false; } >+ > #if ENABLE(DASHBOARD_SUPPORT) > static const Vector<StyleDashboardRegion>& initialDashboardRegions(); > static const Vector<StyleDashboardRegion>& noneDashboardRegions(); >diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp >index d925fc6080f..47b12cf4d48 100644 >--- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp >+++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp >@@ -78,6 +78,7 @@ StyleRareNonInheritedData::StyleRareNonInheritedData() > #if ENABLE(TOUCH_EVENTS) > , touchAction(static_cast<unsigned>(RenderStyle::initialTouchAction())) > #endif >+ , useSmoothScrolling(static_cast<unsigned>(RenderStyle::initialUseSmoothScrolling())) > , pageSizeType(PAGE_SIZE_AUTO) > , transformStyle3D(static_cast<unsigned>(RenderStyle::initialTransformStyle3D())) > , backfaceVisibility(static_cast<unsigned>(RenderStyle::initialBackfaceVisibility())) >@@ -170,6 +171,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) >@@ -282,6 +284,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 089ccfa438c..31fa47295de 100644 >--- a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h >+++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h >@@ -175,6 +175,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 d3e45295df9..76e89972a77 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -1621,7 +1621,7 @@ ExceptionOr<void> Internals::unconstrainedScrollTo(Element& element, double x, d > if (!document || !document->view()) > return Exception { InvalidAccessError }; > >- element.scrollTo({ x, y }, ScrollClamping::Unclamped); >+ element.scrollTo(ScrollToOptions::fromCoordinates(x, y), ScrollClamping::Unclamped); > return { }; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188043
:
346381
|
346513
|
346627
|
348010
|
348493
|
348494
|
348500
|
348903
|
348904
|
349043
|
349393
|
349536
|
349668
|
349879
|
350255
|
350271
|
350286
|
350288
|
350309
|
350409
|
350566
|
350567
|
350568
|
350571
|
350572
|
350579
|
350610
|
350615
|
350617
|
350620
|
350621
|
353958
|
353960
|
354071
|
354079
|
354082
|
354086
|
354319
|
354320
|
356043
|
356151
|
358313
|
363090
|
363093
|
368453
|
368454
|
368455
|
368459
|
368460
|
372999
|
377582
|
377813
|
378193
|
382485
|
382550
|
382561
|
384462
|
384514
|
384517
|
384623
|
384720
|
384789
|
384800
|
440977