diff options
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 8902a0545ab..71547c860bc 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -524,8 +524,15 @@ impl Node { TrustedNodeAddress(&*self as *const Node as *const libc::c_void) } - pub fn bounding_content_box(&self) -> Rect<Au> { - window_from_node(self).content_box_query(self.to_trusted_node_address()) + /// Returns the rendered bounding content box if the element is rendered, + /// and none otherwise. + pub fn bounding_content_box(&self) -> Option<Rect<Au>> { + window_from_node(self) + .content_box_query(self.to_trusted_node_address()) + } + + pub fn bounding_content_box_or_zero(&self) -> Rect<Au> { + self.bounding_content_box().unwrap_or_else(Rect::zero) } pub fn content_boxes(&self) -> Vec<Rect<Au>> { |