diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-04-25 08:29:09 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-04-25 21:25:00 +0200 |
commit | 3ab5e2a188a2e6e892367dfbcd4880bd9aadeab8 (patch) | |
tree | 41e7c3af2ec5467bf2432fd03dca2e65c0c99ebf /components/layout_thread/lib.rs | |
parent | 2ae158dec19d735ee1ffc6a4e7aab495b0d96dc1 (diff) | |
download | servo-3ab5e2a188a2e6e892367dfbcd4880bd9aadeab8.tar.gz servo-3ab5e2a188a2e6e892367dfbcd4880bd9aadeab8.zip |
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.
Diffstat (limited to 'components/layout_thread/lib.rs')
-rw-r--r-- | components/layout_thread/lib.rs | 36 |
1 files changed, 19 insertions, 17 deletions
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<ScrollState>, |