diff options
author | Tetsuharu OHZEKI <saneyuki.snyk@gmail.com> | 2014-04-23 02:33:37 +0900 |
---|---|---|
committer | Tetsuharu OHZEKI <saneyuki.snyk@gmail.com> | 2014-04-24 14:36:43 +0900 |
commit | dce92dc44a2f548dcf2558a47cfc47d8e7f774c3 (patch) | |
tree | 65ab26220f25bbf4c284b4bfa420dfea964c7f3a /src/components/script/dom/node.rs | |
parent | 5e27f49fe2b7fb31d0635455b491c088a2b19ccf (diff) | |
download | servo-dce92dc44a2f548dcf2558a47cfc47d8e7f774c3.tar.gz servo-dce92dc44a2f548dcf2558a47cfc47d8e7f774c3.zip |
Add NodeHelpers::get_bounding_content_box().
Diffstat (limited to 'src/components/script/dom/node.rs')
-rw-r--r-- | src/components/script/dom/node.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index a136e564a45..53c3776fab5 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -26,9 +26,10 @@ use dom::processinginstruction::ProcessingInstruction; use dom::text::Text; use dom::virtualmethods::{VirtualMethods, vtable_for}; use dom::window::Window; +use geom::rect::Rect; use html::hubbub_html_parser::build_element_from_tag; -use layout_interface::{LayoutChan, ReapLayoutDataMsg, UntrustedNodeAddress}; -use layout_interface::TrustedNodeAddress; +use layout_interface::{ContentBoxQuery, ContentBoxResponse, LayoutChan, ReapLayoutDataMsg, TrustedNodeAddress, UntrustedNodeAddress}; +use servo_util::geometry::Au; use servo_util::str::{DOMString, null_str_as_empty}; use js::jsapi::{JSContext, JSObject, JSRuntime}; @@ -283,6 +284,8 @@ pub trait NodeHelpers { fn from_untrusted_node_address(runtime: *JSRuntime, candidate: UntrustedNodeAddress) -> Self; fn to_trusted_node_address(&self) -> TrustedNodeAddress; + + fn get_bounding_content_box(&self) -> Rect<Au>; } impl NodeHelpers for JS<Node> { @@ -565,6 +568,15 @@ impl NodeHelpers for JS<Node> { fn to_trusted_node_address(&self) -> TrustedNodeAddress { TrustedNodeAddress(self.get() as *Node as *libc::c_void) } + + fn get_bounding_content_box(&self) -> Rect<Au> { + let window = window_from_node(self); + let page = window.get().page(); + let (chan, port) = channel(); + let addr = self.to_trusted_node_address(); + let ContentBoxResponse(rect) = page.query_layout(ContentBoxQuery(addr, chan), port); + rect + } } // |