mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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().
This commit is contained in:
parent
0f6dd8c62b
commit
344374588b
Notes:
sideshowbarker
2024-07-17 16:32:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/344374588b
9 changed files with 24 additions and 24 deletions
|
@ -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'),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -16,7 +16,7 @@ class Emoji;
|
|||
class Font;
|
||||
class GlyphBitmap;
|
||||
class ImageDecoder;
|
||||
struct FontMetrics;
|
||||
struct FontPixelMetrics;
|
||||
|
||||
template<typename T>
|
||||
class Line;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue