1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:57:46 +00:00

LibGfx: Templatize Point, Size, and Rect

This commit is contained in:
Matthew Olsson 2020-07-25 21:31:47 -07:00 committed by Andreas Kling
parent 7a1c328417
commit 335916d8db
33 changed files with 404 additions and 835 deletions

View file

@ -163,7 +163,7 @@ Gfx::IntPoint Frame::to_main_frame_position(const Gfx::IntPoint& a_position)
return {};
if (!ancestor->host_element()->layout_node())
return {};
position.move_by(ancestor->host_element()->layout_node()->box_type_agnostic_position().to_int_point());
position.move_by(ancestor->host_element()->layout_node()->box_type_agnostic_position().to_type<int>());
}
return position;
}

View file

@ -82,10 +82,10 @@ void CanvasRenderingContext2D::stroke_rect(float x, float y, float width, float
auto rect = m_transform.map(Gfx::FloatRect(x, y, width, height));
auto top_left = m_transform.map(Gfx::FloatPoint(x, y)).to_int_point();
auto top_right = m_transform.map(Gfx::FloatPoint(x + width - 1, y)).to_int_point();
auto bottom_left = m_transform.map(Gfx::FloatPoint(x, y + height - 1)).to_int_point();
auto bottom_right = m_transform.map(Gfx::FloatPoint(x + width - 1, y + height - 1)).to_int_point();
auto top_left = m_transform.map(Gfx::FloatPoint(x, y)).to_type<int>();
auto top_right = m_transform.map(Gfx::FloatPoint(x + width - 1, y)).to_type<int>();
auto bottom_left = m_transform.map(Gfx::FloatPoint(x, y + height - 1)).to_type<int>();
auto bottom_right = m_transform.map(Gfx::FloatPoint(x + width - 1, y + height - 1)).to_type<int>();
painter->draw_line(top_left, top_right, m_stroke_style, m_line_width);
painter->draw_line(top_right, bottom_right, m_stroke_style, m_line_width);

View file

@ -27,7 +27,7 @@
#pragma once
#include <AK/OwnPtr.h>
#include <LibGfx/FloatRect.h>
#include <LibGfx/Rect.h>
#include <LibWeb/Layout/LayoutNode.h>
#include <LibWeb/Painting/StackingContext.h>

View file

@ -90,7 +90,7 @@ void LayoutFrame::did_set_rect()
LayoutReplaced::did_set_rect();
ASSERT(node().hosted_frame());
node().hosted_frame()->set_size(size().to_int_size());
node().hosted_frame()->set_size(size().to_type<int>());
}
}

View file

@ -29,7 +29,6 @@
#include <AK/NonnullRefPtr.h>
#include <AK/TypeCasts.h>
#include <AK/Vector.h>
#include <LibGfx/FloatRect.h>
#include <LibGfx/Rect.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/Forward.h>

View file

@ -59,7 +59,7 @@ void LayoutWidget::did_set_rect()
void LayoutWidget::update_widget()
{
auto adjusted_widget_position = absolute_rect().location().to_int_point();
auto adjusted_widget_position = absolute_rect().location().to_type<int>();
auto& page_view = static_cast<const PageView&>(frame().page().client());
adjusted_widget_position.move_by(-page_view.horizontal_scrollbar().value(), -page_view.vertical_scrollbar().value());
widget().move_to(adjusted_widget_position);

View file

@ -27,7 +27,7 @@
#pragma once
#include <AK/Weakable.h>
#include <LibGfx/FloatRect.h>
#include <LibGfx/Rect.h>
#include <LibGfx/Forward.h>
#include <LibWeb/Forward.h>

View file

@ -161,7 +161,7 @@ String PageView::selected_text() const
void PageView::page_did_layout()
{
ASSERT(layout_root());
set_content_size(layout_root()->size().to_int_size());
set_content_size(layout_root()->size().to_type<int>());
}
void PageView::page_did_change_title(const String& title)
@ -263,14 +263,14 @@ void PageView::layout_and_sync_size()
page().main_frame().set_size(available_size());
document()->layout();
set_content_size(layout_root()->size().to_int_size());
set_content_size(layout_root()->size().to_type<int>());
// NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again
// since the scrollbars now take up some of the available space.
if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) {
page().main_frame().set_size(available_size());
document()->layout();
set_content_size(layout_root()->size().to_int_size());
set_content_size(layout_root()->size().to_type<int>());
}
page().main_frame().set_viewport_rect(viewport_rect_in_content_coordinates());

View file

@ -25,7 +25,6 @@
*/
#include <LibGfx/Painter.h>
#include <LibGfx/Path.h>
#include <LibWeb/CSS/StyleResolver.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>