From bff863d6d9c56fe58e77d6868a9ebae95947c910 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Tue, 31 Mar 2026 09:33:08 +0200 Subject: [PATCH] LibGfx+LibWeb: Remove unused code from Gfx::Point/Rect/Size No functional changes. --- Libraries/LibGfx/BitmapSequence.h | 1 + Libraries/LibGfx/ImageFormats/JPEGWriter.cpp | 1 + Libraries/LibGfx/PaintStyle.h | 1 + Libraries/LibGfx/Point.h | 10 --- Libraries/LibGfx/Rect.h | 86 ------------------- Libraries/LibGfx/Size.h | 9 -- Libraries/LibWeb/CSS/VisualViewport.h | 1 + .../Painting/DisplayListRecordingContext.h | 1 + Libraries/LibWeb/Painting/ScrollState.cpp | 1 + 9 files changed, 6 insertions(+), 105 deletions(-) diff --git a/Libraries/LibGfx/BitmapSequence.h b/Libraries/LibGfx/BitmapSequence.h index 8f4f8f6580..8a1d8fedd3 100644 --- a/Libraries/LibGfx/BitmapSequence.h +++ b/Libraries/LibGfx/BitmapSequence.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include #include diff --git a/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp b/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp index 1cadaf376b..80e8530f10 100644 --- a/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp +++ b/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibGfx/PaintStyle.h b/Libraries/LibGfx/PaintStyle.h index d39bbc40aa..02f2320550 100644 --- a/Libraries/LibGfx/PaintStyle.h +++ b/Libraries/LibGfx/PaintStyle.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibGfx/Point.h b/Libraries/LibGfx/Point.h index 90000a10be..ed0223b0dd 100644 --- a/Libraries/LibGfx/Point.h +++ b/Libraries/LibGfx/Point.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -68,8 +67,6 @@ public: ALWAYS_INLINE void scale_by(T dboth) { scale_by(dboth, dboth); } ALWAYS_INLINE void scale_by(Point const& delta) { scale_by(delta.x(), delta.y()); } - void transform_by(AffineTransform const& transform) { *this = transform.map(*this); } - [[nodiscard]] Point translated(Point const& delta) const { Point point = *this; @@ -112,13 +109,6 @@ public: return point; } - [[nodiscard]] Point transformed(AffineTransform const& transform) const - { - Point point = *this; - point.transform_by(transform); - return point; - } - void constrain(Rect const&); [[nodiscard]] Point constrained(Rect const& rect) const { diff --git a/Libraries/LibGfx/Rect.h b/Libraries/LibGfx/Rect.h index bb2b6fe3bb..70ef5d6db6 100644 --- a/Libraries/LibGfx/Rect.h +++ b/Libraries/LibGfx/Rect.h @@ -9,12 +9,9 @@ #pragma once #include -#include -#include #include #include #include -#include #include namespace Gfx { @@ -84,8 +81,6 @@ public: ALWAYS_INLINE void scale_by(T dboth) { scale_by(dboth, dboth); } ALWAYS_INLINE void scale_by(Point const& delta) { scale_by(delta.x(), delta.y()); } - void transform_by(AffineTransform const& transform) { *this = transform.map(*this); } - [[nodiscard]] Point center() const { return { x() + width() / 2, y() + height() / 2 }; @@ -197,13 +192,6 @@ public: return rect; } - [[nodiscard]] Rect transformed(AffineTransform const& transform) const - { - Rect rect = *this; - rect.transform_by(transform); - return rect; - } - [[nodiscard]] Rect shrunken(T w, T h) const { Rect rect = *this; @@ -462,11 +450,6 @@ public: set_bottom(b); } - [[nodiscard]] static Rect centered_on(Point const& center, Size const& size) - { - return { { center.x() - size.width() / 2, center.y() - size.height() / 2 }, size }; - } - [[nodiscard]] static Rect from_two_points(Point const& a, Point const& b) { return { min(a.x(), b.x()), min(a.y(), b.y()), AK::abs(a.x() - b.x()), AK::abs(a.y() - b.y()) }; @@ -484,29 +467,6 @@ public: return intersection(*this, other); } - template - [[nodiscard]] Gfx::Rect interpolated_to(Gfx::Rect const& to, float factor) const - { - VERIFY(factor >= 0.f); - VERIFY(factor <= 1.f); - if (factor == 0.f) - return *this; - if (factor == 1.f) - return to; - if (this == &to) - return *this; - auto interpolated_left = round_to(mix(x(), to.x(), factor)); - auto interpolated_top = round_to(mix(y(), to.y(), factor)); - auto interpolated_right = round_to(mix(right(), to.right(), factor)); - auto interpolated_bottom = round_to(mix(bottom(), to.bottom(), factor)); - return { interpolated_left, interpolated_top, interpolated_right - interpolated_left, interpolated_bottom - interpolated_top }; - } - - [[nodiscard]] static Rect centered_at(Point const& point, Size const& size) - { - return { { point.x() - size.width() / 2, point.y() - size.height() / 2 }, size }; - } - void unite(Rect const& other) { if (is_empty()) { @@ -547,52 +507,6 @@ public: [[nodiscard]] Point bottom_left() const { return { left(), bottom() }; } [[nodiscard]] Point bottom_right() const { return { right(), bottom() }; } - void align_within(Rect const& other, TextAlignment alignment) - { - switch (alignment) { - case TextAlignment::Center: - center_within(other); - return; - case TextAlignment::TopCenter: - center_horizontally_within(other); - set_y(other.y()); - return; - case TextAlignment::TopLeft: - set_location(other.location()); - return; - case TextAlignment::TopRight: - set_x(other.right() - width()); - set_y(other.y()); - return; - case TextAlignment::CenterLeft: - set_x(other.x()); - center_vertically_within(other); - return; - case TextAlignment::CenterRight: - set_x(other.right() - width()); - center_vertically_within(other); - return; - case TextAlignment::BottomCenter: - center_horizontally_within(other); - set_y(other.bottom() - height()); - return; - case TextAlignment::BottomLeft: - set_x(other.x()); - set_y(other.bottom() - height()); - return; - case TextAlignment::BottomRight: - set_x(other.right() - width()); - set_y(other.bottom() - height()); - return; - } - } - - void center_within(Rect const& other) - { - center_horizontally_within(other); - center_vertically_within(other); - } - [[nodiscard]] Rect centered_within(Rect const& other) const { Rect rect { *this }; diff --git a/Libraries/LibGfx/Size.h b/Libraries/LibGfx/Size.h index b6ef30b821..324c4e1f24 100644 --- a/Libraries/LibGfx/Size.h +++ b/Libraries/LibGfx/Size.h @@ -53,8 +53,6 @@ public: m_height *= dy; } - constexpr void transform_by(AffineTransform const& transform) { *this = transform.map(*this); } - ALWAYS_INLINE constexpr void scale_by(T dboth) { scale_by(dboth, dboth); } ALWAYS_INLINE constexpr void scale_by(Point const& s) { scale_by(s.x(), s.y()); } @@ -79,13 +77,6 @@ public: return size; } - [[nodiscard]] constexpr Size transformed_by(AffineTransform const& transform) const - { - Size size = *this; - size.transform_by(transform); - return size; - } - [[nodiscard]] constexpr float aspect_ratio() const { VERIFY(height() != 0); diff --git a/Libraries/LibWeb/CSS/VisualViewport.h b/Libraries/LibWeb/CSS/VisualViewport.h index 3f3c6352e3..3936a0d686 100644 --- a/Libraries/LibWeb/CSS/VisualViewport.h +++ b/Libraries/LibWeb/CSS/VisualViewport.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include diff --git a/Libraries/LibWeb/Painting/DisplayListRecordingContext.h b/Libraries/LibWeb/Painting/DisplayListRecordingContext.h index cdfd760a57..345ec14905 100644 --- a/Libraries/LibWeb/Painting/DisplayListRecordingContext.h +++ b/Libraries/LibWeb/Painting/DisplayListRecordingContext.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include diff --git a/Libraries/LibWeb/Painting/ScrollState.cpp b/Libraries/LibWeb/Painting/ScrollState.cpp index ad715c0746..f0b82ee918 100644 --- a/Libraries/LibWeb/Painting/ScrollState.cpp +++ b/Libraries/LibWeb/Painting/ScrollState.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include namespace Web::Painting {