mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibWeb: Replace all px Length creation with Length::make_px(CSSPixels)
This commit is contained in:
parent
13b1952929
commit
7d40e3eb0d
5 changed files with 4 additions and 16 deletions
|
@ -29,11 +29,6 @@ Length::Length(float value, Type type)
|
||||||
, m_value(value)
|
, m_value(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Length::Length(CSSPixels value, Type type)
|
|
||||||
: m_type(type)
|
|
||||||
, m_value(value.value())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Length::~Length() = default;
|
Length::~Length() = default;
|
||||||
|
|
||||||
Length Length::make_auto()
|
Length Length::make_auto()
|
||||||
|
@ -41,11 +36,6 @@ Length Length::make_auto()
|
||||||
return Length(0, Type::Auto);
|
return Length(0, Type::Auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
Length Length::make_px(float value)
|
|
||||||
{
|
|
||||||
return Length(value, Type::Px);
|
|
||||||
}
|
|
||||||
|
|
||||||
Length Length::make_px(CSSPixels value)
|
Length Length::make_px(CSSPixels value)
|
||||||
{
|
{
|
||||||
return Length(value.value(), Type::Px);
|
return Length(value.value(), Type::Px);
|
||||||
|
|
|
@ -41,11 +41,9 @@ public:
|
||||||
// this file already. To break the cyclic dependency, we must move all method definitions out.
|
// this file already. To break the cyclic dependency, we must move all method definitions out.
|
||||||
Length(int value, Type type);
|
Length(int value, Type type);
|
||||||
Length(float value, Type type);
|
Length(float value, Type type);
|
||||||
Length(CSSPixels value, Type type);
|
|
||||||
~Length();
|
~Length();
|
||||||
|
|
||||||
static Length make_auto();
|
static Length make_auto();
|
||||||
static Length make_px(float value);
|
|
||||||
static Length make_px(CSSPixels value);
|
static Length make_px(CSSPixels value);
|
||||||
static Length make_calculated(NonnullRefPtr<CalculatedStyleValue>);
|
static Length make_calculated(NonnullRefPtr<CalculatedStyleValue>);
|
||||||
Length percentage_of(Percentage const&) const;
|
Length percentage_of(Percentage const&) const;
|
||||||
|
|
|
@ -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.
|
// 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 (value->has_number() && value->to_number() == 0) {
|
||||||
if (flex_grow && flex_shrink && !flex_basis) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1508,7 +1508,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool has_length() const override { return to_number() == 0; }
|
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 bool has_number() const override { return true; }
|
||||||
virtual float to_number() const override
|
virtual float to_number() const override
|
||||||
|
|
|
@ -72,8 +72,8 @@ Optional<float> SVGGraphicsElement::stroke_width() const
|
||||||
float viewport_height = 0;
|
float viewport_height = 0;
|
||||||
if (auto* svg_svg_element = first_ancestor_of_type<SVGSVGElement>()) {
|
if (auto* svg_svg_element = first_ancestor_of_type<SVGSVGElement>()) {
|
||||||
if (auto* svg_svg_layout_node = svg_svg_element->layout_node()) {
|
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_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, { 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, 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);
|
auto scaled_viewport_size = CSS::Length::make_px((viewport_width + viewport_height) * 0.5f);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue