diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-28 19:40:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-28 19:44:21 +0200 |
commit | 723ea4bcd705a029bf632204b03b91e8aca29b87 (patch) | |
tree | c2ca98579828d4a05656921522eaa1ef7d13866e /Userland | |
parent | 37f0bd0a42e1090cc61b1a7a480eb0c1ca376dec (diff) | |
download | serenity-723ea4bcd705a029bf632204b03b91e8aca29b87.zip |
LibWeb: Add Layout::Box::border_box_as_relative_rect()
This helper returns the border box (content+padding+border) of a given
box. Margin not included.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Box.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Box.h b/Userland/Libraries/LibWeb/Layout/Box.h index dc7ecee20b..d256ecbc73 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.h +++ b/Userland/Libraries/LibWeb/Layout/Box.h @@ -88,6 +88,17 @@ public: return { m_offset, m_size }; } + Gfx::FloatRect border_box_as_relative_rect() const + { + auto rect = content_box_as_relative_rect(); + auto border_box = box_model().border_box(); + rect.set_x(rect.x() - border_box.left); + rect.set_width(rect.width() + border_box.left + border_box.right); + rect.set_y(rect.y() - border_box.top); + rect.set_height(rect.height() + border_box.top + border_box.bottom); + return rect; + } + Gfx::FloatRect margin_box_as_relative_rect() const { auto rect = content_box_as_relative_rect(); |