aboutsummaryrefslogtreecommitdiffstats
path: root/components/compositing
diff options
context:
space:
mode:
authorZhen Zhang <izgzhen@gmail.com>2016-04-03 15:41:37 +0800
committerZhen Zhang <izgzhen@gmail.com>2016-04-19 12:27:35 +0800
commitfefdaf76ded7675c0c67fd33f5abfbb5f74ac30f (patch)
tree90131ccb368cc04b279f82b085052ae4236495e2 /components/compositing
parentf73c6143d5375db80fd2e0b7de96a99c78b5866b (diff)
downloadservo-fefdaf76ded7675c0c67fd33f5abfbb5f74ac30f.tar.gz
servo-fefdaf76ded7675c0c67fd33f5abfbb5f74ac30f.zip
Implement ScrollTop and ScrollLeft getters:
Add new compositor message to get scroll_offset; Add new layout query for computed value of overflow-x/y; Implement layer_id method for ThreadSafeLayoutNode; Add new layout query for layer_id; Implement script interface for getting scrollTop and scrollLeft, as well as relavant helper functions.
Diffstat (limited to 'components/compositing')
-rw-r--r--components/compositing/compositor.rs10
-rw-r--r--components/compositing/compositor_thread.rs7
2 files changed, 17 insertions, 0 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 71528e8b88a..bfc2fa1abc6 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -714,6 +714,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let _ = sender.send(());
}
+ (Msg::GetScrollOffset(pipeline_id, layer_id, sender), ShutdownState::NotShuttingDown) => {
+ match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) {
+ Some(ref layer) => {
+ let typed = layer.extra_data.borrow().scroll_offset;
+ let _ = sender.send(Point2D::new(typed.x.get(), typed.y.get()));
+ },
+ None => {},
+ }
+ }
+
// When we are shutting_down, we need to avoid performing operations
// such as Paint that may crash because we have begun tearing down
// the rest of our resources.
diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs
index fdfd4c633bf..d624e0212a9 100644
--- a/components/compositing/compositor_thread.rs
+++ b/components/compositing/compositor_thread.rs
@@ -98,6 +98,10 @@ pub fn run_script_listener_thread(compositor_proxy: Box<CompositorProxy + 'stati
compositor_proxy.send(Msg::TouchEventProcessed(result))
}
+ ScriptToCompositorMsg::GetScrollOffset(pid, lid, send) => {
+ compositor_proxy.send(Msg::GetScrollOffset(pid, lid, send));
+ }
+
ScriptToCompositorMsg::Exited => break,
}
}
@@ -231,6 +235,8 @@ pub enum Msg {
MoveTo(Point2D<i32>),
/// Resize the window to size
ResizeTo(Size2D<u32>),
+ /// Get scroll offset of a layer
+ GetScrollOffset(PipelineId, LayerId, IpcSender<Point2D<f32>>),
/// A pipeline was shut down.
// This message acts as a synchronization point between the constellation,
// when it shuts down a pipeline, to the compositor; when the compositor
@@ -272,6 +278,7 @@ impl Debug for Msg {
Msg::MoveTo(..) => write!(f, "MoveTo"),
Msg::ResizeTo(..) => write!(f, "ResizeTo"),
Msg::PipelineExited(..) => write!(f, "PipelineExited"),
+ Msg::GetScrollOffset(..) => write!(f, "GetScrollOffset"),
}
}
}