mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
layout: return None bounding box when no nodes found (#31253)
Signed-off-by: syvb <me@iter.ca>
This commit is contained in:
parent
95931de499
commit
436e949296
6 changed files with 18 additions and 24 deletions
|
@ -93,8 +93,9 @@ impl FragmentTree {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_content_box_for_node(&self, requested_node: OpaqueNode) -> Rect<Au> {
|
pub fn get_content_box_for_node(&self, requested_node: OpaqueNode) -> Option<Rect<Au>> {
|
||||||
let mut bounding_box = PhysicalRect::zero();
|
let mut bounding_box = PhysicalRect::zero();
|
||||||
|
let mut found_any_nodes = false;
|
||||||
let tag_to_find = Tag::new(requested_node);
|
let tag_to_find = Tag::new(requested_node);
|
||||||
self.find(|fragment, _, containing_block| {
|
self.find(|fragment, _, containing_block| {
|
||||||
if fragment.tag() != Some(tag_to_find) {
|
if fragment.tag() != Some(tag_to_find) {
|
||||||
|
@ -114,13 +115,15 @@ impl FragmentTree {
|
||||||
Fragment::Anonymous(_) => return None,
|
Fragment::Anonymous(_) => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
found_any_nodes = true;
|
||||||
bounding_box = fragment_relative_rect
|
bounding_box = fragment_relative_rect
|
||||||
.translate(containing_block.origin.to_vector())
|
.translate(containing_block.origin.to_vector())
|
||||||
.union(&bounding_box);
|
.union(&bounding_box);
|
||||||
None::<()>
|
None::<()>
|
||||||
});
|
});
|
||||||
|
|
||||||
Rect::new(
|
if found_any_nodes {
|
||||||
|
Some(Rect::new(
|
||||||
Point2D::new(
|
Point2D::new(
|
||||||
Au::from_f32_px(bounding_box.origin.x.px()),
|
Au::from_f32_px(bounding_box.origin.x.px()),
|
||||||
Au::from_f32_px(bounding_box.origin.y.px()),
|
Au::from_f32_px(bounding_box.origin.y.px()),
|
||||||
|
@ -129,7 +132,10 @@ impl FragmentTree {
|
||||||
Au::from_f32_px(bounding_box.size.width.px()),
|
Au::from_f32_px(bounding_box.size.width.px()),
|
||||||
Au::from_f32_px(bounding_box.size.height.px()),
|
Au::from_f32_px(bounding_box.size.height.px()),
|
||||||
),
|
),
|
||||||
)
|
))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_border_dimensions_for_node(&self, requested_node: OpaqueNode) -> Rect<i32> {
|
pub fn get_border_dimensions_for_node(&self, requested_node: OpaqueNode) -> Rect<i32> {
|
||||||
|
|
|
@ -173,7 +173,7 @@ pub fn process_content_box_request(
|
||||||
requested_node: OpaqueNode,
|
requested_node: OpaqueNode,
|
||||||
fragment_tree: Option<Arc<FragmentTree>>,
|
fragment_tree: Option<Arc<FragmentTree>>,
|
||||||
) -> Option<Rect<Au>> {
|
) -> Option<Rect<Au>> {
|
||||||
Some(fragment_tree?.get_content_box_for_node(requested_node))
|
fragment_tree?.get_content_box_for_node(requested_node)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_content_boxes_request(_requested_node: OpaqueNode) -> Vec<Rect<Au>> {
|
pub fn process_content_boxes_request(_requested_node: OpaqueNode) -> Vec<Rect<Au>> {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[not-rendered-dimension-getter.html]
|
|
||||||
[Image intrinsic dimensions are returned if the image isn't rendered]
|
|
||||||
expected: FAIL
|
|
|
@ -2,6 +2,3 @@
|
||||||
expected: ERROR
|
expected: ERROR
|
||||||
[WebGL test #2: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #2: Unable to fetch WebGL rendering context for Canvas]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #0: img was loaded]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[origin-clean-conformance.html]
|
|
||||||
[WebGL test #0: img was loaded]
|
|
||||||
expected: FAIL
|
|
|
@ -2,6 +2,3 @@
|
||||||
expected: ERROR
|
expected: ERROR
|
||||||
[WebGL test #2: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #2: Unable to fetch WebGL rendering context for Canvas]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #0: img was loaded]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue