1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize

This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much
better visual clue about what type of metric is being used.
This commit is contained in:
Andreas Kling 2020-06-10 10:57:59 +02:00
parent 656b01eb0f
commit 116cf92156
212 changed files with 1144 additions and 1144 deletions

View file

@ -201,7 +201,7 @@ void CanvasRenderingContext2D::put_image_data(const ImageData& image_data, float
if (!painter)
return;
painter->blit(Gfx::Point(x, y), image_data.bitmap(), image_data.bitmap().rect());
painter->blit(Gfx::IntPoint(x, y), image_data.bitmap(), image_data.bitmap().rect());
did_draw(Gfx::FloatRect(x, y, image_data.width(), image_data.height()));
}

View file

@ -82,7 +82,7 @@ CanvasRenderingContext2D* HTMLCanvasElement::get_context(String type)
return m_context;
}
static Gfx::Size bitmap_size_for_canvas(const HTMLCanvasElement& canvas)
static Gfx::IntSize bitmap_size_for_canvas(const HTMLCanvasElement& canvas)
{
int width = canvas.requested_width();
int height = canvas.requested_height();

View file

@ -47,7 +47,7 @@ RefPtr<ImageData> ImageData::create_with_size(JS::GlobalObject& global_object, i
auto data_handle = JS::make_handle(data);
auto bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA32, Gfx::Size(width, height), width * sizeof(u32), (u32*)data->data());
auto bitmap = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA32, Gfx::IntSize(width, height), width * sizeof(u32), (u32*)data->data());
if (!bitmap)
return nullptr;
return adopt(*new ImageData(bitmap.release_nonnull(), move(data_handle)));

View file

@ -38,7 +38,7 @@
namespace Web {
static Gfx::Point compute_mouse_event_offset(const Gfx::Point& position, const LayoutNode& layout_node)
static Gfx::IntPoint compute_mouse_event_offset(const Gfx::IntPoint& position, const LayoutNode& layout_node)
{
auto top_left_of_layout_node = layout_node.box_type_agnostic_position();
return {
@ -70,7 +70,7 @@ LayoutDocument* EventHandler::layout_root()
return const_cast<LayoutDocument*>(m_frame.document()->layout_node());
}
bool EventHandler::handle_mouseup(const Gfx::Point& position, unsigned button, unsigned modifiers)
bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
{
auto* layout_root_ptr = this->layout_root();
if (!layout_root_ptr)
@ -98,7 +98,7 @@ bool EventHandler::handle_mouseup(const Gfx::Point& position, unsigned button, u
return handled_event;
}
bool EventHandler::handle_mousedown(const Gfx::Point& position, unsigned button, unsigned modifiers)
bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
{
auto* layout_root_ptr = this->layout_root();
if (!layout_root_ptr)
@ -154,7 +154,7 @@ bool EventHandler::handle_mousedown(const Gfx::Point& position, unsigned button,
return true;
}
bool EventHandler::handle_mousemove(const Gfx::Point& position, unsigned buttons, unsigned modifiers)
bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers)
{
auto* layout_root_ptr = this->layout_root();
if (!layout_root_ptr)

View file

@ -40,9 +40,9 @@ public:
explicit EventHandler(Badge<Frame>, Frame&);
~EventHandler();
bool handle_mouseup(const Gfx::Point&, unsigned button, unsigned modifiers);
bool handle_mousedown(const Gfx::Point&, unsigned button, unsigned modifiers);
bool handle_mousemove(const Gfx::Point&, unsigned buttons, unsigned modifiers);
bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers);
private:
LayoutDocument* layout_root();

View file

@ -69,7 +69,7 @@ void Frame::set_document(Document* document)
page().client().page_did_set_document_in_main_frame(m_document);
}
void Frame::set_size(const Gfx::Size& size)
void Frame::set_size(const Gfx::IntSize& size)
{
if (m_size == size)
return;
@ -78,7 +78,7 @@ void Frame::set_size(const Gfx::Size& size)
m_document->layout();
}
void Frame::set_viewport_rect(const Gfx::Rect& rect)
void Frame::set_viewport_rect(const Gfx::IntRect& rect)
{
if (m_viewport_rect == rect)
return;
@ -88,7 +88,7 @@ void Frame::set_viewport_rect(const Gfx::Rect& rect)
m_document->layout_node()->did_set_viewport_rect({}, rect);
}
void Frame::set_needs_display(const Gfx::Rect& rect)
void Frame::set_needs_display(const Gfx::IntRect& rect)
{
if (!m_viewport_rect.intersects(rect))
return;
@ -121,14 +121,14 @@ void Frame::scroll_to_anchor(const String& fragment)
page().client().page_did_request_scroll_to_anchor(fragment);
}
Gfx::Rect Frame::to_main_frame_rect(const Gfx::Rect& a_rect)
Gfx::IntRect Frame::to_main_frame_rect(const Gfx::IntRect& a_rect)
{
auto rect = a_rect;
rect.set_location(to_main_frame_position(a_rect.location()));
return rect;
}
Gfx::Point Frame::to_main_frame_position(const Gfx::Point& a_position)
Gfx::IntPoint Frame::to_main_frame_position(const Gfx::IntPoint& a_position)
{
auto position = a_position;
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {

View file

@ -55,13 +55,13 @@ public:
Page& page() { return m_page; }
const Page& page() const { return m_page; }
const Gfx::Size& size() const { return m_size; }
void set_size(const Gfx::Size&);
const Gfx::IntSize& size() const { return m_size; }
void set_size(const Gfx::IntSize&);
void set_needs_display(const Gfx::Rect&);
void set_needs_display(const Gfx::IntRect&);
void set_viewport_rect(const Gfx::Rect&);
Gfx::Rect viewport_rect() const { return m_viewport_rect; }
void set_viewport_rect(const Gfx::IntRect&);
Gfx::IntRect viewport_rect() const { return m_viewport_rect; }
void did_scroll(Badge<PageView>);
@ -79,8 +79,8 @@ public:
Element* host_element() { return m_host_element; }
const Element* host_element() const { return m_host_element; }
Gfx::Point to_main_frame_position(const Gfx::Point&);
Gfx::Rect to_main_frame_rect(const Gfx::Rect&);
Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&);
Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&);
private:
explicit Frame(Element& host_element, Frame& main_frame);
@ -94,8 +94,8 @@ private:
WeakPtr<Element> m_host_element;
RefPtr<Document> m_document;
Gfx::Size m_size;
Gfx::Rect m_viewport_rect;
Gfx::IntSize m_size;
Gfx::IntRect m_viewport_rect;
};
}

View file

