diff options
author | Matthew Olsson <matthewcolsson@gmail.com> | 2021-04-12 11:47:09 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-02 22:48:06 +0200 |
commit | 88cfaf7bf0ad2d5d3adb2654a5f7cc5b810a3ccd (patch) | |
tree | 47ec61dc9f8fb3ef9867be1cda3db5568e9b6686 /Userland/Libraries/LibWeb/Layout | |
parent | ac238b3bd63e47a334c6859ddb6570b89f7be3dc (diff) | |
download | serenity-88cfaf7bf0ad2d5d3adb2654a5f7cc5b810a3ccd.zip |
LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
9 files changed, 9 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockBox.cpp b/Userland/Libraries/LibWeb/Layout/BlockBox.cpp index 79a6c1e855..6682dbb8de 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockBox.cpp @@ -142,7 +142,7 @@ bool BlockBox::handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsi if (!is_scrollable()) return false; auto new_offset = m_scroll_offset; - new_offset.move_by(0, wheel_delta); + new_offset.translate_by(0, wheel_delta); set_scroll_offset(new_offset); return true; diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index a93207c9c0..815f2bf6bc 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -550,7 +550,7 @@ static Gfx::FloatRect rect_in_coordinate_space(const Box& box, const Box& contex for (auto* ancestor = box.parent(); ancestor; ancestor = ancestor->parent()) { if (is<Box>(*ancestor)) { auto offset = downcast<Box>(*ancestor).effective_offset(); - rect.move_by(offset); + rect.translate_by(offset); } if (ancestor == &context_box) break; diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp index fbeb4723f7..523bad3dae 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.cpp +++ b/Userland/Libraries/LibWeb/Layout/Box.cpp @@ -154,7 +154,7 @@ const Gfx::FloatRect Box::absolute_rect() const { Gfx::FloatRect rect { effective_offset(), size() }; for (auto* block = containing_block(); block; block = block->containing_block()) { - rect.move_by(block->effective_offset()); + rect.translate_by(block->effective_offset()); } return rect; } diff --git a/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp b/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp index af5eb88344..614f4bcada 100644 --- a/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp @@ -49,7 +49,7 @@ void ButtonBox::paint(PaintContext& context, PaintPhase phase) auto text_rect = enclosing_int_rect(absolute_rect()); if (m_being_pressed) - text_rect.move_by(1, 1); + text_rect.translate_by(1, 1); context.painter().draw_text(text_rect, dom_node().value(), font(), Gfx::TextAlignment::Center, context.palette().button_text()); } } diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp index bf1439b91d..092aa61d37 100644 --- a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp @@ -60,7 +60,7 @@ void FrameBox::paint(PaintContext& context, PaintPhase phase) if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) { if (dom_node().content_frame()->is_focused_frame()) { - context.painter().draw_rect(absolute_rect().to<int>(), Color::Cyan); + context.painter().draw_rect(absolute_rect().to_type<int>(), Color::Cyan); } } } diff --git a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp index 1cd544847c..c358c08d66 100644 --- a/Userland/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/ImageBox.cpp @@ -110,7 +110,7 @@ bool ImageBox::renders_as_alt_text() const void ImageBox::frame_did_set_viewport_rect(const Gfx::IntRect& viewport_rect) { - m_image_loader.set_visible_in_viewport(viewport_rect.to<float>().intersects(absolute_rect())); + m_image_loader.set_visible_in_viewport(viewport_rect.to_type<float>().intersects(absolute_rect())); } } diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index 5790643d37..535541a97a 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -154,7 +154,7 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode) // Shift subsequent sibling fragments to the right to adjust for change in width. for (size_t j = i + 1; j < line_box.fragments().size(); ++j) { auto offset = line_box.fragments()[j].offset(); - offset.move_by(diff, 0); + offset.translate_by(diff, 0); line_box.fragments()[j].set_offset(offset); } } diff --git a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp index b039148155..856e5849a0 100644 --- a/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp +++ b/Userland/Libraries/LibWeb/Layout/LineBoxFragment.cpp @@ -48,7 +48,7 @@ const Gfx::FloatRect LineBoxFragment::absolute_rect() const { Gfx::FloatRect rect { {}, size() }; rect.set_location(m_layout_node.containing_block()->absolute_position()); - rect.move_by(offset()); + rect.translate_by(offset()); return rect; } diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 51b5b82601..c51945b225 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -319,7 +319,7 @@ bool Node::handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned if (!containing_block->is_scrollable()) return false; auto new_offset = containing_block->scroll_offset(); - new_offset.move_by(0, wheel_delta); + new_offset.translate_by(0, wheel_delta); containing_block->set_scroll_offset(new_offset); return true; } |