1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

LibWeb: Replace all px Length creation with Length::make_px(CSSPixels)

This commit is contained in:
Sam Atkins 2022-11-08 16:58:15 +00:00 committed by Linus Groh
parent 13b1952929
commit 7d40e3eb0d
5 changed files with 4 additions and 16 deletions

View file

@ -29,11 +29,6 @@ Length::Length(float value, Type type)
, m_value(value)
{
}
Length::Length(CSSPixels value, Type type)
: m_type(type)
, m_value(value.value())
{
}
Length::~Length() = default;
Length Length::make_auto()
@ -41,11 +36,6 @@ Length Length::make_auto()
return Length(0, Type::Auto);
}
Length Length::make_px(float value)
{
return Length(value, Type::Px);
}
Length Length::make_px(CSSPixels value)
{
return Length(value.value(), Type::Px);

View file

@ -41,11 +41,9 @@ public:
// this file already. To break the cyclic dependency, we must move all method definitions out.
Length(int value, Type type);
Length(float value, Type type);
Length(CSSPixels value, Type type);
~Length();
static Length make_auto();
static Length make_px(float value);
static Length make_px(CSSPixels value);
static Length make_calculated(NonnullRefPtr<CalculatedStyleValue>);
Length percentage_of(Percentage const&) const;

View file

@ -5028,7 +5028,7 @@ RefPtr<StyleValue> Parser::parse_flex_value(Vector<ComponentValue> const& compon
// Zero is a valid value for basis, but only if grow and shrink are already specified.
if (value->has_number() && value->to_number() == 0) {
if (flex_grow && flex_shrink && !flex_basis) {
flex_basis = LengthStyleValue::create(Length(0, Length::Type::Px));
flex_basis = LengthStyleValue::create(Length::make_px(0));
continue;
}
}

View file

@ -1508,7 +1508,7 @@ public:
}
virtual bool has_length() const override { return to_number() == 0; }
virtual Length to_length() const override { return Length(0, Length::Type::Px); }
virtual Length to_length() const override { return Length::make_px(0); }
virtual bool has_number() const override { return true; }
virtual float to_number() const override

View file

@ -72,8 +72,8 @@ Optional<float> SVGGraphicsElement::stroke_width() const
float viewport_height = 0;
if (auto* svg_svg_element = first_ancestor_of_type<SVGSVGElement>()) {
if (auto* svg_svg_layout_node = svg_svg_element->layout_node()) {
viewport_width = svg_svg_layout_node->computed_values().width().resolved(*svg_svg_layout_node, { 0, CSS::Length::Type::Px }).to_px(*svg_svg_layout_node);
viewport_height = svg_svg_layout_node->computed_values().height().resolved(*svg_svg_layout_node, { 0, CSS::Length::Type::Px }).to_px(*svg_svg_layout_node);
viewport_width = svg_svg_layout_node->computed_values().width().resolved(*svg_svg_layout_node, CSS::Length::make_px(0)).to_px(*svg_svg_layout_node);
viewport_height = svg_svg_layout_node->computed_values().height().resolved(*svg_svg_layout_node, CSS::Length::make_px(0)).to_px(*svg_svg_layout_node);
}
}
auto scaled_viewport_size = CSS::Length::make_px((viewport_width + viewport_height) * 0.5f);