diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-15 14:18:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-15 14:18:17 +0200 |
commit | eac31e21f2bf3c1a4cd5bb4e5d0c19a75fd0b395 (patch) | |
tree | d507d7da41796409ec30d40274b5d558fb52e0c2 /Userland/Libraries/LibWeb/Layout/Box.cpp | |
parent | 1103eb8d4437abfd954820fd35e0d1dc172ed0de (diff) | |
download | serenity-eac31e21f2bf3c1a4cd5bb4e5d0c19a75fd0b395.zip |
LibWeb: Avoid some redundant calls to Layout::Box::absolute_rect()
Computing the absolute rect of a box requires walking the chain of
containing blocks and apply any offsets encountered. This can be slow in
deeply nested box trees, so let's at least avoid doing it multiple times
when once is enough.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/Box.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Box.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp index 99717c3a56..85ad404327 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.cpp +++ b/Userland/Libraries/LibWeb/Layout/Box.cpp @@ -305,11 +305,12 @@ Box::BorderRadiusData Box::normalized_border_radius_data() auto top_right_radius = computed_values().border_top_right_radius().resolved_or_zero(*this, width()).to_px(*this); // Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap + auto bordered_rect = this->bordered_rect(); auto f = 1.0f; - f = min(f, bordered_rect().width() / (float)(top_left_radius + top_right_radius)); - f = min(f, bordered_rect().height() / (float)(top_right_radius + bottom_right_radius)); - f = min(f, bordered_rect().width() / (float)(bottom_left_radius + bottom_right_radius)); - f = min(f, bordered_rect().height() / (float)(top_left_radius + bottom_left_radius)); + f = min(f, bordered_rect.width() / (float)(top_left_radius + top_right_radius)); + f = min(f, bordered_rect.height() / (float)(top_right_radius + bottom_right_radius)); + f = min(f, bordered_rect.width() / (float)(bottom_left_radius + bottom_right_radius)); + f = min(f, bordered_rect.height() / (float)(top_left_radius + bottom_left_radius)); top_left_radius = (int)(top_left_radius * f); top_right_radius = (int)(top_right_radius * f); |