From 0219eb2ef9e4b25389d4ab3f6be6c43fda922792 Mon Sep 17 00:00:00 2001 From: Callum Law Date: Mon, 30 Mar 2026 12:21:07 +1300 Subject: [PATCH] LibWeb: Remove `FooOrCalculated` classes These are unused since we now store values as `StyleValue`s before used-value time, and as their resolved type (e.g. CSSPixels) after --- Documentation/CSSProperties.md | 3 +- Libraries/LibWeb/CMakeLists.txt | 1 - Libraries/LibWeb/CSS/CalculatedOr.cpp | 137 ---------- Libraries/LibWeb/CSS/CalculatedOr.h | 236 ------------------ Libraries/LibWeb/CSS/ComputedValues.h | 1 - Libraries/LibWeb/CSS/EasingFunction.cpp | 1 + Libraries/LibWeb/CSS/GridTrackPlacement.cpp | 1 + Libraries/LibWeb/CSS/GridTrackPlacement.h | 3 +- Libraries/LibWeb/CSS/MediaQuery.h | 1 - Libraries/LibWeb/CSS/Parser/MediaParsing.cpp | 1 - Libraries/LibWeb/CSS/Parser/Parser.h | 8 - Libraries/LibWeb/CSS/Parser/ValueParsing.cpp | 95 ------- .../CSS/StyleValues/ColorMixStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/CursorStyleValue.h | 1 - .../LibWeb/CSS/StyleValues/EasingStyleValue.h | 1 - Libraries/LibWeb/Forward.h | 11 +- Libraries/LibWeb/HTML/SourceSet.h | 3 +- 17 files changed, 9 insertions(+), 497 deletions(-) delete mode 100644 Libraries/LibWeb/CSS/CalculatedOr.cpp delete mode 100644 Libraries/LibWeb/CSS/CalculatedOr.h diff --git a/Documentation/CSSProperties.md b/Documentation/CSSProperties.md index 0d98ebd449..7304229409 100644 --- a/Documentation/CSSProperties.md +++ b/Documentation/CSSProperties.md @@ -33,8 +33,7 @@ After parsing and style computation, longhand properties are stored as `StyleVal `ComputedProperties`. Any shorthands have been expanded out, and so we do not need to store them directly. These longhands then need to be converted to a more usable form. To do this, add a getter to `ComputedProperties` with -the same name as the property. It should return a type that holds the value in a compact form. Be aware that anything -involving numbers or dimensions may be a calculation, so store it in one of the `FooOrCalculated` types. +the same name as the property. It should return a type that holds the value in a compact form. Then, `CSS/ComputedValues.h` contains three classes that are relevant: - `ComputedValues` holds the computed value of each property, in a flat format. Depending on whether the property is diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 9d219d2975..940e04aa39 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -100,7 +100,6 @@ set(SOURCES CSS/Angle.cpp CSS/AnimationEvent.cpp CSS/BooleanExpression.cpp - CSS/CalculatedOr.cpp CSS/CascadedProperties.cpp CSS/Clip.cpp CSS/ComputedProperties.cpp diff --git a/Libraries/LibWeb/CSS/CalculatedOr.cpp b/Libraries/LibWeb/CSS/CalculatedOr.cpp deleted file mode 100644 index 375a1af840..0000000000 --- a/Libraries/LibWeb/CSS/CalculatedOr.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2023-2025, Sam Atkins - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include "CalculatedOr.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Web::CSS { - -Optional AngleOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_angle(context); -} - -NonnullRefPtr AngleOrCalculated::create_style_value() const -{ - return AngleStyleValue::create(value()); -} - -Optional FlexOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_flex(context); -} - -NonnullRefPtr FlexOrCalculated::create_style_value() const -{ - return FlexStyleValue::create(value()); -} - -Optional FrequencyOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_frequency(context); -} - -NonnullRefPtr FrequencyOrCalculated::create_style_value() const -{ - return FrequencyStyleValue::create(value()); -} - -Optional IntegerOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_integer(context); -} - -NonnullRefPtr IntegerOrCalculated::create_style_value() const -{ - return IntegerStyleValue::create(value()); -} - -Optional LengthOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_length(context); -} - -NonnullRefPtr LengthOrCalculated::create_style_value() const -{ - return LengthStyleValue::create(value()); -} - -Optional LengthOrAutoOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_length(context).map([](auto&& length) { return LengthOrAuto { length }; }); -} - -NonnullRefPtr LengthOrAutoOrCalculated::create_style_value() const -{ - auto const& length_or_auto = value(); - if (length_or_auto.is_auto()) - return KeywordStyleValue::create(Keyword::Auto); - return LengthStyleValue::create(length_or_auto.length()); -} - -bool LengthOrAutoOrCalculated::is_auto() const -{ - return !is_calculated() && value().is_auto(); -} - -LengthOrCalculated LengthOrAutoOrCalculated::without_auto() const -{ - VERIFY(!is_auto()); - if (is_calculated()) - return calculated(); - return value().length(); -} - -Optional NumberOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_number(context); -} - -NonnullRefPtr NumberOrCalculated::create_style_value() const -{ - return NumberStyleValue::create(value()); -} - -Optional PercentageOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_percentage(context); -} - -NonnullRefPtr PercentageOrCalculated::create_style_value() const -{ - return PercentageStyleValue::create(value()); -} - -Optional ResolutionOrCalculated::resolve_calculated(NonnullRefPtr const& calculated, CalculationResolutionContext const& context) const -{ - return calculated->resolve_resolution(context); -} - -NonnullRefPtr ResolutionOrCalculated::create_style_value() const -{ - return ResolutionStyleValue::create(value()); -} - -Optional