layout: Expose whether the element was rendered in content_box_query to script.

But don't change the API yet.
This commit is contained in:
Emilio Cobos Álvarez 2017-01-17 00:22:42 +01:00
parent 8159dac506
commit 485fe874e8
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 13 additions and 12 deletions

View file

@ -524,8 +524,12 @@ impl Node {
TrustedNodeAddress(&*self as *const Node as *const libc::c_void)
}
/// Returns the rendered bounding content box if the element is rendered,
/// and none otherwise.
pub fn bounding_content_box(&self) -> Rect<Au> {
window_from_node(self).content_box_query(self.to_trusted_node_address())
window_from_node(self)
.content_box_query(self.to_trusted_node_address())
.unwrap_or_else(Rect::zero)
}
pub fn content_boxes(&self) -> Vec<Rect<Au>> {

View file

@ -1216,11 +1216,11 @@ impl Window {
&*self.layout_rpc
}
pub fn content_box_query(&self, content_box_request: TrustedNodeAddress) -> Rect<Au> {
pub fn content_box_query(&self, content_box_request: TrustedNodeAddress) -> Option<Rect<Au>> {
if !self.reflow(ReflowGoal::ForScriptQuery,
ReflowQueryType::ContentBoxQuery(content_box_request),
ReflowReason::Query) {
return Rect::zero();
return None;
}
let ContentBoxResponse(rect) = self.layout_rpc.content_box();
rect