Add basic support for ScrollIntoViewOptions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 05:19:58 +0000 (05:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 05:19:58 +0000 (05:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189258

Patch by Frederic Wang <fwang@igalia.com> on 2018-09-04
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Update test expectations for WPT scrollIntoView tests.

* web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt: This is not
supported yet but update the error message.
* web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt: Ditto.
* web-platform-tests/css/cssom-view/scrollIntoView-shadow-expected.txt: Update expectation
now that this test passes.
* web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt: Ditto.
* web-platform-tests/css/cssom-view/scrollintoview-expected.txt: Ditto.

Source/WebCore:

This patch introduces a new ScrollIntoViewOptions parameter that can be passed into
Element.scrollIntoView instead of a boolean. A basic support for scroll alignments is
implemented, so that it is closer to the behavior of the CSSOMView spec while still remaining
compatible with the current boolean-parameter implementation. Full implementation that
takes into account orientation/direction will be handled in bug 161611. This patch is also a
preliminary step to support the ScrollBehavior (bug 188043) for ScrollIntoView.

Tests: web-platform-tests/css/cssom-view/scrollintoview-html
       web-platform-tests/css/cssom-view/scrollIntoView-smooth.html

* CMakeLists.txt: Add new IDL files.
* DerivedSources.make: Ditto.
* Sources.txt: Add new generated cpp JS bindings.
* WebCore.xcodeproj/project.pbxproj: Add files to build to XCode.
* dom/Element.cpp:
(WebCore::toScrollAlignment): Convert ScrollLogicalPosition to scroll alignment. Orientation
and direction are not implemented yet.
(WebCore::Element::scrollIntoView): Implement new scrollIntoView version accepting
ScrollIntoViewOptions parameter.
* dom/Element.h: Declare new scrollIntoView.
* dom/Element.idl: Make scrollIntoView accept a ScrollIntoViewOptions parameter.
* page/ScrollIntoViewOptions.h: Added.
* page/ScrollIntoViewOptions.idl: Added.
* page/ScrollLogicalPosition.h: Added.
* page/ScrollLogicalPosition.idl: Added.

Source/WebKit:

* DOM/DOMElement.mm: Add ScrollIntoViewOptions
header so that this file can build despite the new scrollIntoView function.

Source/WebKitLegacy/mac:

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElementGtk.cpp: Add ScrollIntoViewOptions
header so that this file can build despite the new scrollIntoView function.

Source/WebKitLegacy/win:

* DOMCoreClasses.cpp: Add ScrollIntoViewOptions header so that this file
can build despite the new scrollIntoView function.

LayoutTests:

Update test expectations for WPT scrollIntoView tests.

* platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235659 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-shadow-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/scrollintoview-expected.txt
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt [deleted file]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Element.idl
Source/WebCore/page/ScrollIntoViewOptions.h [new file with mode: 0644]
Source/WebCore/page/ScrollIntoViewOptions.idl [new file with mode: 0644]
Source/WebCore/page/ScrollLogicalPosition.h [new file with mode: 0644]
Source/WebCore/page/ScrollLogicalPosition.idl [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElementGtk.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/DOM/DOMElement.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/DOMCoreClasses.cpp

index ac04de1..2c5c3a5 100644 (file)
@@ -1,3 +1,14 @@
+2018-09-04  Frederic Wang  <fwang@igalia.com>
+
+        Add basic support for ScrollIntoViewOptions
+        https://bugs.webkit.org/show_bug.cgi?id=189258
+
+        Reviewed by Simon Fraser.
+
+        Update test expectations for WPT scrollIntoView tests.
+
+        * platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt: Removed.
+
 2018-09-04  Michael Saboff  <msaboff@apple.com>
 
         YARR: Add new RegExp back reference tests to specifically test back reference JIT code
index a8ef33d..cf7b31b 100644 (file)
@@ -1,3 +1,20 @@
+2018-09-04  Frederic Wang  <fwang@igalia.com>
+
+        Add basic support for ScrollIntoViewOptions
+        https://bugs.webkit.org/show_bug.cgi?id=189258
+
+        Reviewed by Simon Fraser.
+
+        Update test expectations for WPT scrollIntoView tests.
+
+        * web-platform-tests/css/cssom-view/scrollIntoView-scrollMargin-expected.txt: This is not
+        supported yet but update the error message.
+        * web-platform-tests/css/cssom-view/scrollIntoView-scrollPadding-expected.txt: Ditto.
+        * web-platform-tests/css/cssom-view/scrollIntoView-shadow-expected.txt: Update expectation
+        now that this test passes.
+        * web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt: Ditto.
+        * web-platform-tests/css/cssom-view/scrollintoview-expected.txt: Ditto.
+
 2018-09-04  Oriol Brufau  <obrufau@igalia.com>
 
         Check important flags when serializing shorthand with "initial" values
index 65bb1b9..787936d 100644 (file)
@@ -1,5 +1,5 @@
 
-FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 115
-FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 115
+FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 158
+FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 200
 FAIL scrollIntoView({block: "end", inline: "end"}) assert_approx_equals: scrollX expected 123 +/- 0.5 but got 115
 
index 65bb1b9..787936d 100644 (file)
@@ -1,5 +1,5 @@
 
-FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 115
-FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 115
+FAIL scrollIntoView({block: "center", inline: "center"}) assert_approx_equals: scrollX expected 153.5 +/- 0.5 but got 158
+FAIL scrollIntoView({block: "start", inline: "start"}) assert_approx_equals: scrollX expected 184 +/- 0.5 but got 200
 FAIL scrollIntoView({block: "end", inline: "end"}) assert_approx_equals: scrollX expected 123 +/- 0.5 but got 115
 
index e40fa2d..d972497 100644 (file)
@@ -1,3 +1,3 @@
 
-FAIL scrollIntoView should behave correctly if applies to shadow dom elements assert_approx_equals: expected 8 +/- 1 but got 0
+PASS scrollIntoView should behave correctly if applies to shadow dom elements 
 
index 72df3e8..4e16850 100644 (file)
@@ -1,6 +1,6 @@
 
-FAIL Smooth scrollIntoView should scroll the element to the 'nearest' position assert_approx_equals: scrollY expected 915 +/- 1 but got 1000
-FAIL Smooth scrollIntoView should scroll the element to the 'start' position assert_approx_equals: scrollX expected 1008 +/- 1 but got 723
-FAIL Smooth scrollIntoView should scroll the element to the 'center' position assert_approx_equals: scrollX expected 865.5 +/- 1 but got 723
-FAIL Smooth scrollIntoView should scroll the element to the 'end' position assert_approx_equals: scrollY expected 915 +/- 1 but got 1000
+PASS Smooth scrollIntoView should scroll the element to the 'nearest' position 
+PASS Smooth scrollIntoView should scroll the element to the 'start' position 
+PASS Smooth scrollIntoView should scroll the element to the 'center' position 
+PASS Smooth scrollIntoView should scroll the element to the 'end' position 
 
index f7288d1..cd307f7 100644 (file)
@@ -15,28 +15,28 @@ PASS scrollIntoView(undefined) starting at left,top
 PASS scrollIntoView(undefined) starting at left,bottom 
 PASS scrollIntoView(undefined) starting at right,top 
 PASS scrollIntoView(undefined) starting at right,bottom 
-FAIL scrollIntoView(null) starting at left,top assert_approx_equals: scrollY expected 4000 +/- 0.5 but got 3600
-FAIL scrollIntoView(null) starting at left,bottom assert_approx_equals: scrollY expected 4000 +/- 0.5 but got 3600
-FAIL scrollIntoView(null) starting at right,top assert_approx_equals: scrollY expected 4000 +/- 0.5 but got 3600
-FAIL scrollIntoView(null) starting at right,bottom assert_approx_equals: scrollY expected 4000 +/- 0.5 but got 3600
+PASS scrollIntoView(null) starting at left,top 
+PASS scrollIntoView(null) starting at left,bottom 
+PASS scrollIntoView(null) starting at right,top 
+PASS scrollIntoView(null) starting at right,bottom 
 PASS scrollIntoView({}) starting at left,top 
 PASS scrollIntoView({}) starting at left,bottom 
 PASS scrollIntoView({}) starting at right,top 
 PASS scrollIntoView({}) starting at right,bottom 
-FAIL scrollIntoView({block: "center", inline: "center"}) starting at left,top assert_approx_equals: scrollX expected 3700 +/- 0.5 but got 3400
-FAIL scrollIntoView({block: "center", inline: "center"}) starting at left,bottom assert_approx_equals: scrollX expected 3700 +/- 0.5 but got 3400
-FAIL scrollIntoView({block: "center", inline: "center"}) starting at right,top assert_approx_equals: scrollX expected 3700 +/- 0.5 but got 4000
-FAIL scrollIntoView({block: "center", inline: "center"}) starting at right,bottom assert_approx_equals: scrollX expected 3700 +/- 0.5 but got 4000
-FAIL scrollIntoView({block: "start", inline: "start"}) starting at left,top assert_approx_equals: scrollX expected 4000 +/- 0.5 but got 3400
-FAIL scrollIntoView({block: "start", inline: "start"}) starting at left,bottom assert_approx_equals: scrollX expected 4000 +/- 0.5 but got 3400
+PASS scrollIntoView({block: "center", inline: "center"}) starting at left,top 
+PASS scrollIntoView({block: "center", inline: "center"}) starting at left,bottom 
+PASS scrollIntoView({block: "center", inline: "center"}) starting at right,top 
+PASS scrollIntoView({block: "center", inline: "center"}) starting at right,bottom 
+PASS scrollIntoView({block: "start", inline: "start"}) starting at left,top 
+PASS scrollIntoView({block: "start", inline: "start"}) starting at left,bottom 
 PASS scrollIntoView({block: "start", inline: "start"}) starting at right,top 
 PASS scrollIntoView({block: "start", inline: "start"}) starting at right,bottom 
-FAIL scrollIntoView({block: "end", inline: "end"}) starting at left,top assert_approx_equals: scrollY expected 3600 +/- 0.5 but got 4000
-FAIL scrollIntoView({block: "end", inline: "end"}) starting at left,bottom assert_approx_equals: scrollY expected 3600 +/- 0.5 but got 4000
-FAIL scrollIntoView({block: "end", inline: "end"}) starting at right,top assert_approx_equals: scrollX expected 3400 +/- 0.5 but got 4000
-FAIL scrollIntoView({block: "end", inline: "end"}) starting at right,bottom assert_approx_equals: scrollX expected 3400 +/- 0.5 but got 4000
-FAIL scrollIntoView({block: "nearest", inline: "nearest"}) starting at left,top assert_approx_equals: scrollY expected 3600 +/- 0.5 but got 4000
+PASS scrollIntoView({block: "end", inline: "end"}) starting at left,top 
+PASS scrollIntoView({block: "end", inline: "end"}) starting at left,bottom 
+PASS scrollIntoView({block: "end", inline: "end"}) starting at right,top 
+PASS scrollIntoView({block: "end", inline: "end"}) starting at right,bottom 
+PASS scrollIntoView({block: "nearest", inline: "nearest"}) starting at left,top 
 PASS scrollIntoView({block: "nearest", inline: "nearest"}) starting at left,bottom 
-FAIL scrollIntoView({block: "nearest", inline: "nearest"}) starting at right,top assert_approx_equals: scrollY expected 3600 +/- 0.5 but got 4000
+PASS scrollIntoView({block: "nearest", inline: "nearest"}) starting at right,top 
 PASS scrollIntoView({block: "nearest", inline: "nearest"}) starting at right,bottom 
 
diff --git a/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt b/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom-view/scrollIntoView-smooth-expected.txt
deleted file mode 100644 (file)
index 9f4b95b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-
-FAIL Smooth scrollIntoView should scroll the element to the 'nearest' position assert_approx_equals: scrollY expected 900 +/- 1 but got 1000
-FAIL Smooth scrollIntoView should scroll the element to the 'start' position assert_approx_equals: scrollX expected 1008 +/- 1 but got 708
-FAIL Smooth scrollIntoView should scroll the element to the 'center' position assert_approx_equals: scrollX expected 858 +/- 1 but got 708
-FAIL Smooth scrollIntoView should scroll the element to the 'end' position assert_approx_equals: scrollY expected 900 +/- 1 but got 1000
-
index 2fdd331..ec77463 100644 (file)
@@ -831,6 +831,8 @@ set(WebCore_NON_SVG_IDL_FILES
     page/PerformanceTiming.idl
     page/RemoteDOMWindow.idl
     page/Screen.idl
+    page/ScrollIntoViewOptions.idl
+    page/ScrollLogicalPosition.idl
     page/ScrollToOptions.idl
     page/ShareData.idl
     page/VisualViewport.idl
index c8b708b..225cb67 100644 (file)
@@ -1,3 +1,36 @@
+2018-09-04  Frederic Wang  <fwang@igalia.com>
+
+        Add basic support for ScrollIntoViewOptions
+        https://bugs.webkit.org/show_bug.cgi?id=189258
+
+        Reviewed by Simon Fraser.
+
+        This patch introduces a new ScrollIntoViewOptions parameter that can be passed into
+        Element.scrollIntoView instead of a boolean. A basic support for scroll alignments is
+        implemented, so that it is closer to the behavior of the CSSOMView spec while still remaining
+        compatible with the current boolean-parameter implementation. Full implementation that
+        takes into account orientation/direction will be handled in bug 161611. This patch is also a
+        preliminary step to support the ScrollBehavior (bug 188043) for ScrollIntoView.
+
+        Tests: web-platform-tests/css/cssom-view/scrollintoview-html
+               web-platform-tests/css/cssom-view/scrollIntoView-smooth.html
+
+        * CMakeLists.txt: Add new IDL files.
+        * DerivedSources.make: Ditto.
+        * Sources.txt: Add new generated cpp JS bindings.
+        * WebCore.xcodeproj/project.pbxproj: Add files to build to XCode.
+        * dom/Element.cpp:
+        (WebCore::toScrollAlignment): Convert ScrollLogicalPosition to scroll alignment. Orientation
+        and direction are not implemented yet.
+        (WebCore::Element::scrollIntoView): Implement new scrollIntoView version accepting
+        ScrollIntoViewOptions parameter.
+        * dom/Element.h: Declare new scrollIntoView.
+        * dom/Element.idl: Make scrollIntoView accept a ScrollIntoViewOptions parameter.
+        * page/ScrollIntoViewOptions.h: Added.
+        * page/ScrollIntoViewOptions.idl: Added.
+        * page/ScrollLogicalPosition.h: Added.
+        * page/ScrollLogicalPosition.idl: Added.
+
 2018-09-04  Oriol Brufau  <obrufau@igalia.com>
 
         Check important flags when serializing shorthand with "initial" values
index 5b753d8..a940f94 100644 (file)
@@ -796,6 +796,8 @@ JS_BINDING_IDLS = \
     $(WebCore)/page/PerformanceTiming.idl \
     $(WebCore)/page/RemoteDOMWindow.idl \
     $(WebCore)/page/Screen.idl \
+    $(WebCore)/page/ScrollIntoViewOptions.idl \
+    $(WebCore)/page/ScrollLogicalPosition.idl \
     $(WebCore)/page/ScrollToOptions.idl \
     $(WebCore)/page/UserMessageHandler.idl \
     $(WebCore)/page/UserMessageHandlersNamespace.idl \
index d4cf50d..b614713 100644 (file)
@@ -3058,6 +3058,8 @@ JSSVGZoomEvent.cpp
 JSScreen.cpp
 JSScreenLuminance.cpp
 JSScriptProcessorNode.cpp
+JSScrollIntoViewOptions.cpp
+JSScrollLogicalPosition.cpp
 JSScrollToOptions.cpp
 JSSecurityPolicyViolationEvent.cpp
 JSServiceWorker.cpp
index 68ce908..a6452ca 100644 (file)
                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, ); }; };
+               834476EF1DA5BC5E002B5EB0 /* JSScrollLogicalPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFD8D4 /* JSScrollLogicalPosition.h */; };
+               834476EF1DA5BC5E002B5EC1 /* JSScrollIntoViewOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.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, ); }; };
                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, ); }; };
+               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, ); }; };
                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 */; };
                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>"; };
+               8350C3E71DA59B6200355424 /* ScrollLogicalPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollLogicalPosition.h; sourceTree = "<group>"; };
+               8350C3E81DA59B6200355424 /* ScrollLogicalPosition.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollLogicalPosition.idl; sourceTree = "<group>"; };
+               8350C3E71DA59B6200355435 /* ScrollIntoViewOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollIntoViewOptions.h; sourceTree = "<group>"; };
+               8350C3E81DA59B6200355435 /* ScrollIntoViewOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollIntoViewOptions.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>"; };
                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>"; };
+               83E9B3001DA5A51E00FFD8D4 /* JSScrollLogicalPosition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollLogicalPosition.cpp; sourceTree = "<group>"; };
+               83E9B3011DA5A51E00FFD8D4 /* JSScrollLogicalPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollLogicalPosition.h; sourceTree = "<group>"; };
+               83E9B3001DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollIntoViewOptions.cpp; sourceTree = "<group>"; };
+               83E9B3011DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollIntoViewOptions.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>"; };
                                BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */,
                                BCEC01BB0C274DAC009F4EC9 /* Screen.h */,
                                BCEC01BC0C274DAC009F4EC9 /* Screen.idl */,
+                               8350C3E71DA59B6200355435 /* ScrollIntoViewOptions.h */,
+                               8350C3E81DA59B6200355435 /* ScrollIntoViewOptions.idl */,
+                               8350C3E71DA59B6200355424 /* ScrollLogicalPosition.h */,
+                               8350C3E81DA59B6200355424 /* ScrollLogicalPosition.idl */,
                                8350C3E71DA59B6200356446 /* ScrollToOptions.h */,
                                8350C3E81DA59B6200356446 /* ScrollToOptions.idl */,
                                BCD0E0F70E972C3500265DEA /* SecurityOrigin.cpp */,
                                46C376612085176D00C73829 /* JSRemoteDOMWindow.h */,
                                BCEC01C00C274DDD009F4EC9 /* JSScreen.cpp */,
                                BCEC01C10C274DDD009F4EC9 /* JSScreen.h */,
