script: Implement scrollIntoView (#38230)

This is an implementation for `scrollIntoView`. For now, it is called
when a certain element gains focus.

Testing: Existing WPT tests
Fixes: #24059

Signed-off-by: abdelrahman1234567 <abdelrahman.hossameldin.awadalla@huawei.com>
This commit is contained in:
Abdelrahman Hossam 2025-08-06 16:08:25 +08:00 committed by GitHub
parent dcb90bb85e
commit 17a269a8ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 492 additions and 318 deletions

View file

@ -1,4 +1,5 @@
[elementFromPoint.html]
expected: CRASH
[SVG element at x,y]
expected: FAIL

View file

@ -266,9 +266,6 @@
[Element interface: document.createElement("div") must inherit property "scrollIntoView([object Object\],[object Object\])" with the proper type]
expected: FAIL
[Element interface: calling scrollIntoView(optional (boolean or ScrollIntoViewOptions)) on document.createElement("img") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("img") must inherit property "convertQuadFromNode(DOMQuadInit, GeometryNode, optional ConvertCoordinateOptions)" with the proper type]
expected: FAIL
@ -278,9 +275,6 @@
[CSSPseudoElement interface: operation convertPointFromNode(DOMPointInit, GeometryNode, optional ConvertCoordinateOptions)]
expected: FAIL
[Element interface: document.createElementNS("x", "y") must inherit property "scrollIntoView(optional (boolean or ScrollIntoViewOptions))" with the proper type]
expected: FAIL
[Element interface: document.createElement("img") must inherit property "getBoxQuads(optional BoxQuadOptions)" with the proper type]
expected: FAIL
@ -401,15 +395,6 @@
[Text interface: calling getBoxQuads(optional BoxQuadOptions) on document.createTextNode("x") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: calling scrollIntoView(optional (boolean or ScrollIntoViewOptions)) on document.createElement("div") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("img") must inherit property "scrollIntoView(optional (boolean or ScrollIntoViewOptions))" with the proper type]
expected: FAIL
[Element interface: operation scrollIntoView(optional (boolean or ScrollIntoViewOptions))]
expected: FAIL
[Document interface: document must inherit property "convertPointFromNode(DOMPointInit, GeometryNode, optional ConvertCoordinateOptions)" with the proper type]
expected: FAIL
@ -422,12 +407,6 @@
[CSSPseudoElement interface: operation getBoxQuads(optional BoxQuadOptions)]
expected: FAIL
[Element interface: calling scrollIntoView(optional (boolean or ScrollIntoViewOptions)) on document.createElementNS("x", "y") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("div") must inherit property "scrollIntoView(optional (boolean or ScrollIntoViewOptions))" with the proper type]
expected: FAIL
[Element interface: document.createElementNS("x", "y") must inherit property "convertRectFromNode(DOMRectReadOnly, GeometryNode, optional ConvertCoordinateOptions)" with the proper type]
expected: FAIL

View file

@ -35,15 +35,6 @@
[Element with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollIntoView() with default behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollIntoView() with auto behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollIntoView() with instant behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL
@ -53,9 +44,6 @@
[Element with smooth scroll-behavior ; scrollIntoView() with auto behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scrollIntoView() with instant behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL

View file

@ -35,15 +35,6 @@
[Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollIntoView() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollIntoView() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollIntoView() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL
@ -53,9 +44,6 @@
[Main frame with smooth scroll-behavior ; scrollIntoView() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollIntoView() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL

View file

@ -1,15 +1,3 @@
[scroll-behavior-smooth-positions.html]
[Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollIntoView() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scrollIntoView() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollIntoView() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollIntoView() ]
expected: FAIL
[Make sure the page is ready for animation.]
expected: FAIL
expected: FAIL

View file

@ -35,15 +35,6 @@
[Subframe with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollIntoView() with default behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollIntoView() with auto behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollIntoView() with instant behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL
@ -53,9 +44,6 @@
[Subframe with smooth scroll-behavior ; scrollIntoView() with auto behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scrollIntoView() with instant behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL

View file

@ -1,3 +0,0 @@
[scrollIntoView-align-scrollport-covering-child.html]
[scrollIntoView scrolls scrollport-covering child in both axes]
expected: FAIL

View file

@ -1,15 +0,0 @@
[scrollIntoView-container.html]
[scrollIntoView() defaults to scrolling ancestors]
expected: FAIL
[scrollIntoView({container: 'all'}) scrolls ancestors]
expected: FAIL
[scrollIntoView({container: 'nearest'}) only scrolls nearest scroll container]
expected: FAIL
[scrollIntoView({container: 'nearest'}) doesn't stop at itself]
expected: FAIL
[scrollIntoView({container: 'nearest'}) doesn't propagate to outer frames]
expected: FAIL

View file

@ -1,4 +0,0 @@
[scrollIntoView-horizontal-partially-visible.html]
[scrollIntoView scrolls partially-visible child in both axes]
expected: FAIL

View file

@ -1,28 +0,0 @@
[scrollIntoView-horizontal-tb-writing-mode.html]
[scrollIntoView({"block":"center","inline":"center"})]
expected: FAIL
[scrollIntoView({"block":"end","inline":"start"})]
expected: FAIL
[scrollIntoView({"block":"start","inline":"center"})]
expected: FAIL
[scrollIntoView({"block":"center","inline":"start"})]
expected: FAIL
[scrollIntoView({"block":"start","inline":"start"})]
expected: FAIL
[scrollIntoView({"block":"end","inline":"center"})]
expected: FAIL
[scrollIntoView({"block":"end","inline":"end"})]
expected: FAIL
[scrollIntoView({"block":"start","inline":"end"})]
expected: FAIL
[scrollIntoView({"block":"center","inline":"end"})]
expected: FAIL

View file

@ -1,4 +0,0 @@
[scrollIntoView-inline-image.html]
[Scrolling an inline element with a large line height uses the bounding rect]
expected: FAIL

View file

@ -1,12 +1,13 @@
[scrollIntoView-multiple-nested.html]
expected: TIMEOUT
[Simultaneous smooth scrollIntoViews run to completion]
expected: FAIL
expected: TIMEOUT
[Simultaneous smooth,instant scrollIntoViews run to completion]
expected: FAIL
expected: NOTRUN
[Simultaneous instant,smooth scrollIntoViews run to completion]
expected: FAIL
expected: NOTRUN
[Simultaneous instant scrollIntoViews run to completion]
expected: FAIL
expected: NOTRUN

View file

@ -1,12 +1,13 @@
[scrollIntoView-multiple.html]
expected: TIMEOUT
[Simultaneous smooth scrollIntoViews run to completion]
expected: FAIL
expected: TIMEOUT
[Simultaneous smooth,instant scrollIntoViews run to completion]
expected: FAIL
expected: NOTRUN
[Simultaneous instant,smooth scrollIntoViews run to completion]
expected: FAIL
expected: NOTRUN
[Simultaneous instant scrollIntoViews run to completion]
expected: FAIL
expected: NOTRUN

View file

@ -1,4 +0,0 @@
[scrollIntoView-shadow.html]
[scrollIntoView should behave correctly if applies to shadow dom elements]
expected: FAIL

View file

@ -1,13 +1,13 @@
[scrollIntoView-smooth.html]
expected: TIMEOUT
[Smooth scrollIntoView should scroll the element to the 'center' position]
expected: FAIL
expected: NOTRUN
[Smooth scrollIntoView should scroll the element to the 'end' position]
expected: FAIL
expected: NOTRUN
[Smooth scrollIntoView should scroll the element to the 'nearest' position]
expected: FAIL
expected: TIMEOUT
[Smooth scrollIntoView should scroll the element to the 'start' position]
expected: FAIL
expected: NOTRUN

View file

@ -1,7 +1,4 @@
[scrollIntoView-vertical-lr-writing-mode.html]
[scrollIntoView({"block":"center","inline":"center"})]
expected: FAIL
[scrollIntoView({"block":"end","inline":"start"})]
expected: FAIL
@ -11,18 +8,11 @@
[scrollIntoView({"block":"center","inline":"start"})]
expected: FAIL
[scrollIntoView({"block":"start","inline":"start"})]
expected: FAIL
[scrollIntoView({"block":"end","inline":"center"})]
expected: FAIL
[scrollIntoView({"block":"end","inline":"end"})]
expected: FAIL
[scrollIntoView({"block":"start","inline":"end"})]
expected: FAIL
[scrollIntoView({"block":"center","inline":"end"})]
expected: FAIL

View file

@ -1,3 +0,0 @@
[scrollintoview-containingblock-chain.html]
[scrollIntoView should not scroll ancestor overflow:scroll elements that are not containing block ancestors]
expected: FAIL

View file

@ -1,121 +0,0 @@
[scrollintoview.html]
[scrollIntoView(null) starting at right,top]
expected: FAIL
[scrollIntoView({block: "start", inline: "start"}) starting at right,top]
expected: FAIL
[scrollIntoView({block: "nearest", inline: "nearest"}) starting at left,top]
expected: FAIL
[scrollIntoView(false) starting at right,top]
expected: FAIL
[scrollIntoView({block: "end", inline: "end"}) starting at right,top]
expected: FAIL
[scrollIntoView() starting at right,top]
expected: FAIL
[scrollIntoView(undefined) starting at left,bottom]
expected: FAIL
[scrollIntoView(false) starting at left,bottom]
expected: FAIL
[scrollIntoView({}) starting at right,top]
expected: FAIL
[scrollIntoView({block: "end", inline: "end"}) starting at left,top]
expected: FAIL
[scrollIntoView() starting at right,bottom]
expected: FAIL
[scrollIntoView({block: "nearest", inline: "nearest"}) starting at right,top]
expected: FAIL
[scrollIntoView(undefined) starting at right,bottom]
expected: FAIL
[scrollIntoView(true) starting at left,top]
expected: FAIL
[scrollIntoView({block: "start", inline: "start"}) starting at left,top]
expected: FAIL
[scrollIntoView({block: "center", inline: "center"}) starting at left,bottom]
expected: FAIL
[scrollIntoView({block: "end", inline: "end"}) starting at left,bottom]
expected: FAIL
[scrollIntoView(true) starting at left,bottom]
expected: FAIL
[scrollIntoView({block: "center", inline: "center"}) starting at right,bottom]
expected: FAIL
[scrollIntoView(true) starting at right,bottom]
expected: FAIL
[scrollIntoView({block: "nearest", inline: "nearest"}) starting at right,bottom]
expected: FAIL
[scrollIntoView(false) starting at right,bottom]
expected: FAIL
[scrollIntoView({}) starting at right,bottom]
expected: FAIL
[scrollIntoView({block: "center", inline: "center"}) starting at right,top]
expected: FAIL
[scrollIntoView(false) starting at left,top]
expected: FAIL
[scrollIntoView() starting at left,top]
expected: FAIL
[scrollIntoView(undefined) starting at left,top]
expected: FAIL
[scrollIntoView({}) starting at left,top]
expected: FAIL
[scrollIntoView({block: "end", inline: "end"}) starting at right,bottom]
expected: FAIL
[scrollIntoView(null) starting at right,bottom]
expected: FAIL
[scrollIntoView(null) starting at left,top]
expected: FAIL
[scrollIntoView({block: "start", inline: "start"}) starting at right,bottom]
expected: FAIL
[scrollIntoView({block: "center", inline: "center"}) starting at left,top]
expected: FAIL
[scrollIntoView({block: "nearest", inline: "nearest"}) starting at left,bottom]
expected: FAIL
[scrollIntoView(null) starting at left,bottom]
expected: FAIL
[scrollIntoView({block: "start", inline: "start"}) starting at left,bottom]
expected: FAIL
[scrollIntoView(true) starting at right,top]
expected: FAIL
[scrollIntoView(undefined) starting at right,top]
expected: FAIL
[scrollIntoView() starting at left,bottom]
expected: FAIL
[scrollIntoView({}) starting at left,bottom]
expected: FAIL