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.
This commit is contained in:
Zhen Zhang 2016-04-03 15:41:37 +08:00
parent f73c6143d5
commit fefdaf76de
12 changed files with 243 additions and 9 deletions

View file

@ -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.

View file

@ -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"),
}
}
}