diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2016-06-08 18:46:02 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2016-06-10 18:43:04 -0700 |
commit | 041cfe6d0a07882819ae35380c286e7fe09c1013 (patch) | |
tree | 464033c42b2417f4f993e70840ea8a2bae03b3c9 /components/script/script_thread.rs | |
parent | ce88b8ed30feff9c7d3f067041fe5d781e012351 (diff) | |
download | servo-041cfe6d0a07882819ae35380c286e7fe09c1013.tar.gz servo-041cfe6d0a07882819ae35380c286e7fe09c1013.zip |
script: When using WebRender, keep the DOM-side scroll positions for
elements with `overflow: scroll` up to date, and take them into account
when doing hit testing.
Closes #11648.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 51460cd4bb9..7684eb9e336 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -85,11 +85,12 @@ use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult}; use script_traits::{InitialScriptState, MouseButton, MouseEventType, MozBrowserEvent}; use script_traits::{NewLayoutInfo, ScriptMsg as ConstellationMsg}; use script_traits::{ScriptThreadFactory, TimerEvent, TimerEventRequest, TimerSource}; -use script_traits::{TouchEventType, TouchId}; +use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress}; use std::borrow::ToOwned; use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; use std::option::Option; +use std::ptr; use std::rc::Rc; use std::result::Result; use std::sync::atomic::{Ordering, AtomicBool}; @@ -728,9 +729,9 @@ impl ScriptThread { self.handle_viewport(id, rect); }) } - FromConstellation(ConstellationControlMsg::SetScrollState(id, scroll_offset)) => { + FromConstellation(ConstellationControlMsg::SetScrollState(id, scroll_state)) => { self.profile_event(ScriptThreadEventCategory::SetScrollState, || { - self.handle_set_scroll_state(id, &scroll_offset); + self.handle_set_scroll_state(id, &scroll_state); }) } FromConstellation(ConstellationControlMsg::TickAllAnimations( @@ -1110,17 +1111,31 @@ impl ScriptThread { panic!("Page rect message sent to nonexistent pipeline"); } - fn handle_set_scroll_state(&self, id: PipelineId, scroll_state: &Point2D<f32>) { - 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 + fn handle_set_scroll_state(&self, + id: PipelineId, + scroll_states: &[(UntrustedNodeAddress, Point2D<f32>)]) { + let window = match self.browsing_context.get() { + Some(context) => { + match context.find(id) { + Some(inner_context) => inner_context.active_window(), + None => { + panic!("Set scroll state message sent to nonexistent pipeline: {:?}", id) + } + } } - } + None => panic!("Set scroll state message sent to nonexistent pipeline: {:?}", id), + }; - panic!("Set scroll state message message sent to nonexistent pipeline: {:?}", id); + let mut scroll_offsets = HashMap::new(); + for &(node_address, ref scroll_offset) in scroll_states { + if node_address == UntrustedNodeAddress(ptr::null()) { + window.update_viewport_for_scroll(-scroll_offset.x, -scroll_offset.y); + } else { + scroll_offsets.insert(node_address, + Point2D::new(-scroll_offset.x, -scroll_offset.y)); + } + } + window.set_scroll_offsets(scroll_offsets) } fn handle_new_layout(&self, new_layout_info: NewLayoutInfo) { |