@ -449,7 +449,7 @@ void LayoutBlock::render(RenderingContext& context)
}
}
HitTestResult LayoutBlock::hit_test(const Gfx::Point& position) const
HitTestResult LayoutBlock::hit_test(const Gfx::IntPoint& position) const
{
if (!children_are_inline())
return LayoutBox::hit_test(position);

View file

@ -51,7 +51,7 @@ public:
LineBox& ensure_last_line_box();
LineBox& add_line_box();
virtual HitTestResult hit_test(const Gfx::Point&) const override;
virtual HitTestResult hit_test(const Gfx::IntPoint&) const override;
LayoutBlock* previous_sibling() { return to<LayoutBlock>(LayoutNode::previous_sibling()); }
const LayoutBlock* previous_sibling() const { return to<LayoutBlock>(LayoutNode::previous_sibling()); }

View file

@ -240,7 +240,7 @@ void LayoutBox::render(RenderingContext& context)
context.painter().draw_rect(enclosing_int_rect(absolute_rect()), Color::Magenta);
}
HitTestResult LayoutBox::hit_test(const Gfx::Point& position) const
HitTestResult LayoutBox::hit_test(const Gfx::IntPoint& position) const
{
// FIXME: It would be nice if we could confidently skip over hit testing
// parts of the layout tree, but currently we can't just check

View file

@ -53,7 +53,7 @@ public:
float absolute_y() const { return absolute_rect().y(); }
Gfx::FloatPoint absolute_position() const { return absolute_rect().location(); }
virtual HitTestResult hit_test(const Gfx::Point& absolute_position) const override;
virtual HitTestResult hit_test(const Gfx::IntPoint& absolute_position) const override;
virtual void set_needs_display() override;
bool is_body() const;

View file

@ -66,7 +66,7 @@ void LayoutDocument::layout(LayoutMode layout_mode)
});
}
void LayoutDocument::did_set_viewport_rect(Badge<Frame>, const Gfx::Rect& a_viewport_rect)
void LayoutDocument::did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect& a_viewport_rect)
{
Gfx::FloatRect viewport_rect(a_viewport_rect.x(), a_viewport_rect.y(), a_viewport_rect.width(), a_viewport_rect.height());
for_each_in_subtree_of_type<LayoutImage>([&](auto& layout_image) {

View file

@ -43,7 +43,7 @@ public:
const LayoutRange& selection() const { return m_selection; }
LayoutRange& selection() { return m_selection; }
void did_set_viewport_rect(Badge<Frame>, const Gfx::Rect&);
void did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect&);
virtual bool is_root() const override { return true; }

View file

@ -40,7 +40,7 @@ LayoutListItemMarker::~LayoutListItemMarker()
void LayoutListItemMarker::render(RenderingContext& context)
{
Gfx::Rect bullet_rect { 0, 0, 4, 4 };
Gfx::IntRect bullet_rect { 0, 0, 4, 4 };
bullet_rect.center_within(enclosing_int_rect(absolute_rect()));
// FIXME: It would be nicer to not have to go via the parent here to get our inherited style.
auto color = parent()->style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text());

View file

@ -98,7 +98,7 @@ void LayoutNode::render(RenderingContext& context)
});
}
HitTestResult LayoutNode::hit_test(const Gfx::Point& position) const
HitTestResult LayoutNode::hit_test(const Gfx::IntPoint& position) const
{
HitTestResult result;
for_each_child([&](auto& child) {

View file

@ -94,7 +94,7 @@ class LayoutNode : public TreeNode<LayoutNode> {
public:
virtual ~LayoutNode();
virtual HitTestResult hit_test(const Gfx::Point&) const;
virtual HitTestResult hit_test(const Gfx::IntPoint&) const;
bool is_anonymous() const { return !m_node; }
const Node* node() const { return m_node; }

View file

@ -50,17 +50,17 @@ Gfx::Palette Page::palette() const
return static_cast<const PageView&>(m_client).palette();
}
bool Page::handle_mouseup(const Gfx::Point& position, unsigned button, unsigned modifiers)
bool Page::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
{
return main_frame().event_handler().handle_mouseup(position, button, modifiers);
}
bool Page::handle_mousedown(const Gfx::Point& position, unsigned button, unsigned modifiers)
bool Page::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
{
return main_frame().event_handler().handle_mousedown(position, button, modifiers);
}
bool Page::handle_mousemove(const Gfx::Point& position, unsigned buttons, unsigned modifiers)
bool Page::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers)
{
return main_frame().event_handler().handle_mousemove(position, buttons, modifiers);
}

View file

@ -54,9 +54,9 @@ public:
void load(const URL&);
bool handle_mouseup(const Gfx::Point&, unsigned button, unsigned modifiers);
bool handle_mousedown(const Gfx::Point&, unsigned button, unsigned modifiers);
bool handle_mousemove(const Gfx::Point&, unsigned buttons, unsigned modifiers);
bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
bool handle_mousedown(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
bool handle_mousemove(const Gfx::IntPoint&, unsigned buttons, unsigned modifiers);
Gfx::Palette palette() const;
@ -73,15 +73,15 @@ public:
virtual void page_did_start_loading(const URL&) { }
virtual void page_did_change_selection() { }
virtual void page_did_request_cursor_change(GUI::StandardCursor) { }
virtual void page_did_request_link_context_menu(const Gfx::Point&, [[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { }
virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, [[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { }
virtual void page_did_click_link([[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { }
virtual void page_did_middle_click_link([[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { }
virtual void page_did_enter_tooltip_area(const Gfx::Point&, const String&) { }
virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) { }
virtual void page_did_leave_tooltip_area() { }
virtual void page_did_hover_link(const URL&) { }
virtual void page_did_unhover_link() { }
virtual void page_did_request_scroll_to_anchor([[maybe_unused]] const String& fragment) { }
virtual void page_did_invalidate(const Gfx::Rect&) { }
virtual void page_did_invalidate(const Gfx::IntRect&) { }
virtual void page_did_change_favicon(const Gfx::Bitmap&) { }
};

View file

@ -97,7 +97,7 @@ void PageView::page_did_request_cursor_change(GUI::StandardCursor cursor)
window()->set_override_cursor(cursor);
}
void PageView::page_did_request_link_context_menu(const Gfx::Point& content_position, const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers)
void PageView::page_did_request_link_context_menu(const Gfx::IntPoint& content_position, const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers)
{
if (on_link_context_menu_request)
on_link_context_menu_request(href, screen_relative_rect().location().translated(to_widget_position(content_position)));
@ -115,7 +115,7 @@ void PageView::page_did_middle_click_link(const String& href, [[maybe_unused]] c
on_link_middle_click(href);
}
void PageView::page_did_enter_tooltip_area(const Gfx::Point& content_position, const String& title)
void PageView::page_did_enter_tooltip_area(const Gfx::IntPoint& content_position, const String& title)
{
GUI::Application::the().show_tooltip(title, screen_relative_rect().location().translated(to_widget_position(content_position)));
}
@ -140,7 +140,7 @@ void PageView::page_did_request_scroll_to_anchor(const String& fragment)
scroll_to_anchor(fragment);
}
void PageView::page_did_invalidate(const Gfx::Rect&)
void PageView::page_did_invalidate(const Gfx::IntRect&)
{
update();
}

View file

@ -63,7 +63,7 @@ public:
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
Function<void(const String& href, const String& target, unsigned modifiers)> on_link_click;
Function<void(const String& href, const Gfx::Point& screen_position)> on_link_context_menu_request;
Function<void(const String& href, const Gfx::IntPoint& screen_position)> on_link_context_menu_request;
Function<void(const String& href)> on_link_middle_click;
Function<void(const String&)> on_link_hover;
Function<void(const String&)> on_title_change;
@ -96,15 +96,15 @@ private:
virtual void page_did_start_loading(const URL&) override;
virtual void page_did_change_selection() override;
virtual void page_did_request_cursor_change(GUI::StandardCursor) override;
virtual void page_did_request_link_context_menu(const Gfx::Point&, const String& href, const String& target, unsigned modifiers) override;
virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const String& href, const String& target, unsigned modifiers) override;
virtual void page_did_click_link(const String& href, const String& target, unsigned modifiers) override;
virtual void page_did_middle_click_link(const String& href, const String& target, unsigned modifiers) override;
virtual void page_did_enter_tooltip_area(const Gfx::Point&, const String&) override;
virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override;
virtual void page_did_leave_tooltip_area() override;
virtual void page_did_hover_link(const URL&) override;
virtual void page_did_unhover_link() override;
virtual void page_did_request_scroll_to_anchor(const String& fragment) override;
virtual void page_did_invalidate(const Gfx::Rect&) override;
virtual void page_did_invalidate(const Gfx::IntRect&) override;
virtual void page_did_change_favicon(const Gfx::Bitmap&) override;
void layout_and_sync_size();

View file

@ -46,13 +46,13 @@ public:
bool should_show_line_box_borders() const { return m_should_show_line_box_borders; }
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
Gfx::Rect viewport_rect() const { return m_viewport_rect; }
void set_viewport_rect(const Gfx::Rect& rect) { m_viewport_rect = rect; }
Gfx::IntRect viewport_rect() const { return m_viewport_rect; }
void set_viewport_rect(const Gfx::IntRect& rect) { m_viewport_rect = rect; }
private:
GUI::Painter& m_painter;
Palette m_palette;
Gfx::Rect m_viewport_rect;
Gfx::IntRect m_viewport_rect;
bool m_should_show_line_box_borders { false };
};