Fix scrolling from script in Layout 2020

Script will only scroll if it detects that an element has a scrolling
box, so this change adds an implementation of the scroll area query to
Layout 2020. This allows some scrolling tests to start passing.

This change also updates all expected results in css-backgrounds and
cssom-view.
This commit is contained in:
Martin Robinson 2023-04-25 09:11:28 +02:00
parent eca0acf459
commit 404ee8b984
31 changed files with 72 additions and 238 deletions

View file

@ -538,6 +538,39 @@ impl FragmentTree {
})
.unwrap_or_else(Rect::zero)
}
pub fn get_scroll_area_for_node(&self, requested_node: OpaqueNode) -> Rect<i32> {
let mut scroll_area: PhysicalRect<Length> = PhysicalRect::zero();
let tag_to_find = Tag::Node(requested_node);
self.find(|fragment, _, containing_block| {
if fragment.tag() != Some(tag_to_find) {
return None::<()>;
}
scroll_area = match fragment {
Fragment::Box(fragment) => fragment
.scrollable_overflow(&containing_block)
.translate(containing_block.origin.to_vector()),
Fragment::Text(_) |
Fragment::AbsoluteOrFixedPositioned(_) |
Fragment::Image(_) |
Fragment::IFrame(_) |
Fragment::Anonymous(_) => return None,
};
None::<()>
});
Rect::new(
Point2D::new(
scroll_area.origin.x.px() as i32,
scroll_area.origin.y.px() as i32,
),
Size2D::new(
scroll_area.size.width.px() as i32,
scroll_area.size.height.px() as i32,
),
)
}
}
/// https://drafts.csswg.org/css-backgrounds/#root-background

View file

@ -201,8 +201,15 @@ pub fn process_node_scroll_id_request<'dom>(
}
/// https://drafts.csswg.org/cssom-view/#scrolling-area
pub fn process_node_scroll_area_request(_requested_node: OpaqueNode) -> Rect<i32> {
Rect::zero()
pub fn process_node_scroll_area_request(
requested_node: OpaqueNode,
fragment_tree: Option<Arc<FragmentTree>>,
) -> Rect<i32> {
if let Some(fragment_tree) = fragment_tree {
fragment_tree.get_scroll_area_for_node(requested_node)
} else {
Rect::zero()
}
}
/// Return the resolved value of property for a given (pseudo)element.

View file

@ -1184,7 +1184,8 @@ impl LayoutThread {
process_node_geometry_request(node, self.fragment_tree.borrow().clone());
},
&QueryMsg::NodeScrollGeometryQuery(node) => {
rw_data.scroll_area_response = process_node_scroll_area_request(node);
rw_data.scroll_area_response =
process_node_scroll_area_request(node, self.fragment_tree.borrow().clone());
},
&QueryMsg::NodeScrollIdQuery(node) => {
let node = unsafe { ServoLayoutNode::new(&node) };

View file

@ -1,2 +0,0 @@
[attachment-local-positioning-2.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[attachment-scroll-positioning-1.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[scroll-positioned-multiple-background-images.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[containing-block-change-scrollframe.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[position-absolute-under-non-containing-stacking-context.html]
expected: FAIL

View file

@ -28,15 +28,3 @@
[.containing-block 14]
expected: FAIL
[.containing-block 5]
expected: FAIL
[.containing-block 6]
expected: FAIL
[.containing-block 12]
expected: FAIL
[.containing-block 13]
expected: FAIL

View file

@ -1,2 +0,0 @@
[position-sticky-escape-scroller-001.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[position-sticky-escape-scroller-003.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[position-sticky-fractional-offset.html]
expected: FAIL

View file

@ -1,6 +1,3 @@
[position-sticky-overflow-padding.html]
[Ancestor overflow padding does not allow a sticky element to escape its container]
expected: FAIL
[A sticky element should be offset by ancestor padding even when stuck]
expected: FAIL

View file

@ -1,6 +0,0 @@
[position-sticky-scrolled-remove-sibling.html]
[Sticky position and its overflow contribution in the vertical axis]
expected: FAIL
[Sticky position and its overflow contribution in the horizontal axis]
expected: FAIL

View file

@ -0,0 +1,2 @@
[position-sticky-table-td-top.html]
expected: FAIL

View file

@ -1,3 +1,9 @@
[MediaQueryList-addListener-removeListener.html]
[listeners are called when <iframe> is resized]
expected: FAIL
[listeners are called correct number of times]
expected: FAIL
[listeners are called in order their MQLs were created]
expected: FAIL

View file

@ -1,2 +0,0 @@
[add-background-attachment-fixed-during-smooth-scroll.html]
expected: TIMEOUT

View file

@ -1,4 +0,0 @@
[background-change-during-smooth-scroll.html]
expected: TIMEOUT
[background change during smooth scroll]
expected: NOTRUN

View file

@ -1,6 +0,0 @@
[dom-element-scroll.html]
[Element test for having overflow]
expected: FAIL
[Element test for having scrolling box]
expected: FAIL

View file

@ -1,3 +0,0 @@
[elementFromPoint-float-in-table.html]
[float-in-div]
expected: FAIL

View file

@ -1,12 +0,0 @@
[elementScroll-002.html]
[simple scroll with style: 'padding' and 'overflow: hidden']
expected: FAIL
[simple scroll with style: 'margin' and 'overflow: hidden']
expected: FAIL
[simple scroll with style: 'margin' and 'overflow: scroll']
expected: FAIL
[simple scroll with style: 'padding' and 'overflow: scroll']
expected: FAIL

View file

@ -1,24 +1,3 @@
[elementScroll.html]
[Element scrollTop/Left getter/setter test]
expected: FAIL
[Element scrollBy test (two arguments)]
expected: FAIL
[Element scrollTo test (two arguments)]
expected: FAIL
[Element scroll test (two arguments)]
expected: FAIL
[Element scroll maximum test]
expected: FAIL
[Element scrollTo test (one argument)]
expected: FAIL
[Element scrollBy test (one argument)]
expected: FAIL
[Element scroll test (one argument)]
expected: FAIL

View file

@ -1,6 +1,3 @@
[elementsFromPoint-iframes.html]
[elementsFromPoint on the root document for points in iframe elements]
expected: FAIL
[elementsFromPoint on inner documents]
expected: FAIL

View file

@ -1,4 +0,0 @@
[elementsFromPoint-inline-vlr-ltr.html]
[elementsFromPoint should return all elements under a point]
expected: FAIL

View file

@ -1,3 +0,0 @@
[pt-to-px-width.html]
[10pt converted to offset/client/scroll width]
expected: FAIL

View file

@ -1,6 +1,3 @@
[scroll-behavior-default-css.html]
[Instant scrolling of an element with default scroll-behavior]
expected: FAIL
[Smooth scrolling of an element with default scroll-behavior]
expected: FAIL

View file

@ -1,13 +1,4 @@
[scroll-behavior-element.html]
[Element with auto scroll-behavior ; scroll() with default behavior]
expected: FAIL
[Element with auto scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Element with auto scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Element with auto scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
@ -17,21 +8,9 @@
[Element with smooth scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollTo() with default behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
@ -41,21 +20,9 @@
[Element with smooth scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollBy() with default behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Element with auto scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -65,9 +32,6 @@
[Element with smooth scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Element with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -95,17 +59,8 @@
[Element with smooth scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL
[Set scrollLeft to element with auto scroll-behavior]
expected: FAIL
[Set scrollLeft to element with smooth scroll-behavior]
expected: FAIL
[Set scrollTop to element with auto scroll-behavior]
expected: FAIL
[Set scrollTop to element with smooth scroll-behavior]
expected: FAIL
[Aborting an ongoing smooth scrolling on an element with another smooth scrolling]
expected: FAIL

View file

@ -5,63 +5,8 @@
[Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scrollIntoView() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollBy() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scroll() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scroll() ]
expected: FAIL
[Scroll positions when aborting a smooth scrolling with an instant scrolling]
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 500 to 250 by setting scrollTop ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollIntoView() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scrollBy() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollTo() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scroll() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scroll() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollBy() ]
expected: FAIL
[Scroll positions when aborting a smooth scrolling with another smooth scrolling]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 500) to (500, 250) using scrollTo() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from 1000 to 500 by setting scrollLeft ]
expected: FAIL
[Scroll positions when performing smooth scrolling from 0 to 500 by setting scrollLeft ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollTo() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollTo() ]
expected: FAIL
[Scroll positions when performing smooth scrolling from 0 to 250 by setting scrollTop ]
expected: FAIL
[Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollBy() ]
expected: FAIL

View file

@ -13,15 +13,3 @@
[elemOverflow.scrollHeight is the width of its scrolled contents (including padding)]
expected: FAIL
[elemSimple.scrollHeight is its clientHeight]
expected: FAIL
[elemSimple.scrollWidth is its clientWidth]
expected: FAIL
[elemNestedOverflow.scrollHeight is the height of its scrolled contents (ignoring padding)]
expected: FAIL
[elemNestedOverflow.scrollWidth is the width of its scrolled contents (ignoring padding)]
expected: FAIL

View file

@ -1,18 +0,0 @@
[scrollWidthHeightWhenNotScrollable.xht]
[elemSimple.scrollWidth is its clientWidth]
expected: FAIL
[elemSimple.scrollHeight is its clientHeight]
expected: FAIL
[elemOverflow.scrollHeight is the height of its scrolled contents (ignoring padding, since we overflowed)]
expected: FAIL
[elemNestedOverflow.scrollWidth is the width of its scrolled contents (ignoring padding, since we overflowed)]
expected: FAIL
[elemNestedOverflow.scrollHeight is the height of its scrolled contents (ignoring padding, since we overflowed)]
expected: FAIL
[elemOverflow.scrollHeight is the width of its scrolled contents (ignoring padding, since we overflowed)]
expected: FAIL

View file

@ -8,24 +8,15 @@
[scrollBy() on the root element in non-quirks mode]
expected: FAIL
[scrollWidth/scrollHeight of the content in non-quirks mode]
expected: FAIL
[scrollLeft/scrollRight of the content in quirks mode]
expected: FAIL
[scrollWidth/scrollHeight of the content in quirks mode]
expected: FAIL
[scrollWidth/scrollHeight on the root element in non-quirks mode]
expected: FAIL
[scrollingElement in quirks mode]
expected: FAIL
[scrollWidth/scrollHeight on the HTML body element in non-quirks mode]
expected: FAIL
[clientWidth/clientHeight on the root element in non-quirks mode]
expected: FAIL
@ -43,3 +34,21 @@
[scrollWidth/scrollHeight on the HTML body element in quirks mode]
expected: FAIL
[scroll() on the HTML body element in non-quirks mode]
expected: FAIL
[scrollBy() on the HTML body element in non-quirks mode]
expected: FAIL
[scrollLeft/scrollTop on the HTML body element in non-quirks mode]
expected: FAIL
[scroll() on the HTML body element in quirks mode]
expected: FAIL
[scrollBy() on the HTML body element in quirks mode]
expected: FAIL
[scrollLeft/scrollTop on the HTML body element in quirks mode]
expected: FAIL