mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibWeb: Simplify InlinePaintable::bounding_rect() implementation
No behavior change expected.
This commit is contained in:
parent
768b8415f2
commit
96d5f555e1
Notes:
sideshowbarker
2024-07-16 23:44:30 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/96d5f555e1 Pull-request: https://github.com/SerenityOS/serenity/pull/23015
@ -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…
Reference in New Issue
Block a user