diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp index afa4db52df6..1a76a738025 100644 --- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp @@ -321,8 +321,6 @@ WebIDL::ExceptionOr CSSStyleProperties::set_property(PropertyID property_i static NonnullRefPtr style_value_for_length_percentage(LengthPercentage const& length_percentage) { - if (length_percentage.is_auto()) - return KeywordStyleValue::create(Keyword::Auto); if (length_percentage.is_percentage()) return PercentageStyleValue::create(length_percentage.percentage()); if (length_percentage.is_length()) diff --git a/Libraries/LibWeb/CSS/ComputedProperties.cpp b/Libraries/LibWeb/CSS/ComputedProperties.cpp index d3c8db89e1b..b5e670f0faa 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.cpp +++ b/Libraries/LibWeb/CSS/ComputedProperties.cpp @@ -209,12 +209,8 @@ Size ComputedProperties::size_value(PropertyID id) const if (value.is_percentage()) return Size::make_percentage(value.as_percentage().percentage()); - if (value.is_length()) { - auto length = value.as_length().length(); - if (length.is_auto()) - return Size::make_auto(); - return Size::make_length(length); - } + if (value.is_length()) + return Size::make_length(value.as_length().length()); // FIXME: Support `anchor-size(..)` if (value.is_anchor_size()) @@ -378,11 +374,8 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r if (line_height.is_keyword() && line_height.to_keyword() == Keyword::Normal) return CSSPixels { round_to(font_metrics.font_size * normal_line_height_scale) }; - if (line_height.is_length()) { - auto line_height_length = line_height.as_length().length(); - if (!line_height_length.is_auto()) - return line_height_length.to_px(viewport_rect, font_metrics, root_font_metrics); - } + if (line_height.is_length()) + return line_height.as_length().length().to_px(viewport_rect, font_metrics, root_font_metrics); if (line_height.is_number()) return Length(line_height.as_number().number(), Length::Type::Em).to_px(viewport_rect, font_metrics, root_font_metrics); diff --git a/Libraries/LibWeb/CSS/GridTrackSize.cpp b/Libraries/LibWeb/CSS/GridTrackSize.cpp index 097c77b6ed8..39129aa74b5 100644 --- a/Libraries/LibWeb/CSS/GridTrackSize.cpp +++ b/Libraries/LibWeb/CSS/GridTrackSize.cpp @@ -96,9 +96,7 @@ bool GridSize::is_intrinsic(Layout::AvailableSize const& available_size) const bool GridSize::is_definite() const { return m_value.visit( - [](Size const& size) { - return (size.is_length() && !size.length().is_auto()) || size.is_percentage() || size.is_calculated(); - }, + [](Size const& size) { return size.is_length_percentage(); }, [](Flex const&) { return false; }); } diff --git a/Libraries/LibWeb/CSS/Length.cpp b/Libraries/LibWeb/CSS/Length.cpp index 9860d4c9e3d..9dd8e0a0622 100644 --- a/Libraries/LibWeb/CSS/Length.cpp +++ b/Libraries/LibWeb/CSS/Length.cpp @@ -38,11 +38,6 @@ Length::Length(double value, Type type) } Length::~Length() = default; -Length Length::make_auto() -{ - return Length(0, Type::Auto); -} - Length Length::make_px(double value) { return Length(value, Type::Px); @@ -55,11 +50,6 @@ Length Length::make_px(CSSPixels value) Length Length::percentage_of(Percentage const& percentage) const { - if (is_auto()) { - dbgln("Attempting to get percentage of an auto length, this seems wrong? But for now we just return the original length."); - return *this; - } - return Length { percentage.as_fraction() * raw_value(), m_type }; } @@ -191,11 +181,6 @@ CSSPixels Length::to_px(ResolutionContext const& context) const CSSPixels Length::to_px_slow_case(Layout::Node const& layout_node) const { - if (is_auto()) { - // FIXME: We really, really shouldn't end up here, but we do, and so frequently that - // adding a dbgln() here outputs a couple hundred lines loading `welcome.html`. - return 0; - } if (!layout_node.document().browsing_context()) return 0; @@ -223,9 +208,6 @@ CSSPixels Length::to_px_slow_case(Layout::Node const& layout_node) const String Length::to_string(SerializationMode serialization_mode) const { - if (is_auto()) - return "auto"_string; - // https://drafts.csswg.org/cssom/#serialize-a-css-value // -> // The component serialized as per followed by the unit in its canonical form as defined in its @@ -334,8 +316,6 @@ StringView Length::unit_name() const return "pc"sv; case Type::Px: return "px"sv; - case Type::Auto: - return "auto"sv; } VERIFY_NOT_REACHED(); } diff --git a/Libraries/LibWeb/CSS/Length.h b/Libraries/LibWeb/CSS/Length.h index 4423271af11..e0c535b99ae 100644 --- a/Libraries/LibWeb/CSS/Length.h +++ b/Libraries/LibWeb/CSS/Length.h @@ -68,9 +68,6 @@ public: Pt, Pc, Px, - - // FIXME: Remove auto somehow - Auto, }; struct FontMetrics { @@ -90,12 +87,10 @@ public: Length(double value, Type type); ~Length(); - static Length make_auto(); static Length make_px(double value); static Length make_px(CSSPixels value); Length percentage_of(Percentage const&) const; - bool is_auto() const { return m_type == Type::Auto; } bool is_px() const { return m_type == Type::Px; } bool is_absolute() const @@ -185,8 +180,6 @@ public: ALWAYS_INLINE CSSPixels to_px(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const { - if (is_auto()) - return 0; if (is_absolute()) return absolute_length_to_px(); if (is_font_relative()) @@ -254,11 +247,8 @@ private: class LengthOrAuto { public: LengthOrAuto(Length length) + : m_length(move(length)) { - if (length.is_auto()) - m_length = {}; - else - m_length = move(length); } static LengthOrAuto make_auto() { return LengthOrAuto { OptionalNone {} }; } diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index 31d8ae66020..2c897c13488 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -3173,7 +3173,6 @@ RefPtr Parser::parse_fit_content_value(TokenStream Parser::parse_fit_content_value(TokenStreamis_auto()) - return FitContentStyleValue::create(); return FitContentStyleValue::create(maybe_length.release_value()); } diff --git a/Libraries/LibWeb/CSS/PercentageOr.h b/Libraries/LibWeb/CSS/PercentageOr.h index 419c9344878..5b09a90f9a8 100644 --- a/Libraries/LibWeb/CSS/PercentageOr.h +++ b/Libraries/LibWeb/CSS/PercentageOr.h @@ -208,8 +208,6 @@ class LengthPercentage : public PercentageOr { public: using PercentageOr::PercentageOr; - bool is_auto() const { return is_length() && length().is_auto(); } - bool is_length() const { return is_t(); } Length const& length() const { return get_t(); } }; @@ -217,19 +215,13 @@ public: class LengthPercentageOrAuto { public: LengthPercentageOrAuto(LengthPercentage length_percentage) + : m_length_percentage(move(length_percentage)) { - if (length_percentage.is_auto()) - m_length_percentage = {}; - else - m_length_percentage = move(length_percentage); } LengthPercentageOrAuto(Length length) + : m_length_percentage(move(length)) { - if (length.is_auto()) - m_length_percentage = {}; - else - m_length_percentage = move(length); } LengthPercentageOrAuto(Percentage percentage) diff --git a/Libraries/LibWeb/CSS/Size.cpp b/Libraries/LibWeb/CSS/Size.cpp index 1de91309088..4e146df6466 100644 --- a/Libraries/LibWeb/CSS/Size.cpp +++ b/Libraries/LibWeb/CSS/Size.cpp @@ -48,8 +48,6 @@ Size Size::make_calculated(NonnullRefPtr calculated) Size Size::make_length_percentage(LengthPercentage const& length_percentage) { - if (length_percentage.is_auto()) - return make_auto(); if (length_percentage.is_length()) return make_length(length_percentage.length()); if (length_percentage.is_percentage()) diff --git a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp index 338598256e4..f8a51de31e1 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp @@ -2807,9 +2807,6 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalculationResult: [](Frequency const& frequency) { return frequency.to_hertz(); }, [&context](Length const& length) { // Handle some common cases first, so we can resolve more without a context - if (length.is_auto()) - return 0.0; - if (length.is_absolute()) return length.absolute_length_to_px_without_rounding(); diff --git a/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp index 20997fcb358..d2f538dc66e 100644 --- a/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.cpp @@ -13,7 +13,6 @@ namespace Web::CSS { ValueComparingNonnullRefPtr LengthStyleValue::create(Length const& length) { - VERIFY(!length.is_auto()); if (length.is_px()) { if (length.raw_value() == 0) { static auto value = adopt_ref(*new (nothrow) LengthStyleValue(CSS::Length::make_px(0)));