aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/fragment_tree/fragment_tree.rs
diff options
context:
space:
mode:
authorSmitty <me@iter.ca>2024-02-02 18:24:20 -0500
committerGitHub <noreply@github.com>2024-02-02 23:24:20 +0000
commit436e949296890b5388af4d5a48cf139ceaa2cc58 (patch)
treecd2b929dd02aeba8c535d8549424293733deac0e /components/layout_2020/fragment_tree/fragment_tree.rs
parent95931de499d19927e43c277bb36d2d9e506e3dae (diff)
downloadservo-436e949296890b5388af4d5a48cf139ceaa2cc58.tar.gz
servo-436e949296890b5388af4d5a48cf139ceaa2cc58.zip
layout: return None bounding box when no nodes found (#31253)
Signed-off-by: syvb <me@iter.ca>
Diffstat (limited to 'components/layout_2020/fragment_tree/fragment_tree.rs')
-rw-r--r--components/layout_2020/fragment_tree/fragment_tree.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs
index 3244a8bd2bb..5e50a54768c 100644
--- a/components/layout_2020/fragment_tree/fragment_tree.rs
+++ b/components/layout_2020/fragment_tree/fragment_tree.rs
@@ -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 found_any_nodes = false;
let tag_to_find = Tag::new(requested_node);
self.find(|fragment, _, containing_block| {
if fragment.tag() != Some(tag_to_find) {
@@ -114,22 +115,27 @@ impl FragmentTree {
Fragment::Anonymous(_) => return None,
};
+ found_any_nodes = true;
bounding_box = fragment_relative_rect
.translate(containing_block.origin.to_vector())
.union(&bounding_box);
None::<()>
});
- Rect::new(
- Point2D::new(
- Au::from_f32_px(bounding_box.origin.x.px()),
- Au::from_f32_px(bounding_box.origin.y.px()),
- ),
- Size2D::new(
- Au::from_f32_px(bounding_box.size.width.px()),
- Au::from_f32_px(bounding_box.size.height.px()),
- ),
- )
+ if found_any_nodes {
+ Some(Rect::new(
+ Point2D::new(
+ Au::from_f32_px(bounding_box.origin.x.px()),
+ Au::from_f32_px(bounding_box.origin.y.px()),
+ ),
+ Size2D::new(
+ Au::from_f32_px(bounding_box.size.width.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> {