mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +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
|
||||
{
|
||||
auto top = CSSPixels::max();
|
||||
auto left = CSSPixels::max();
|
||||
auto right = CSSPixels::min();
|
||||
auto bottom = CSSPixels::min();
|
||||
auto has_fragments = false;
|
||||
CSSPixelRect bounding_rect;
|
||||
for_each_fragment([&](auto const& fragment, bool, bool) {
|
||||
has_fragments = true;
|
||||
auto fragment_absolute_rect = fragment.absolute_rect();
|
||||
if (fragment_absolute_rect.top() < top)
|
||||
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();
|
||||
bounding_rect = bounding_rect.united(fragment_absolute_rect);
|
||||
});
|
||||
|
||||
if (!has_fragments) {
|
||||
if (bounding_rect.is_empty()) {
|
||||
// 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();
|
||||
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