+                               83E9B3001DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.cpp */,
+                               83E9B3011DA5A51E00FFD8E5 /* JSScrollIntoViewOptions.h */,
+                               83E9B3001DA5A51E00FFD8D4 /* JSScrollLogicalPosition.cpp */,
+                               83E9B3011DA5A51E00FFD8D4 /* JSScrollLogicalPosition.h */,
                                83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */,
                                83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */,
                                7C73FB0F191EF6F4007DE061 /* JSUserMessageHandler.cpp */,
                                5E2C436C1BCF071E0001E2BC /* JSRTCTrackEvent.h in Headers */,
                                BCEC01C30C274DDD009F4EC9 /* JSScreen.h in Headers */,
                                FDA15ECE12B03F61003A583A /* JSScriptProcessorNode.h in Headers */,
+                               834476EF1DA5BC5E002B5EC1 /* JSScrollIntoViewOptions.h in Headers */,
+                               834476EF1DA5BC5E002B5EB0 /* JSScrollLogicalPosition.h in Headers */,
                                834476EF1DA5BC5E002B6ED2 /* JSScrollToOptions.h in Headers */,
                                CED06AD11C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.h in Headers */,
                                5182C2561F3143CD0059BA7C /* JSServiceWorker.h in Headers */,
                                9391A99D1629D70000297330 /* ScrollingTreeScrollingNode.h in Headers */,
                                A6D5A99D1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h in Headers */,
                                0FB8890A167D2FA10010CDA5 /* ScrollingTreeStickyNode.h in Headers */,
+                               83C5795D1DA5C301006F9C97 /* ScrollIntoViewOptions.h in Headers */,
                                7AAFE8D019CB8672000F56D8 /* ScrollLatchingState.h in Headers */,
+                               83C5795D1DA5C301006F9C86 /* ScrollLogicalPosition.h in Headers */,
                                F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */,
                                F46729281E0DE68500ACC3D8 /* ScrollSnapOffsetsInfo.h in Headers */,
                                83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */,
index b78da9c..6fa86b1 100644 (file)
@@ -91,6 +91,7 @@
 #include "SVGNames.h"
 #include "SVGSVGElement.h"
 #include "ScriptDisallowedScope.h"
+#include "ScrollIntoViewOptions.h"
 #include "ScrollLatchingState.h"
 #include "SelectorQuery.h"
 #include "Settings.h"
@@ -651,6 +652,49 @@ void Element::setHovered(bool flag)
         renderer()->theme().stateChanged(*renderer(), ControlStates::HoverState);
 }
 
+// FIXME(webkit.org/b/161611): Take into account orientation/direction.
+inline ScrollAlignment toScrollAlignment(std::optional<ScrollLogicalPosition> position, bool isVertical)
+{
+    switch (position.value_or(isVertical ? ScrollLogicalPosition::Start : ScrollLogicalPosition::Nearest)) {
+    case ScrollLogicalPosition::Start:
+        return isVertical ? ScrollAlignment::alignTopAlways : ScrollAlignment::alignLeftAlways;
+    case ScrollLogicalPosition::Center:
+        return ScrollAlignment::alignCenterAlways;
+    case ScrollLogicalPosition::End:
+        return isVertical ? ScrollAlignment::alignBottomAlways : ScrollAlignment::alignRightAlways;
+    case ScrollLogicalPosition::Nearest:
+        return ScrollAlignment::alignToEdgeIfNeeded;
+    default:
+        ASSERT_NOT_REACHED();
+        return ScrollAlignment::alignToEdgeIfNeeded;
+    }
+}
+
+void Element::scrollIntoView(std::optional<Variant<bool, ScrollIntoViewOptions>>&& arg)
+{
+    document().updateLayoutIgnorePendingStylesheets();
+
+    if (!renderer())
+        return;
+
+    bool insideFixed;
+    LayoutRect absoluteBounds = renderer()->absoluteAnchorRect(&insideFixed);
+
+    // FIXME(webkit.org/b/188043): Support ScrollBehavior.
+    ScrollIntoViewOptions options;
+    if (arg) {
+        auto value = arg.value();
+        if (WTF::holds_alternative<ScrollIntoViewOptions>(value))
+            options = WTF::get<ScrollIntoViewOptions>(value);
+        else if (!WTF::get<bool>(value))
+            options.blockPosition = ScrollLogicalPosition::End;
+    }
+
+    ScrollAlignment alignX = toScrollAlignment(options.inlinePosition, false);
+    ScrollAlignment alignY = toScrollAlignment(options.blockPosition, true);
+    renderer()->scrollRectToVisible(SelectionRevealMode::Reveal, absoluteBounds, insideFixed, alignX, alignY, ShouldAllowCrossOriginScrolling::No);
+}
+
 void Element::scrollIntoView(bool alignToTop) 
 {
     document().updateLayoutIgnorePendingStylesheets();
index f94cce0..c83f508 100644 (file)
@@ -55,6 +55,7 @@ class PseudoElement;
 class RenderTreePosition;
 class WebAnimation;
 struct ElementStyle;
+struct ScrollIntoViewOptions;
 
 #if ENABLE(INTERSECTION_OBSERVER)
 struct IntersectionObserverData;
@@ -141,6 +142,7 @@ public:
     unsigned findAttributeIndexByName(const QualifiedName& name) const { return elementData()->findAttributeIndexByName(name); }
     unsigned findAttributeIndexByName(const AtomicString& name, bool shouldIgnoreAttributeCase) const { return elementData()->findAttributeIndexByName(name, shouldIgnoreAttributeCase); }
 
+    WEBCORE_EXPORT void scrollIntoView(std::optional<Variant<bool, ScrollIntoViewOptions>>&& arg);
     WEBCORE_EXPORT void scrollIntoView(bool alignToTop = true);
     WEBCORE_EXPORT void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
     WEBCORE_EXPORT void scrollIntoViewIfNotVisible(bool centerIfNotVisible = true);
index 7df36ec..9aed6c9 100644 (file)
@@ -71,7 +71,7 @@
     // CSSOM-view extensions (https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface).
     DOMRectList getClientRects();
     [NewObject] DOMRect getBoundingClientRect();
-    void scrollIntoView(optional boolean alignWithTop = true); // FIXME(webkit.org/b/161611): Parameter type should be (boolean or object).
+    void scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg);
     [ImplementedAs=scrollTo] void scroll(optional ScrollToOptions options);
     [ImplementedAs=scrollTo] void scroll(unrestricted double x, unrestricted double y);
     void scrollTo(optional ScrollToOptions options);
diff --git a/Source/WebCore/page/ScrollIntoViewOptions.h b/Source/WebCore/page/ScrollIntoViewOptions.h
new file mode 100644 (file)
index 0000000..328d2ec
--- /dev/null
@@ -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 "ScrollLogicalPosition.h"
+
+namespace WebCore {
+
+class Element;
+
+struct ScrollIntoViewOptions {
+    std::optional<ScrollLogicalPosition> blockPosition { ScrollLogicalPosition::Start };
+    std::optional<ScrollLogicalPosition> inlinePosition { ScrollLogicalPosition::Nearest };
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/page/ScrollIntoViewOptions.idl b/Source/WebCore/page/ScrollIntoViewOptions.idl
new file mode 100644 (file)
index 0000000..cf9d1fd
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+// FIXME(webkit.org/b/188043): Support ScrollBehavior.
+dictionary ScrollIntoViewOptions {
+    [ImplementedAs=blockPosition] ScrollLogicalPosition block = "start";
+    [ImplementedAs=inlinePosition] ScrollLogicalPosition inline = "nearest";
+};
diff --git a/Source/WebCore/page/ScrollLogicalPosition.h b/Source/WebCore/page/ScrollLogicalPosition.h
new file mode 100644 (file)
index 0000000..8d0a09f
--- /dev/null
@@ -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 ScrollLogicalPosition : uint8_t {
+    Start = 0,
+    Center,
+    End,
+    Nearest
+};
+
+}
diff --git a/Source/WebCore/page/ScrollLogicalPosition.idl b/Source/WebCore/page/ScrollLogicalPosition.idl
new file mode 100644 (file)
index 0000000..d7e59be
--- /dev/null
@@ -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 ScrollLogicalPosition { "start", "center", "end", "nearest" };
index 21eb296..266104c 100644 (file)
@@ -1,3 +1,13 @@
+2018-09-04  Frederic Wang  <fwang@igalia.com>
+
+        Add basic support for ScrollIntoViewOptions
+        https://bugs.webkit.org/show_bug.cgi?id=189258
+
+        Reviewed by Simon Fraser.
+
+        * DOM/DOMElement.mm: Add ScrollIntoViewOptions
+        header so that this file can build despite the new scrollIntoView function.
+
 2018-09-04  Chris Dumez  <cdumez@apple.com>
 
         Rename experimental feature for process swap on navigation
index bbce97f..a26cc72 100644 (file)
@@ -27,6 +27,7 @@
 #include "GObjectEventListener.h"
 #include <WebCore/HTMLNames.h>
 #include <WebCore/JSExecState.h>
+#include <WebCore/ScrollIntoViewOptions.h>
 #include <WebCore/StyledElement.h>
 #include "WebKitDOMAttrPrivate.h"
 #include "WebKitDOMCSSStyleDeclarationPrivate.h"
index b12e132..98813e4 100644 (file)
@@ -1,3 +1,13 @@
+2018-09-04  Frederic Wang  <fwang@igalia.com>
+
+        Add basic support for ScrollIntoViewOptions
+        https://bugs.webkit.org/show_bug.cgi?id=189258
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMElementGtk.cpp: Add ScrollIntoViewOptions
+        header so that this file can build despite the new scrollIntoView function.
+
 2018-09-04  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Populate "text/uri-list" with multiple URLs when the pasteboard contains multiple URLs
index 718b135..50b111a 100644 (file)
@@ -40,6 +40,7 @@
 #import <WebCore/JSExecState.h>
 #import <WebCore/NameNodeList.h>
 #import <WebCore/NodeList.h>
+#import <WebCore/ScrollIntoViewOptions.h>
 #import <WebCore/StyleProperties.h>
 #import <WebCore/StyledElement.h>
 #import <WebCore/ThreadCheck.h>
index c223b86..eebab74 100644 (file)
@@ -1,3 +1,13 @@
+2018-09-04  Frederic Wang  <fwang@igalia.com>
+
+        Add basic support for ScrollIntoViewOptions
+        https://bugs.webkit.org/show_bug.cgi?id=189258
+
+        Reviewed by Simon Fraser.
+
+        * DOMCoreClasses.cpp: Add ScrollIntoViewOptions header so that this file
+        can build despite the new scrollIntoView function.
+
 2018-08-31  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed Windows build fix after r235562.
index 6e4016c..c5880ea 100644 (file)
@@ -54,6 +54,7 @@
 #include <WebCore/Range.h>
 #include <WebCore/RenderElement.h>
 #include <WebCore/RenderTreeAsText.h>
+#include <WebCore/ScrollIntoViewOptions.h>
 #include <WebCore/StyledElement.h>
 
 #include <initguid.h>