From a86f77e36d310737ce9e87e1ab49340cfdd89ed7 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 24 May 2016 18:40:39 -0700 Subject: script: Keep the DOM-side viewport up to date when scrolling happens in WebRender. This happens asynchronously, just as it does in non-WebRender mode. This functionality is a prerequisite for doing proper display-list-based hit testing in WebRender, since it moves the scroll offsets into Servo (and, specifically, into the script thread, enabling iframe event forwarding) instead of keeping them private to WebRender. Requires servo/webrender_traits#55 and servo/webrender#277. Partially addresses #11108. --- components/script/script_thread.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 20a8602a249..b913c5bbae0 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -708,6 +708,11 @@ impl ScriptThread { self.handle_viewport(id, rect); }) } + FromConstellation(ConstellationControlMsg::SetScrollState(id, scroll_offset)) => { + self.profile_event(ScriptThreadEventCategory::SetScrollState, || { + self.handle_set_scroll_state(id, &scroll_offset); + }) + } FromConstellation(ConstellationControlMsg::TickAllAnimations( pipeline_id)) => { if !animation_ticks.contains(&pipeline_id) { @@ -850,6 +855,9 @@ impl ScriptThread { ScriptThreadEventCategory::NetworkEvent => ProfilerCategory::ScriptNetworkEvent, ScriptThreadEventCategory::Resize => ProfilerCategory::ScriptResize, ScriptThreadEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent, + ScriptThreadEventCategory::SetScrollState => { + ProfilerCategory::ScriptSetScrollState + } ScriptThreadEventCategory::UpdateReplacedElement => { ProfilerCategory::ScriptUpdateReplacedElement } @@ -877,6 +885,8 @@ impl ScriptThread { self.handle_resize_inactive_msg(id, new_size), ConstellationControlMsg::Viewport(..) => panic!("should have handled Viewport already"), + ConstellationControlMsg::SetScrollState(..) => + panic!("should have handled SetScrollState already"), ConstellationControlMsg::Resize(..) => panic!("should have handled Resize already"), ConstellationControlMsg::ExitPipeline(..) => @@ -1077,6 +1087,19 @@ impl ScriptThread { panic!("Page rect message sent to nonexistent pipeline"); } + fn handle_set_scroll_state(&self, id: PipelineId, scroll_state: &Point2D) { + let context = self.browsing_context.get(); + if let Some(context) = context { + if let Some(inner_context) = context.find(id) { + let window = inner_context.active_window(); + window.update_viewport_for_scroll(-scroll_state.x, -scroll_state.y); + return + } + } + + panic!("Set scroll state message message sent to nonexistent pipeline: {:?}", id); + } + fn handle_new_layout(&self, new_layout_info: NewLayoutInfo) { let NewLayoutInfo { containing_pipeline_id, -- cgit v1.2.3