mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
LibWeb: Simplify InlinePaintable::bounding_rect() implementation
No behavior change expected.
This commit is contained in:
parent
768b8415f2
commit
96d5f555e1
1 changed files with 4 additions and 16 deletions
|
@ -217,30 +217,18 @@ Optional<HitTestResult> InlinePaintable::hit_test(CSSPixelPoint position, HitTes
|
||||||
|
|
||||||
CSSPixelRect InlinePaintable::bounding_rect() const
|
CSSPixelRect InlinePaintable::bounding_rect() const
|
||||||
{
|
{
|
||||||
auto top = CSSPixels::max();
|
CSSPixelRect bounding_rect;
|
||||||
auto left = CSSPixels::max();
|
|
||||||
auto right = CSSPixels::min();
|
|
||||||
auto bottom = CSSPixels::min();
|
|
||||||
auto has_fragments = false;
|
|
||||||
for_each_fragment([&](auto const& fragment, bool, bool) {
|
for_each_fragment([&](auto const& fragment, bool, bool) {
|
||||||
has_fragments = true;
|
|
||||||
auto fragment_absolute_rect = fragment.absolute_rect();
|
auto fragment_absolute_rect = fragment.absolute_rect();
|
||||||
if (fragment_absolute_rect.top() < top)
|
bounding_rect = bounding_rect.united(fragment_absolute_rect);
|
||||||
top = fragment_absolute_rect.top();
|
|
||||||
if (fragment_absolute_rect.left() < left)
|
|
||||||
left = fragment_absolute_rect.left();
|
|
||||||
if (fragment_absolute_rect.right() > right)
|
|
||||||
right = fragment_absolute_rect.right();
|
|
||||||
if (fragment_absolute_rect.bottom() > bottom)
|
|
||||||
bottom = fragment_absolute_rect.bottom();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!has_fragments) {
|
if (bounding_rect.is_empty()) {
|
||||||
// FIXME: This is adhoc, and we should return rect of empty fragment instead.
|
// FIXME: This is adhoc, and we should return rect of empty fragment instead.
|
||||||
auto containing_block_position_in_absolute_coordinates = containing_block()->paintable_box()->absolute_position();
|
auto containing_block_position_in_absolute_coordinates = containing_block()->paintable_box()->absolute_position();
|
||||||
return { containing_block_position_in_absolute_coordinates, { 0, 0 } };
|
return { containing_block_position_in_absolute_coordinates, { 0, 0 } };
|
||||||
}
|
}
|
||||||
return { left, top, right - left, bottom - top };
|
return bounding_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue