diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index d20c221ea6..c8a9ffb8f7 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -41,7 +41,7 @@ struct GridAutoFlow { class InitialValues { public: static AspectRatio aspect_ratio() { return AspectRatio { true, {} }; } - static float font_size() { return 16; } + static CSSPixels font_size() { return 16; } static int font_weight() { return 400; } static CSS::FontVariant font_variant() { return CSS::FontVariant::Normal; } static CSS::Float float_() { return CSS::Float::None; } @@ -334,7 +334,7 @@ public: Vector const& transformations() const { return m_noninherited.transformations; } CSS::TransformOrigin const& transform_origin() const { return m_noninherited.transform_origin; } - float font_size() const { return m_inherited.font_size; } + CSSPixels font_size() const { return m_inherited.font_size; } int font_weight() const { return m_inherited.font_weight; } CSS::FontVariant font_variant() const { return m_inherited.font_variant; } CSS::Time transition_delay() const { return m_noninherited.transition_delay; } @@ -355,7 +355,7 @@ public: protected: struct { - float font_size { InitialValues::font_size() }; + CSSPixels font_size { InitialValues::font_size() }; int font_weight { InitialValues::font_weight() }; CSS::FontVariant font_variant { InitialValues::font_variant() }; CSS::BorderCollapse border_collapse { InitialValues::border_collapse() }; @@ -477,7 +477,7 @@ public: } void set_aspect_ratio(AspectRatio aspect_ratio) { m_noninherited.aspect_ratio = aspect_ratio; } - void set_font_size(float font_size) { m_inherited.font_size = font_size; } + void set_font_size(CSSPixels font_size) { m_inherited.font_size = font_size; } void set_font_weight(int font_weight) { m_inherited.font_weight = font_weight; } void set_font_variant(CSS::FontVariant font_variant) { m_inherited.font_variant = font_variant; } void set_border_spacing_horizontal(CSS::Length border_spacing_horizontal) { m_inherited.border_spacing_horizontal = border_spacing_horizontal; } diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp index f6c3d9418e..718bdb6dce 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.cpp +++ b/Userland/Libraries/LibWeb/CSS/Length.cpp @@ -138,8 +138,8 @@ Length::ResolutionContext Length::ResolutionContext::for_layout_node(Layout::Nod VERIFY(root_element->layout_node()); return Length::ResolutionContext { .viewport_rect = node.browsing_context().viewport_rect(), - .font_metrics = { CSSPixels::nearest_value_for(node.computed_values().font_size()), node.font().pixel_metrics(), node.line_height() }, - .root_font_metrics = { CSSPixels::nearest_value_for(root_element->layout_node()->computed_values().font_size()), root_element->layout_node()->font().pixel_metrics(), root_element->layout_node()->line_height() }, + .font_metrics = { node.computed_values().font_size(), node.font().pixel_metrics(), node.line_height() }, + .root_font_metrics = { root_element->layout_node()->computed_values().font_size(), root_element->layout_node()->font().pixel_metrics(), root_element->layout_node()->line_height() }, }; } @@ -168,12 +168,12 @@ CSSPixels Length::to_px(Layout::Node const& layout_node) const return 0; FontMetrics font_metrics { - CSSPixels::nearest_value_for(layout_node.computed_values().font_size()), + layout_node.computed_values().font_size(), layout_node.font().pixel_metrics(), layout_node.line_height() }; FontMetrics root_font_metrics { - CSSPixels::nearest_value_for(root_element->layout_node()->computed_values().font_size()), + root_element->layout_node()->computed_values().font_size(), root_element->layout_node()->font().pixel_metrics(), root_element->layout_node()->line_height() }; diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 0f19fb4c8c..919d2d07a2 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -598,7 +598,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(L case PropertyID::Float: return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().float_())); case PropertyID::FontSize: - return LengthStyleValue::create(Length::make_px(CSSPixels::nearest_value_for(layout_node.computed_values().font_size()))); + return LengthStyleValue::create(Length::make_px(layout_node.computed_values().font_size())); case PropertyID::FontVariant: { auto font_variant = layout_node.computed_values().font_variant(); switch (font_variant) { diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index bfa600c713..50f38204c4 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1712,7 +1712,7 @@ CSSPixels FormattingContext::box_baseline(Box const& box) const return box_state.content_height() + box_state.margin_box_top(); case CSS::VerticalAlign::TextTop: // TextTop: Align the top of the box with the top of the parent's content area (see 10.6.1). - return CSSPixels::nearest_value_for(box.computed_values().font_size()); + return box.computed_values().font_size(); case CSS::VerticalAlign::TextBottom: // TextTop: Align the bottom of the box with the bottom of the parent's content area (see 10.6.1). return box_state.content_height() - CSSPixels::nearest_value_for(box.containing_block()->font().pixel_metrics().descent * 2); diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 4564ea1e1e..b98873e6b4 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -321,7 +321,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) // m_font is used by Length::to_px() when resolving sizes against this layout node. // That's why it has to be set before everything else. m_font = computed_style.computed_font(); - computed_values.set_font_size(computed_style.property(CSS::PropertyID::FontSize)->as_length().length().to_px(*this).to_double()); + computed_values.set_font_size(computed_style.property(CSS::PropertyID::FontSize)->as_length().length().to_px(*this)); computed_values.set_font_weight(round_to(computed_style.property(CSS::PropertyID::FontWeight)->as_number().number())); m_line_height = computed_style.line_height(*this);