From 3ab5e2a188a2e6e892367dfbcd4880bd9aadeab8 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 25 Apr 2023 08:29:09 +0200 Subject: [PATCH 1/3] Scroll from script should trigger a reflow Scrolling from script should flow layout and send a display list to WebRender. This allows all of the scroll nodes to exist in WebRender before asking it to move the node. See https://gist.github.com/paulirish/5d52fb081b3570c81e3a. Fixes #29659. --- components/layout_thread/lib.rs | 36 ++++---- components/layout_thread_2020/lib.rs | 36 ++++---- components/script/dom/window.rs | 46 +++++----- components/script_layout_interface/message.rs | 12 +-- components/script_traits/lib.rs | 2 +- ...-absolute-scrollable-overflow-001.html.ini | 18 ++-- ...sition-sticky-escape-scroller-002.html.ini | 2 - .../position-sticky-overflow-padding.html.ini | 6 +- ...nd-will-change-overlapping-layers.html.ini | 2 - .../clear-on-parent-and-child.html.ini | 3 - .../attachment-local-positioning-2.html.ini | 3 - .../attachment-scroll-positioning-1.html.ini | 3 - ...tioned-multiple-background-images.html.ini | 3 - ...ntaining-block-change-scrollframe.html.ini | 2 - ...sition-sticky-escape-scroller-001.html.ini | 2 - ...sition-sticky-escape-scroller-002.html.ini | 2 - ...sition-sticky-escape-scroller-003.html.ini | 2 - ...sition-sticky-escape-scroller-004.html.ini | 2 - .../sticky/position-sticky-rendering.html.ini | 2 + ...nd-will-change-overlapping-layers.html.ini | 2 - .../css/cssom-view/CaretPosition-001.html.ini | 3 - .../css/cssom-view/elementScroll-002.html.ini | 1 - .../scroll-behavior-default-css.html.ini | 6 +- .../scroll-behavior-element.html.ini | 84 +++++++++---------- .../scroll-behavior-smooth-positions.html.ini | 69 ++++++++------- 25 files changed, 161 insertions(+), 188 deletions(-) delete mode 100644 tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini delete mode 100644 tests/wpt/metadata/css/CSS2/floats-clear/clear-on-parent-and-child.html.ini delete mode 100644 tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini delete mode 100644 tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini delete mode 100644 tests/wpt/metadata/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini delete mode 100644 tests/wpt/metadata/css/css-position/containing-block-change-scrollframe.html.ini delete mode 100644 tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini delete mode 100644 tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini delete mode 100644 tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini delete mode 100644 tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-004.html.ini create mode 100644 tests/wpt/metadata/css/css-position/sticky/position-sticky-rendering.html.ini delete mode 100644 tests/wpt/metadata/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini delete mode 100644 tests/wpt/metadata/css/cssom-view/CaretPosition-001.html.ini diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 4ea217edfec..6cabd0b046c 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -645,9 +645,6 @@ impl LayoutThread { Msg::CreateLayoutThread(..) => LayoutHangAnnotation::CreateLayoutThread, Msg::SetFinalUrl(..) => LayoutHangAnnotation::SetFinalUrl, Msg::SetScrollStates(..) => LayoutHangAnnotation::SetScrollStates, - Msg::UpdateScrollStateFromScript(..) => { - LayoutHangAnnotation::UpdateScrollStateFromScript - }, Msg::RegisterPaint(..) => LayoutHangAnnotation::RegisterPaint, Msg::SetNavigationStart(..) => LayoutHangAnnotation::SetNavigationStart, }; @@ -753,19 +750,6 @@ impl LayoutThread { Msg::SetScrollStates(new_scroll_states) => { self.set_scroll_states(new_scroll_states, possibly_locked_rw_data); }, - Msg::UpdateScrollStateFromScript(state) => { - let mut rw_data = possibly_locked_rw_data.lock(); - rw_data - .scroll_offsets - .insert(state.scroll_id, state.scroll_offset); - - let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y); - self.webrender_api.send_scroll_node( - webrender_api::units::LayoutPoint::from_untyped(point), - state.scroll_id, - webrender_api::ScrollClamping::ToContentBounds, - ); - }, Msg::CollectReports(reports_chan) => { self.collect_reports(reports_chan, possibly_locked_rw_data); }, @@ -1250,7 +1234,9 @@ impl LayoutThread { rw_data.inner_window_dimensions_response = None; }, }, - ReflowGoal::Full | ReflowGoal::TickAnimations => {}, + ReflowGoal::Full | + ReflowGoal::TickAnimations | + ReflowGoal::UpdateScrollNode(_) => {}, } return; }, @@ -1619,10 +1605,26 @@ impl LayoutThread { .cloned(); }, }, + ReflowGoal::UpdateScrollNode(scroll_state) => { + self.update_scroll_node_state(&scroll_state, rw_data); + }, ReflowGoal::Full | ReflowGoal::TickAnimations => {}, } } + fn update_scroll_node_state(&self, state: &ScrollState, rw_data: &mut LayoutThreadData) { + rw_data + .scroll_offsets + .insert(state.scroll_id, state.scroll_offset); + + let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y); + self.webrender_api.send_scroll_node( + webrender_api::units::LayoutPoint::from_untyped(point), + state.scroll_id, + webrender_api::ScrollClamping::ToContentBounds, + ); + } + fn set_scroll_states<'a, 'b>( &mut self, new_scroll_states: Vec, diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index 2b7661a631b..0a1dff2d284 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -616,9 +616,6 @@ impl LayoutThread { Msg::CreateLayoutThread(..) => LayoutHangAnnotation::CreateLayoutThread, Msg::SetFinalUrl(..) => LayoutHangAnnotation::SetFinalUrl, Msg::SetScrollStates(..) => LayoutHangAnnotation::SetScrollStates, - Msg::UpdateScrollStateFromScript(..) => { - LayoutHangAnnotation::UpdateScrollStateFromScript - }, Msg::RegisterPaint(..) => LayoutHangAnnotation::RegisterPaint, Msg::SetNavigationStart(..) => LayoutHangAnnotation::SetNavigationStart, }; @@ -724,19 +721,6 @@ impl LayoutThread { Msg::SetScrollStates(new_scroll_states) => { self.set_scroll_states(new_scroll_states, possibly_locked_rw_data); }, - Msg::UpdateScrollStateFromScript(state) => { - let mut rw_data = possibly_locked_rw_data.lock(); - rw_data - .scroll_offsets - .insert(state.scroll_id, state.scroll_offset); - - let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y); - self.webrender_api.send_scroll_node( - webrender_api::units::LayoutPoint::from_untyped(point), - state.scroll_id, - webrender_api::ScrollClamping::ToContentBounds, - ); - }, Msg::CollectReports(reports_chan) => { self.collect_reports(reports_chan, possibly_locked_rw_data); }, @@ -935,7 +919,9 @@ impl LayoutThread { .cloned(); }, }, - ReflowGoal::Full | ReflowGoal::TickAnimations => {}, + ReflowGoal::Full | + ReflowGoal::TickAnimations | + ReflowGoal::UpdateScrollNode(_) => {}, } return; }, @@ -1256,10 +1242,26 @@ impl LayoutThread { rw_data.inner_window_dimensions_response = None; }, }, + ReflowGoal::UpdateScrollNode(scroll_state) => { + self.update_scroll_node_state(&scroll_state, rw_data); + }, ReflowGoal::Full | ReflowGoal::TickAnimations => {}, } } + fn update_scroll_node_state(&self, state: &ScrollState, rw_data: &mut LayoutThreadData) { + rw_data + .scroll_offsets + .insert(state.scroll_id, state.scroll_offset); + + let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y); + self.webrender_api.send_scroll_node( + webrender_api::units::LayoutPoint::from_untyped(point), + state.scroll_id, + webrender_api::ScrollClamping::ToContentBounds, + ); + } + fn set_scroll_states<'a, 'b>( &mut self, new_scroll_states: Vec, diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 38465a4af06..5acf727d35a 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -168,26 +168,27 @@ enum WindowState { #[derive(Debug, MallocSizeOf)] pub enum ReflowReason { CachedPageNeededReflow, - RefreshTick, - FirstLoad, - KeyEvent, - MouseEvent, - Query, - Timer, - Viewport, - WindowResize, DOMContentLoaded, DocumentLoaded, - StylesheetLoaded, - ImageLoaded, - RequestAnimationFrame, - WebFontLoaded, - WorkletLoaded, + ElementStateChanged, + FirstLoad, FramedContentChanged, IFrameLoadEvent, + ImageLoaded, + KeyEvent, MissingExplicitReflow, - ElementStateChanged, + MouseEvent, PendingReflow, + Query, + RefreshTick, + RequestAnimationFrame, + ScrollFromScript, + StylesheetLoaded, + Timer, + Viewport, + WebFontLoaded, + WindowResize, + WorkletLoaded, } #[dom_struct] @@ -1755,15 +1756,13 @@ impl Window { // TODO Step 1 // TODO(mrobinson, #18709): Add smooth scrolling support to WebRender so that we can // properly process ScrollBehavior here. - match self.layout_chan() { - Some(chan) => chan - .send(Msg::UpdateScrollStateFromScript(ScrollState { - scroll_id, - scroll_offset: Vector2D::new(-x, -y), - })) - .unwrap(), - None => warn!("Layout channel unavailable"), - } + self.reflow( + ReflowGoal::UpdateScrollNode(ScrollState { + scroll_id, + scroll_offset: Vector2D::new(-x, -y), + }), + ReflowReason::ScrollFromScript, + ); } pub fn update_viewport_for_scroll(&self, x: f32, y: f32) { @@ -2719,6 +2718,7 @@ fn debug_reflow_events(id: PipelineId, reflow_goal: &ReflowGoal, reason: &Reflow let goal_string = match *reflow_goal { ReflowGoal::Full => "\tFull", ReflowGoal::TickAnimations => "\tTickAnimations", + ReflowGoal::UpdateScrollNode(_) => "\tUpdateScrollNode", ReflowGoal::LayoutQuery(ref query_msg, _) => match query_msg { &QueryMsg::ContentBoxQuery(_n) => "\tContentBoxQuery", &QueryMsg::ContentBoxesQuery(_n) => "\tContentBoxesQuery", diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 9e4312fd2d5..feeded5054c 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -81,10 +81,6 @@ pub enum Msg { /// Tells layout about the new scrolling offsets of each scrollable stacking context. SetScrollStates(Vec), - /// Tells layout about a single new scrolling offset from the script. The rest will - /// remain untouched and layout won't forward this back to script. - UpdateScrollStateFromScript(ScrollState), - /// Tells layout that script has added some paint worklet modules. RegisterPaint(Atom, Vec, Box), @@ -125,6 +121,10 @@ pub enum ReflowGoal { Full, TickAnimations, LayoutQuery(QueryMsg, u64), + + /// Tells layout about a single new scrolling offset from the script. The rest will + /// remain untouched and layout won't forward this back to script. + UpdateScrollNode(ScrollState), } impl ReflowGoal { @@ -132,7 +132,7 @@ impl ReflowGoal { /// be present or false if it only needs stacking-relative positions. pub fn needs_display_list(&self) -> bool { match *self { - ReflowGoal::Full | ReflowGoal::TickAnimations => true, + ReflowGoal::Full | ReflowGoal::TickAnimations | ReflowGoal::UpdateScrollNode(_) => true, ReflowGoal::LayoutQuery(ref querymsg, _) => match *querymsg { QueryMsg::NodesFromPointQuery(..) | QueryMsg::TextIndexQuery(..) | @@ -155,7 +155,7 @@ impl ReflowGoal { /// false if a layout_thread display list is sufficient. pub fn needs_display(&self) -> bool { match *self { - ReflowGoal::Full | ReflowGoal::TickAnimations => true, + ReflowGoal::Full | ReflowGoal::TickAnimations | ReflowGoal::UpdateScrollNode(_) => true, ReflowGoal::LayoutQuery(ref querymsg, _) => match *querymsg { QueryMsg::NodesFromPointQuery(..) | QueryMsg::TextIndexQuery(..) | diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 168b910b3c2..14144d8880b 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -791,7 +791,7 @@ bitflags! { } /// The scroll state of a stacking context. -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct ScrollState { /// The ID of the scroll root. pub scroll_id: ExternalScrollId, diff --git a/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini index 2931576e0c5..9293d969cdb 100644 --- a/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini +++ b/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini @@ -11,12 +11,6 @@ [.containing-block 4] expected: FAIL - [.containing-block 5] - expected: FAIL - - [.containing-block 6] - expected: FAIL - [.containing-block 7] expected: FAIL @@ -32,11 +26,17 @@ [.containing-block 11] expected: FAIL + [.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 - - [.containing-block 14] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini deleted file mode 100644 index 46487c6701a..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-escape-scroller-002.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini index 1dea93847b7..7fb4bc0467c 100644 --- a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini +++ b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini @@ -1,6 +1,6 @@ [position-sticky-overflow-padding.html] - [A sticky element should be offset by ancestor padding even when stuck] - expected: FAIL - [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 diff --git a/tests/wpt/metadata-layout-2020/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini deleted file mode 100644 index 07353055bf7..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[z-index-blend-will-change-overlapping-layers.html] - expected: FAIL diff --git a/tests/wpt/metadata/css/CSS2/floats-clear/clear-on-parent-and-child.html.ini b/tests/wpt/metadata/css/CSS2/floats-clear/clear-on-parent-and-child.html.ini deleted file mode 100644 index c9c1672a96f..00000000000 --- a/tests/wpt/metadata/css/CSS2/floats-clear/clear-on-parent-and-child.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[clear-on-parent-and-child.html] - bug: https://github.com/servo/webrender/issues/3078 - expected: FAIL diff --git a/tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini b/tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini deleted file mode 100644 index 953bbeabcbf..00000000000 --- a/tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[attachment-local-positioning-2.html] - bug: https://github.com/servo/webrender/issues/3078 - expected: FAIL diff --git a/tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini b/tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini deleted file mode 100644 index beea55d7dc0..00000000000 --- a/tests/wpt/metadata/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[attachment-scroll-positioning-1.html] - bug: https://github.com/servo/webrender/issues/3078 - expected: FAIL diff --git a/tests/wpt/metadata/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini b/tests/wpt/metadata/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini deleted file mode 100644 index 08321c4b311..00000000000 --- a/tests/wpt/metadata/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[scroll-positioned-multiple-background-images.html] - bug: https://github.com/servo/webrender/issues/3078 - expected: FAIL diff --git a/tests/wpt/metadata/css/css-position/containing-block-change-scrollframe.html.ini b/tests/wpt/metadata/css/css-position/containing-block-change-scrollframe.html.ini deleted file mode 100644 index 242f79c08a9..00000000000 --- a/tests/wpt/metadata/css/css-position/containing-block-change-scrollframe.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[containing-block-change-scrollframe.html] - expected: FAIL diff --git a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini b/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini deleted file mode 100644 index 3018d79f1af..00000000000 --- a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-escape-scroller-001.html] - expected: FAIL diff --git a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini b/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini deleted file mode 100644 index 46487c6701a..00000000000 --- a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-002.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-escape-scroller-002.html] - expected: FAIL diff --git a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini b/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini deleted file mode 100644 index 990a7ae58c6..00000000000 --- a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-escape-scroller-003.html] - expected: FAIL diff --git a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-004.html.ini b/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-004.html.ini deleted file mode 100644 index 7b98776c5e0..00000000000 --- a/tests/wpt/metadata/css/css-position/sticky/position-sticky-escape-scroller-004.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-escape-scroller-004.html] - expected: FAIL diff --git a/tests/wpt/metadata/css/css-position/sticky/position-sticky-rendering.html.ini b/tests/wpt/metadata/css/css-position/sticky/position-sticky-rendering.html.ini new file mode 100644 index 00000000000..2831b2eabe7 --- /dev/null +++ b/tests/wpt/metadata/css/css-position/sticky/position-sticky-rendering.html.ini @@ -0,0 +1,2 @@ +[position-sticky-rendering.html] + expected: FAIL diff --git a/tests/wpt/metadata/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini b/tests/wpt/metadata/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini deleted file mode 100644 index 07353055bf7..00000000000 --- a/tests/wpt/metadata/css/css-position/z-index-blend-will-change-overlapping-layers.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[z-index-blend-will-change-overlapping-layers.html] - expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/CaretPosition-001.html.ini b/tests/wpt/metadata/css/cssom-view/CaretPosition-001.html.ini deleted file mode 100644 index f18b8d2fcf9..00000000000 --- a/tests/wpt/metadata/css/cssom-view/CaretPosition-001.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[CaretPosition-001.html] - [Element at (400, 100)] - expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini b/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini index 79b250394da..5f07b905cfb 100644 --- a/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini +++ b/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini @@ -4,4 +4,3 @@ [simple scroll with style: 'padding' and 'overflow: scroll'] expected: FAIL - diff --git a/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini b/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini index 6885818c71a..b084797a43f 100644 --- a/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini +++ b/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini @@ -2,8 +2,8 @@ [Testing default value of scroll-behavior] expected: FAIL - [Instant scrolling of an element with default scroll-behavior] - expected: FAIL - [Smooth scrolling of an element with default scroll-behavior] expected: FAIL + + [Instant scrolling of an element with default scroll-behavior] + expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini b/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini index 5d579f4716f..e477e663110 100644 --- a/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini +++ b/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini @@ -2,15 +2,6 @@ [Testing scrollOptions' behavior for Element.scroll* and scroll-behavior on an element] expected: FAIL - [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 @@ -20,21 +11,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 @@ -44,21 +23,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 @@ -68,9 +35,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 @@ -98,17 +62,53 @@ [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 + [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 smooth scroll-behavior ; scroll() with instant 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 smooth scroll-behavior ; scrollTo() with instant 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 smooth scroll-behavior ; scrollBy() with instant behavior] + expected: FAIL + + [Set scrollLeft to element with auto scroll-behavior] + expected: FAIL + + [Set scrollTop to element with auto scroll-behavior] + expected: FAIL + [Aborting an ongoing smooth scrolling on an element with another smooth scrolling] expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini b/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini index b74bb322d1f..c436513c82b 100644 --- a/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini +++ b/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini @@ -2,66 +2,65 @@ [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 scrollTo() ] - 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, 500) to (500, 250) using scrollIntoView() ] 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, 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 (1000, 0) to (500, 250) using scrollBy() ] - expected: FAIL - - [Scroll positions when aborting a smooth scrolling with an instant scrolling] - 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 (1000, 0) to (500, 250) using scroll() ] - 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 scroll() ] - 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 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 scroll() ] + 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 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 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 (1000, 500) to (500, 250) using scrollTo() ] + expected: FAIL + [Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollBy() ] expected: FAIL - [Scroll positions when performing smooth scrolling from 500 to 250 by setting scrollTop ] + [Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollBy() ] expected: FAIL - [Scroll positions when performing smooth scrolling from 1000 to 500 by setting scrollLeft ] + [Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollBy() ] + 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 to 500 by setting scrollLeft ] 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 250 by setting scrollTop ] expected: FAIL + [Scroll positions when performing smooth scrolling from 500 to 250 by setting scrollTop ] + expected: FAIL + + [Scroll positions when aborting a smooth scrolling with another smooth scrolling] + expected: FAIL + + [Scroll positions when aborting a smooth scrolling with an instant scrolling] + expected: FAIL From eca0acf4598c173c71765b961bd2079c0bb48cd2 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 25 Apr 2023 09:07:53 +0200 Subject: [PATCH 2/3] Allow script to scroll `overflow: scroll` elements Before the code was only allowing `overflow: hidden` elements to scroll. This fixes that issue and also clean up the code that deals with detecting whether the body is a "potentially scrollable" in quirks mode. --- components/script/dom/element.rs | 80 +++++++++++-------- components/script/dom/window.rs | 26 +++--- .../css/css-ui/text-overflow-021.html.ini | 2 + ...chment-fixed-during-smooth-scroll.html.ini | 2 - ...round-change-during-smooth-scroll.html.ini | 4 - .../css/cssom-view/elementScroll-002.html.ini | 3 - .../scroll-behavior-default-css.html.ini | 3 - .../scroll-behavior-element.html.ini | 45 ----------- .../scroll-behavior-smooth-positions.html.ini | 54 ------------- .../scrolling-quirks-vs-nonquirks.html.ini | 10 --- .../fieldset-overflow-cssomview.html.ini | 4 - 11 files changed, 60 insertions(+), 173 deletions(-) create mode 100644 tests/wpt/metadata/css/css-ui/text-overflow-021.html.ini delete mode 100644 tests/wpt/metadata/css/cssom-view/add-background-attachment-fixed-during-smooth-scroll.html.ini delete mode 100644 tests/wpt/metadata/css/cssom-view/background-change-during-smooth-scroll.html.ini delete mode 100644 tests/wpt/metadata/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-overflow-cssomview.html.ini diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index e69fd558f5c..179cb169c46 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -120,7 +120,6 @@ use style::invalidation::element::restyle_hints::RestyleHint; use style::properties::longhands::{ self, background_image, border_spacing, font_family, font_size, }; -use style::properties::longhands::{overflow_x, overflow_y}; use style::properties::{parse_style_attribute, PropertyDeclarationBlock}; use style::properties::{ComputedValues, Importance, PropertyDeclaration}; use style::rule_tree::CascadeLevel; @@ -408,46 +407,59 @@ impl Element { } // https://drafts.csswg.org/cssom-view/#potentially-scrollable - fn potentially_scrollable(&self) -> bool { - self.has_css_layout_box() && !self.has_any_visible_overflow() + fn is_potentially_scrollable_body(&self) -> bool { + let node = self.upcast::(); + debug_assert!( + node.owner_doc().GetBody().as_deref() == self.downcast::(), + "Called is_potentially_scrollable_body on element that is not the " + ); + + // "An element body (which will be the body element) is potentially + // scrollable if all of the following conditions are true: + // - body has an associated box." + if !self.has_css_layout_box() { + return false; + } + + // " - body’s parent element’s computed value of the overflow-x or + // overflow-y properties is neither visible nor clip." + if let Some(parent) = node.GetParentElement() { + if let Some(style) = parent.style() { + if !style.get_box().clone_overflow_x().is_scrollable() && + !style.get_box().clone_overflow_y().is_scrollable() + { + return false; + } + }; + } + + // " - body’s computed value of the overflow-x or overflow-y properties + // is neither visible nor clip." + if let Some(style) = self.style() { + if !style.get_box().clone_overflow_x().is_scrollable() && + !style.get_box().clone_overflow_y().is_scrollable() + { + return false; + } + }; + + true } // https://drafts.csswg.org/cssom-view/#scrolling-box fn has_scrolling_box(&self) -> bool { // TODO: scrolling mechanism, such as scrollbar (We don't have scrollbar yet) // self.has_scrolling_mechanism() - self.has_any_hidden_overflow() + self.style().map_or(false, |style| { + style.get_box().clone_overflow_x().is_scrollable() || + style.get_box().clone_overflow_y().is_scrollable() + }) } fn has_overflow(&self) -> bool { self.ScrollHeight() > self.ClientHeight() || self.ScrollWidth() > self.ClientWidth() } - // TODO: Once #19183 is closed (overflow-x/y types moved out of mako), then we could implement - // a more generic `fn has_some_overflow(&self, overflow: Overflow)` rather than have - // these two `has_any_{visible,hidden}_overflow` methods which are very structurally - // similar. - - /// Computed value of overflow-x or overflow-y is "visible" - fn has_any_visible_overflow(&self) -> bool { - self.style().map_or(false, |s| { - let box_ = s.get_box(); - - box_.clone_overflow_x() == overflow_x::computed_value::T::Visible || - box_.clone_overflow_y() == overflow_y::computed_value::T::Visible - }) - } - - /// Computed value of overflow-x or overflow-y is "hidden" - fn has_any_hidden_overflow(&self) -> bool { - self.style().map_or(false, |s| { - let box_ = s.get_box(); - - box_.clone_overflow_x() == overflow_x::computed_value::T::Hidden || - box_.clone_overflow_y() == overflow_y::computed_value::T::Hidden - }) - } - fn shadow_root(&self) -> Option> { self.rare_data() .as_ref()? @@ -1765,7 +1777,7 @@ impl Element { // Step 9 if doc.GetBody().as_deref() == self.downcast::() && doc.quirks_mode() == QuirksMode::Quirks && - !self.potentially_scrollable() + !self.is_potentially_scrollable_body() { win.scroll(x, y, behavior); return; @@ -2305,7 +2317,7 @@ impl ElementMethods for Element { // Step 7 if doc.GetBody().as_deref() == self.downcast::() && doc.quirks_mode() == QuirksMode::Quirks && - !self.potentially_scrollable() + !self.is_potentially_scrollable_body() { return win.ScrollY() as f64; } @@ -2355,7 +2367,7 @@ impl ElementMethods for Element { // Step 9 if doc.GetBody().as_deref() == self.downcast::() && doc.quirks_mode() == QuirksMode::Quirks && - !self.potentially_scrollable() + !self.is_potentially_scrollable_body() { win.scroll(win.ScrollX() as f64, y, behavior); return; @@ -2401,7 +2413,7 @@ impl ElementMethods for Element { // Step 7 if doc.GetBody().as_deref() == self.downcast::() && doc.quirks_mode() == QuirksMode::Quirks && - !self.potentially_scrollable() + !self.is_potentially_scrollable_body() { return win.ScrollX() as f64; } @@ -2452,7 +2464,7 @@ impl ElementMethods for Element { // Step 9 if doc.GetBody().as_deref() == self.downcast::() && doc.quirks_mode() == QuirksMode::Quirks && - !self.potentially_scrollable() + !self.is_potentially_scrollable_body() { win.scroll(x, win.ScrollY() as f64, behavior); return; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 5acf727d35a..2364c1c7f72 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1699,24 +1699,23 @@ impl Window { // TODO Step 4 - determine if a window has a viewport - // Step 5 - //TODO remove scrollbar width - let width = self.InnerWidth() as f64; - // Step 6 - //TODO remove scrollbar height - let height = self.InnerHeight() as f64; + // Step 5 & 6 + // TODO: Remove scrollbar dimensions. + let viewport = self.window_size.get().initial_viewport; // Step 7 & 8 - //TODO use overflow direction + // TODO: Consider `block-end` and `inline-end` overflow direction. let body = self.Document().GetBody(); let (x, y) = match body { Some(e) => { - let content_size = e.upcast::().bounding_content_box_or_zero(); - let content_height = content_size.size.height.to_f64_px(); - let content_width = content_size.size.width.to_f64_px(); + let scroll_area = e.upcast::().scroll_area(); ( - xfinite.min(content_width - width).max(0.0f64), - yfinite.min(content_height - height).max(0.0f64), + xfinite + .min(scroll_area.width() as f64 - viewport.width as f64) + .max(0.0f64), + yfinite + .min(scroll_area.height() as f64 - viewport.height as f64) + .max(0.0f64), ) }, None => (xfinite.max(0.0f64), yfinite.max(0.0f64)), @@ -1731,14 +1730,13 @@ impl Window { //TODO Step 11 //let document = self.Document(); // Step 12 - let global_scope = self.upcast::(); let x = x.to_f32().unwrap_or(0.0f32); let y = y.to_f32().unwrap_or(0.0f32); self.update_viewport_for_scroll(x, y); self.perform_a_scroll( x, y, - global_scope.pipeline_id().root_scroll_id(), + self.upcast::().pipeline_id().root_scroll_id(), behavior, None, ); diff --git a/tests/wpt/metadata/css/css-ui/text-overflow-021.html.ini b/tests/wpt/metadata/css/css-ui/text-overflow-021.html.ini new file mode 100644 index 00000000000..bc6acd4a26f --- /dev/null +++ b/tests/wpt/metadata/css/css-ui/text-overflow-021.html.ini @@ -0,0 +1,2 @@ +[text-overflow-021.html] + expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/add-background-attachment-fixed-during-smooth-scroll.html.ini b/tests/wpt/metadata/css/cssom-view/add-background-attachment-fixed-during-smooth-scroll.html.ini deleted file mode 100644 index 1b477fbb9d1..00000000000 --- a/tests/wpt/metadata/css/cssom-view/add-background-attachment-fixed-during-smooth-scroll.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[add-background-attachment-fixed-during-smooth-scroll.html] - expected: TIMEOUT diff --git a/tests/wpt/metadata/css/cssom-view/background-change-during-smooth-scroll.html.ini b/tests/wpt/metadata/css/cssom-view/background-change-during-smooth-scroll.html.ini deleted file mode 100644 index ea00ae5f7e3..00000000000 --- a/tests/wpt/metadata/css/cssom-view/background-change-during-smooth-scroll.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[background-change-during-smooth-scroll.html] - expected: TIMEOUT - [background change during smooth scroll] - expected: NOTRUN diff --git a/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini b/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini index 5f07b905cfb..a2d32c314ea 100644 --- a/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini +++ b/tests/wpt/metadata/css/cssom-view/elementScroll-002.html.ini @@ -1,6 +1,3 @@ [elementScroll-002.html] [simple scroll with style: 'margin' and 'overflow: scroll'] expected: FAIL - - [simple scroll with style: 'padding' and 'overflow: scroll'] - expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini b/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini index b084797a43f..38761f42590 100644 --- a/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini +++ b/tests/wpt/metadata/css/cssom-view/scroll-behavior-default-css.html.ini @@ -4,6 +4,3 @@ [Smooth scrolling of an element with default scroll-behavior] expected: FAIL - - [Instant scrolling of an element with default scroll-behavior] - expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini b/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini index e477e663110..885aae83604 100644 --- a/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini +++ b/tests/wpt/metadata/css/cssom-view/scroll-behavior-element.html.ini @@ -67,48 +67,3 @@ [Set scrollTop to element with smooth scroll-behavior] expected: FAIL - - [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 smooth scroll-behavior ; scroll() with instant 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 smooth scroll-behavior ; scrollTo() with instant 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 smooth scroll-behavior ; scrollBy() with instant behavior] - expected: FAIL - - [Set scrollLeft to element with auto scroll-behavior] - expected: FAIL - - [Set scrollTop to element with auto scroll-behavior] - expected: FAIL - - [Aborting an ongoing smooth scrolling on an element with another smooth scrolling] - expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini b/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini index c436513c82b..ecf3c45a692 100644 --- a/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini +++ b/tests/wpt/metadata/css/cssom-view/scroll-behavior-smooth-positions.html.ini @@ -10,57 +10,3 @@ [Scroll positions when performing smooth scrolling from (0, 500) to (500, 250) using scrollIntoView() ] 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 scroll() ] - 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 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 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 (1000, 500) to (500, 250) using scrollTo() ] - expected: FAIL - - [Scroll positions when performing smooth scrolling from (0, 0) to (500, 250) using scrollBy() ] - expected: FAIL - - [Scroll positions when performing smooth scrolling from (1000, 0) to (500, 250) using scrollBy() ] - 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 (1000, 500) to (500, 250) using scrollBy() ] - 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 to 500 by setting scrollLeft ] - expected: FAIL - - [Scroll positions when performing smooth scrolling from 0 to 250 by setting scrollTop ] - expected: FAIL - - [Scroll positions when performing smooth scrolling from 500 to 250 by setting scrollTop ] - expected: FAIL - - [Scroll positions when aborting a smooth scrolling with another smooth scrolling] - expected: FAIL - - [Scroll positions when aborting a smooth scrolling with an instant scrolling] - expected: FAIL diff --git a/tests/wpt/metadata/css/cssom-view/scrolling-quirks-vs-nonquirks.html.ini b/tests/wpt/metadata/css/cssom-view/scrolling-quirks-vs-nonquirks.html.ini index 40d0827a65f..b63dd7da4f6 100644 --- a/tests/wpt/metadata/css/cssom-view/scrolling-quirks-vs-nonquirks.html.ini +++ b/tests/wpt/metadata/css/cssom-view/scrolling-quirks-vs-nonquirks.html.ini @@ -17,15 +17,6 @@ [scrollingElement in non-quirks mode] expected: FAIL - [scroll() on the root element in non-quirks mode] - expected: FAIL - - [scrollBy() on the root element in non-quirks mode] - expected: FAIL - - [scrollLeft/scrollTop on the root element in non-quirks mode] - expected: FAIL - [scrollWidth/scrollHeight on the root element in non-quirks mode] expected: FAIL @@ -43,4 +34,3 @@ [scrollLeft/scrollRight of the content in non-quirks mode] expected: FAIL - diff --git a/tests/wpt/metadata/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-overflow-cssomview.html.ini b/tests/wpt/metadata/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-overflow-cssomview.html.ini deleted file mode 100644 index b49fbe68d59..00000000000 --- a/tests/wpt/metadata/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-overflow-cssomview.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[fieldset-overflow-cssomview.html] - [Test cssom-view API for FIELDSET] - expected: FAIL - From 404ee8b98468970f0108d1e011f44b694975acb7 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 25 Apr 2023 09:11:28 +0200 Subject: [PATCH 3/3] 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. --- components/layout_2020/flow/root.rs | 33 +++++++++++ components/layout_2020/query.rs | 11 +++- components/layout_thread_2020/lib.rs | 3 +- .../attachment-local-positioning-2.html.ini | 2 - .../attachment-scroll-positioning-1.html.ini | 2 - ...tioned-multiple-background-images.html.ini | 2 - ...ntaining-block-change-scrollframe.html.ini | 2 - ...r-non-containing-stacking-context.html.ini | 2 + ...-absolute-scrollable-overflow-001.html.ini | 12 ---- ...sition-sticky-escape-scroller-001.html.ini | 2 - ...sition-sticky-escape-scroller-003.html.ini | 2 - ...position-sticky-fractional-offset.html.ini | 2 - .../position-sticky-overflow-padding.html.ini | 3 - ...on-sticky-scrolled-remove-sibling.html.ini | 6 -- .../position-sticky-table-td-top.html.ini | 2 + ...ryList-addListener-removeListener.html.ini | 6 ++ ...chment-fixed-during-smooth-scroll.html.ini | 2 - ...round-change-during-smooth-scroll.html.ini | 4 -- .../cssom-view/dom-element-scroll.html.ini | 6 -- .../elementFromPoint-float-in-table.html.ini | 3 - .../css/cssom-view/elementScroll-002.html.ini | 12 ---- .../css/cssom-view/elementScroll.html.ini | 21 ------- .../elementsFromPoint-iframes.html.ini | 3 - .../elementsFromPoint-inline-vlr-ltr.html.ini | 4 -- .../css/cssom-view/pt-to-px-width.html.ini | 3 - .../scroll-behavior-default-css.html.ini | 3 - .../scroll-behavior-element.html.ini | 45 --------------- .../scroll-behavior-smooth-positions.html.ini | 55 ------------------- .../css/cssom-view/scrollWidthHeight.xht.ini | 12 ---- ...scrollWidthHeightWhenNotScrollable.xht.ini | 18 ------ .../scrolling-quirks-vs-nonquirks.html.ini | 27 ++++++--- 31 files changed, 72 insertions(+), 238 deletions(-) delete mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-position/containing-block-change-scrollframe.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/css-position/position-absolute-under-non-containing-stacking-context.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-fractional-offset.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-scrolled-remove-sibling.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-table-td-top.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/add-background-attachment-fixed-during-smooth-scroll.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/background-change-during-smooth-scroll.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/dom-element-scroll.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/elementFromPoint-float-in-table.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/elementScroll-002.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/elementsFromPoint-inline-vlr-ltr.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/pt-to-px-width.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/scrollWidthHeightWhenNotScrollable.xht.ini diff --git a/components/layout_2020/flow/root.rs b/components/layout_2020/flow/root.rs index 80a42c70701..fb05049f4a8 100644 --- a/components/layout_2020/flow/root.rs +++ b/components/layout_2020/flow/root.rs @@ -538,6 +538,39 @@ impl FragmentTree { }) .unwrap_or_else(Rect::zero) } + + pub fn get_scroll_area_for_node(&self, requested_node: OpaqueNode) -> Rect { + let mut scroll_area: PhysicalRect = 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 diff --git a/components/layout_2020/query.rs b/components/layout_2020/query.rs index 0e99ec88fac..f59163a3a7c 100644 --- a/components/layout_2020/query.rs +++ b/components/layout_2020/query.rs @@ -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 { - Rect::zero() +pub fn process_node_scroll_area_request( + requested_node: OpaqueNode, + fragment_tree: Option>, +) -> Rect { + 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. diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index 0a1dff2d284..18851ef905c 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -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) }; diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini deleted file mode 100644 index c2c7efbdb1e..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-local-positioning-2.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[attachment-local-positioning-2.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini deleted file mode 100644 index 56dea1c6b86..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-local/attachment-scroll-positioning-1.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[attachment-scroll-positioning-1.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini deleted file mode 100644 index b5ff1f789a7..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-backgrounds/scroll-positioned-multiple-background-images.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[scroll-positioned-multiple-background-images.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/containing-block-change-scrollframe.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/containing-block-change-scrollframe.html.ini deleted file mode 100644 index 242f79c08a9..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-position/containing-block-change-scrollframe.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[containing-block-change-scrollframe.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/position-absolute-under-non-containing-stacking-context.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/position-absolute-under-non-containing-stacking-context.html.ini new file mode 100644 index 00000000000..ac4f8b57db3 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/css-position/position-absolute-under-non-containing-stacking-context.html.ini @@ -0,0 +1,2 @@ +[position-absolute-under-non-containing-stacking-context.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini index 9293d969cdb..85b4aad53ef 100644 --- a/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini +++ b/tests/wpt/metadata-layout-2020/css/css-position/positon-absolute-scrollable-overflow-001.html.ini @@ -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 diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini deleted file mode 100644 index 3018d79f1af..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-001.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-escape-scroller-001.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini deleted file mode 100644 index 990a7ae58c6..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-escape-scroller-003.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-escape-scroller-003.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-fractional-offset.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-fractional-offset.html.ini deleted file mode 100644 index 396d46a2f2b..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-fractional-offset.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-sticky-fractional-offset.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini index 7fb4bc0467c..c36358f4f58 100644 --- a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini +++ b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-overflow-padding.html.ini @@ -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 diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-scrolled-remove-sibling.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-scrolled-remove-sibling.html.ini deleted file mode 100644 index 7272a91e0af..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-scrolled-remove-sibling.html.ini +++ /dev/null @@ -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 diff --git a/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-table-td-top.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-table-td-top.html.ini new file mode 100644 index 00000000000..c1aa4f40983 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/css-position/sticky/position-sticky-table-td-top.html.ini @@ -0,0 +1,2 @@ +[position-sticky-table-td-top.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/cssom-view/MediaQueryList-addListener-removeListener.html.ini b/tests/wpt/metadata-layout-2020/css/cssom-view/MediaQueryList-addListener-removeListener.html.ini index 314dca9c1f5..153b135b9a9 100644 --- a/tests/wpt/metadata-layout-2020/css/cssom-view/MediaQueryList-addListener-removeListener.html.ini +++ b/tests/wpt/metadata-layout-2020/css/cssom-view/MediaQueryList-addListener-removeListener.html.ini @@ -1,3 +1,9 @@ [MediaQueryList-addListener-removeListener.html] [listeners are called when