Add NodeHelpers::get_bounding_content_box().

This commit is contained in:
Tetsuharu OHZEKI 2014-04-23 02:33:37 +09:00
parent 5e27f49fe2
commit dce92dc44a
4 changed files with 23 additions and 26 deletions

View file

@ -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
}
}
//