diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-28 12:03:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-30 00:57:15 +0200 |
commit | 344374588bba63e8b6b90c9357bcce698fdbf0d3 (patch) | |
tree | bb08581716656d58654649671cc401abd44f087b | |
parent | 0f6dd8c62b4df4fc4cdde288865a5c99c20093bb (diff) | |
download | serenity-344374588bba63e8b6b90c9357bcce698fdbf0d3.zip |
LibGfx: Rename FontMetrics => FontPixelMetrics
Let's make it clear in the type name that this contains pixel metrics.
Also rename Font::metrics() => Font::pixel_metrics().
-rw-r--r-- | Userland/Libraries/LibGfx/BitmapFont.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Font.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Forward.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Length.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Length.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/MediaQuery.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.h | 8 |
9 files changed, 24 insertions, 24 deletions
diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index ddcc99dc64..9da41f8cb6 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -372,9 +372,9 @@ Font const& Font::bold_variant() const return *m_bold_variant; } -FontMetrics Font::metrics() const +FontPixelMetrics Font::pixel_metrics() const { - return FontMetrics { + return FontPixelMetrics { .size = (float)presentation_size(), .x_height = (float)x_height(), .advance_of_ascii_zero = (float)glyph_width('0'), diff --git a/Userland/Libraries/LibGfx/Font.h b/Userland/Libraries/LibGfx/Font.h index 89a9fa4d02..e8e452a129 100644 --- a/Userland/Libraries/LibGfx/Font.h +++ b/Userland/Libraries/LibGfx/Font.h @@ -86,7 +86,7 @@ private: int m_ascent; }; -struct FontMetrics { +struct FontPixelMetrics { float size { 0 }; float x_height { 0 }; float advance_of_ascii_zero { 0 }; @@ -103,7 +103,7 @@ public: virtual NonnullRefPtr<Font> clone() const = 0; virtual ~Font() {}; - FontMetrics metrics() const; + FontPixelMetrics pixel_metrics() const; virtual u8 presentation_size() const = 0; virtual int pixel_size() const = 0; diff --git a/Userland/Libraries/LibGfx/Forward.h b/Userland/Libraries/LibGfx/Forward.h index 95c7e37f95..c6b78ee724 100644 --- a/Userland/Libraries/LibGfx/Forward.h +++ b/Userland/Libraries/LibGfx/Forward.h @@ -16,7 +16,7 @@ class Emoji; class Font; class GlyphBitmap; class ImageDecoder; -struct FontMetrics; +struct FontPixelMetrics; template<typename T> class Line; diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp index 42d19cca3e..237fd4d4d9 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.cpp +++ b/Userland/Libraries/LibWeb/CSS/Length.cpp @@ -67,7 +67,7 @@ Length Length::resolved(Layout::Node const& layout_node) const return *this; } -float Length::relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const +float Length::relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const { switch (m_type) { case Type::Ex: @@ -106,7 +106,7 @@ float Length::to_px(Layout::Node const& layout_node) const auto* root_element = layout_node.document().document_element(); if (!root_element || !root_element->layout_node()) return 0; - return to_px(viewport_rect, layout_node.font().metrics(), layout_node.computed_values().font_size(), root_element->layout_node()->computed_values().font_size()); + return to_px(viewport_rect, layout_node.font().pixel_metrics(), layout_node.computed_values().font_size(), root_element->layout_node()->computed_values().font_size()); } String Length::to_string() const diff --git a/Userland/Libraries/LibWeb/CSS/Length.h b/Userland/Libraries/LibWeb/CSS/Length.h index 65ebaa8128..57ae881f76 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.h +++ b/Userland/Libraries/LibWeb/CSS/Length.h @@ -79,7 +79,7 @@ public: float to_px(Layout::Node const&) const; - ALWAYS_INLINE float to_px(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const + ALWAYS_INLINE float to_px(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const { if (is_auto()) return 0; @@ -128,7 +128,7 @@ public: return !(*this == other); } - float relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const; + float relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const; private: const char* unit_name() const; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp index f004d57b19..af2c4c8f8b 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp @@ -166,7 +166,7 @@ bool MediaFeature::compare(HTML::Window const& window, MediaFeatureValue left, C Gfx::IntRect viewport_rect { 0, 0, window.inner_width(), window.inner_height() }; auto const& initial_font = window.associated_document().style_computer().initial_font(); - Gfx::FontMetrics const& initial_font_metrics = initial_font.metrics(); + Gfx::FontPixelMetrics const& initial_font_metrics = initial_font.pixel_metrics(); float initial_font_size = initial_font.presentation_size(); left_px = left.length().to_px(viewport_rect, initial_font_metrics, initial_font_size, initial_font_size); diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 7728f611d7..c7fd6898cb 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -776,7 +776,7 @@ float StyleComputer::root_element_font_size() const if (!maybe_root_value.has_value()) return default_root_element_font_size; - return maybe_root_value.value()->to_length().to_px(viewport_rect(), computed_root_style->computed_font().metrics(), default_root_element_font_size, default_root_element_font_size); + return maybe_root_value.value()->to_length().to_px(viewport_rect(), computed_root_style->computed_font().pixel_metrics(), default_root_element_font_size, default_root_element_font_size); } void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* element, Optional<CSS::Selector::PseudoElement> pseudo_element) const @@ -858,11 +858,11 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele } else { float root_font_size = root_element_font_size(); - Gfx::FontMetrics font_metrics; + Gfx::FontPixelMetrics font_metrics; if (parent_element && parent_element->computed_css_values()) - font_metrics = parent_element->computed_css_values()->computed_font().metrics(); + font_metrics = parent_element->computed_css_values()->computed_font().pixel_metrics(); else - font_metrics = Gfx::FontDatabase::default_font().metrics(); + font_metrics = Gfx::FontDatabase::default_font().pixel_metrics(); auto parent_font_size = [&]() -> float { if (!parent_element || !parent_element->computed_css_values()) @@ -1003,7 +1003,7 @@ Gfx::Font const& StyleComputer::initial_font() const void StyleComputer::absolutize_values(StyleProperties& style, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const { - auto font_metrics = style.computed_font().metrics(); + auto font_metrics = style.computed_font().pixel_metrics(); float root_font_size = root_element_font_size(); float font_size = style.property(CSS::PropertyID::FontSize).value()->to_length().to_px(viewport_rect(), font_metrics, root_font_size, root_font_size); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index a10ffe9406..92c763ffe7 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -1423,7 +1423,7 @@ NonnullRefPtr<LengthStyleValue> LengthStyleValue::create(Length const& length) return adopt_ref(*new LengthStyleValue(length)); } -static Optional<CSS::Length> absolutized_length(CSS::Length const& length, Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) +static Optional<CSS::Length> absolutized_length(CSS::Length const& length, Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) { if (length.is_px()) return {}; @@ -1434,19 +1434,19 @@ static Optional<CSS::Length> absolutized_length(CSS::Length const& length, Gfx:: return {}; } -NonnullRefPtr<StyleValue> StyleValue::absolutized(Gfx::IntRect const&, Gfx::FontMetrics const&, float, float) const +NonnullRefPtr<StyleValue> StyleValue::absolutized(Gfx::IntRect const&, Gfx::FontPixelMetrics const&, float, float) const { return *this; } -NonnullRefPtr<StyleValue> LengthStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const +NonnullRefPtr<StyleValue> LengthStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const { if (auto length = absolutized_length(m_length, viewport_rect, font_metrics, font_size, root_font_size); length.has_value()) return LengthStyleValue::create(length.release_value()); return *this; } -NonnullRefPtr<StyleValue> ShadowStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const +NonnullRefPtr<StyleValue> ShadowStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const { auto absolutized_offset_x = absolutized_length(m_offset_x, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_offset_x); auto absolutized_offset_y = absolutized_length(m_offset_y, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_offset_y); @@ -1455,7 +1455,7 @@ NonnullRefPtr<StyleValue> ShadowStyleValue::absolutized(Gfx::IntRect const& view return ShadowStyleValue::create(m_color, absolutized_offset_x, absolutized_offset_y, absolutized_blur_radius, absolutized_spread_distance, m_placement); } -NonnullRefPtr<StyleValue> BorderRadiusStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const +NonnullRefPtr<StyleValue> BorderRadiusStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const { if (m_horizontal_radius.is_percentage() && m_vertical_radius.is_percentage()) return *this; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 0d0f4300e4..1a8c69241c 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -492,7 +492,7 @@ public: virtual bool has_number() const { return false; } virtual bool has_integer() const { return false; } - virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const; + virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const; virtual Color to_color(Layout::NodeWithStyle const&) const { return {}; } virtual CSS::ValueID to_identifier() const { return ValueID::Invalid; } @@ -733,7 +733,7 @@ private: m_is_elliptical = (m_horizontal_radius != m_vertical_radius); } - virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const override; + virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const override; bool m_is_elliptical; LengthPercentage m_horizontal_radius; @@ -1236,7 +1236,7 @@ public: virtual String to_string() const override { return m_length.to_string(); } virtual Length to_length() const override { return m_length; } virtual ValueID to_identifier() const override { return has_auto() ? ValueID::Auto : ValueID::Invalid; } - virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const override; + virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const override; virtual bool equals(StyleValue const& other) const override { @@ -1500,7 +1500,7 @@ private: { } - virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const override; + virtual NonnullRefPtr<StyleValue> absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, float font_size, float root_font_size) const override; Color m_color; Length m_offset_x; |