aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2017-05-12 10:56:18 +0200
committerMartin Robinson <mrobinson@igalia.com>2017-05-16 15:27:09 +0200
commit9fd2df5c09a35eef8b0b503dd98579c4b9092e31 (patch)
tree46192d2163e9aa714cc257ba6d4cab1415617131 /components/script/dom/window.rs
parent7ca393a9603d7fa72e58a36bd53c29db396f6ea4 (diff)
downloadservo-9fd2df5c09a35eef8b0b503dd98579c4b9092e31.tar.gz
servo-9fd2df5c09a35eef8b0b503dd98579c4b9092e31.zip
Properly handle scroll offsets in hit testing
Scroll roots are no longer nested containers holding items, so instead we need to track the offsets of each, carefully handling fixed position items and stacking contexts that create new reference frames. Additionally, we remove the complexity of the pre-computed page scroll offset, instead opting to send script scrolls to the layout task in order to more quickly have a ScrollState there that matches the script's idea of the scroll world. Fixes #16405.
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 4317d2890b7..65d1a591adc 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -75,11 +75,11 @@ use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, Lay
use script_layout_interface::rpc::{MarginStyleResponse, NodeScrollRootIdResponse};
use script_layout_interface::rpc::{ResolvedStyleResponse, TextIndexResponse};
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThreadEventCategory};
-use script_thread::{MainThreadScriptChan, MainThreadScriptMsg, Runnable, RunnableWrapper};
-use script_thread::{SendableMainThreadScriptChan, ImageCacheMsg, ScriptThread};
-use script_traits::{ConstellationControlMsg, LoadData, MozBrowserEvent, UntrustedNodeAddress};
-use script_traits::{DocumentState, TimerEvent, TimerEventId};
-use script_traits::{ScriptMsg as ConstellationMsg, TimerSchedulerMsg, WindowSizeData, WindowSizeType};
+use script_thread::{ImageCacheMsg, MainThreadScriptChan, MainThreadScriptMsg, Runnable};
+use script_thread::{RunnableWrapper, ScriptThread, SendableMainThreadScriptChan};
+use script_traits::{ConstellationControlMsg, DocumentState, LoadData, MozBrowserEvent};
+use script_traits::{ScriptMsg as ConstellationMsg, ScrollState, TimerEvent, TimerEventId};
+use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use servo_atoms::Atom;
use servo_config::opts;
@@ -1111,6 +1111,11 @@ impl Window {
ScrollBehavior::Smooth => true
};
+ self.layout_chan.send(Msg::UpdateScrollStateFromScript(ScrollState {
+ scroll_root_id: scroll_root_id,
+ scroll_offset: Point2D::new(-x, -y),
+ })).unwrap();
+
// TODO (farodin91): Raise an event to stop the current_viewport
self.update_viewport_for_scroll(x, y);
@@ -1372,14 +1377,8 @@ impl Window {
client_point: Point2D<f32>,
update_cursor: bool)
-> Option<UntrustedNodeAddress> {
- let translated_point =
- Point2D::new(client_point.x + self.PageXOffset() as f32,
- client_point.y + self.PageYOffset() as f32);
-
if !self.reflow(ReflowGoal::ForScriptQuery,
- ReflowQueryType::HitTestQuery(translated_point,
- client_point,
- update_cursor),
+ ReflowQueryType::HitTestQuery(client_point, update_cursor),
ReflowReason::Query) {
return None
}