aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/layout_interface.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-01-13 21:00:18 -0800
committerPatrick Walton <pcwalton@mimiga.net>2014-01-14 21:51:24 -0800
commit7d447dbc062429b97d75bebd6fdea7878fbd049d (patch)
tree5903ac1ee64a8a9edf6cf4308daad8a96b5186cf /src/components/script/layout_interface.rs
parent563d6ef91a43a4ebefb87281db7e4813d2afcee6 (diff)
downloadservo-7d447dbc062429b97d75bebd6fdea7878fbd049d.tar.gz
servo-7d447dbc062429b97d75bebd6fdea7878fbd049d.zip
script: Stop trusting pointers to DOM nodes that layout provides.
Pointers to DOM nodes from layout could go stale if incremental reflow does not correctly destroy dead nodes. Therefore, we ask the JavaScript garbage collector to verify that each DOM node is indeed a valid pointer before calling event handlers on it, and fail otherwise.
Diffstat (limited to 'src/components/script/layout_interface.rs')
-rw-r--r--src/components/script/layout_interface.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/components/script/layout_interface.rs b/src/components/script/layout_interface.rs
index 613e61a3429..b0b9ec479f4 100644
--- a/src/components/script/layout_interface.rs
+++ b/src/components/script/layout_interface.rs
@@ -14,8 +14,9 @@ use geom::rect::Rect;
use geom::size::Size2D;
use script_task::{ScriptChan};
use servo_util::geometry::Au;
-use std::comm::{Chan, SharedChan};
use std::cmp;
+use std::comm::{Chan, SharedChan};
+use std::libc::c_void;
use style::Stylesheet;
/// Asynchronous messages that script can send to layout.
@@ -58,9 +59,13 @@ pub enum LayoutQuery {
HitTestQuery(AbstractNode, Point2D<f32>, Chan<Result<HitTestResponse, ()>>),
}
+/// The address of a node. Layout sends these back. They must be validated via
+/// `from_untrusted_node_address` before they can be used, because we do not trust layout.
+pub type UntrustedNodeAddress = *c_void;
+
pub struct ContentBoxResponse(Rect<Au>);
pub struct ContentBoxesResponse(~[Rect<Au>]);
-pub struct HitTestResponse(AbstractNode);
+pub struct HitTestResponse(UntrustedNodeAddress);
/// Determines which part of the
#[deriving(Eq, Ord)]