From 0e3487b9ab455a7648185995363bb3b487551d40 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 14 Aug 2024 11:10:54 +0100 Subject: [PATCH] LibWeb: Rename StyleValue -> CSSStyleValue This matches the name in the CSS Typed OM spec. https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue No behaviour changes. --- .../Browser/LibWebFromLoadingToPainting.md | 2 +- .../LibWeb/GenerateCSSPropertyID.cpp | 8 +- .../Userland/Libraries/LibWeb/CSS/BUILD.gn | 2 +- .../LibWeb/Animations/AnimationEffect.cpp | 4 +- .../LibWeb/Animations/AnimationEffect.h | 2 +- .../LibWeb/Animations/KeyframeEffect.cpp | 10 +- .../LibWeb/Animations/KeyframeEffect.h | 10 +- Userland/Libraries/LibWeb/CMakeLists.txt | 2 +- .../Libraries/LibWeb/CSS/BackdropFilter.h | 2 +- Userland/Libraries/LibWeb/CSS/CSSAnimation.h | 2 +- .../LibWeb/CSS/CSSStyleDeclaration.cpp | 2 +- .../LibWeb/CSS/CSSStyleDeclaration.h | 4 +- .../CSS/{StyleValue.cpp => CSSStyleValue.cpp} | 116 ++++---- .../CSS/{StyleValue.h => CSSStyleValue.h} | 125 ++++----- Userland/Libraries/LibWeb/CSS/CSSTransition.h | 2 +- .../Libraries/LibWeb/CSS/CalculatedOr.cpp | 18 +- Userland/Libraries/LibWeb/CSS/CalculatedOr.h | 22 +- Userland/Libraries/LibWeb/CSS/FontFace.cpp | 2 +- Userland/Libraries/LibWeb/CSS/LengthBox.h | 2 +- .../LibWeb/CSS/Parser/GradientParsing.cpp | 8 +- .../Libraries/LibWeb/CSS/Parser/Helpers.cpp | 2 +- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 250 +++++++++--------- Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 144 +++++----- .../CSS/ResolvedCSSStyleDeclaration.cpp | 18 +- .../LibWeb/CSS/ResolvedCSSStyleDeclaration.h | 2 +- .../Libraries/LibWeb/CSS/StyleComputer.cpp | 98 +++---- Userland/Libraries/LibWeb/CSS/StyleComputer.h | 10 +- .../LibWeb/CSS/StyleInvalidation.cpp | 2 +- .../Libraries/LibWeb/CSS/StyleInvalidation.h | 2 +- .../Libraries/LibWeb/CSS/StyleProperties.cpp | 16 +- .../Libraries/LibWeb/CSS/StyleProperties.h | 18 +- .../Libraries/LibWeb/CSS/StyleProperty.cpp | 2 +- Userland/Libraries/LibWeb/CSS/StyleProperty.h | 2 +- .../CSS/StyleValues/AbstractImageStyleValue.h | 8 +- .../LibWeb/CSS/StyleValues/AngleStyleValue.h | 2 +- .../StyleValues/BackgroundRepeatStyleValue.h | 2 +- .../StyleValues/BackgroundSizeStyleValue.h | 2 +- .../CSS/StyleValues/BasicShapeStyleValue.h | 2 +- .../StyleValues/BorderRadiusStyleValue.cpp | 2 +- .../CSS/StyleValues/BorderRadiusStyleValue.h | 4 +- .../CSS/StyleValues/CalculatedStyleValue.cpp | 2 +- .../CSS/StyleValues/CalculatedStyleValue.h | 8 +- .../LibWeb/CSS/StyleValues/ColorStyleValue.h | 2 +- .../StyleValues/ConicGradientStyleValue.cpp | 2 +- .../CSS/StyleValues/ConicGradientStyleValue.h | 2 +- .../CSS/StyleValues/ContentStyleValue.h | 2 +- .../CounterDefinitionsStyleValue.h | 4 +- .../CSS/StyleValues/CounterStyleValue.cpp | 6 +- .../CSS/StyleValues/CounterStyleValue.h | 10 +- .../CSS/StyleValues/CustomIdentStyleValue.h | 2 +- .../CSS/StyleValues/DisplayStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/EasingStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/EdgeStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/FlexStyleValue.h | 2 +- .../CSS/StyleValues/FrequencyStyleValue.h | 2 +- .../CSS/StyleValues/GridAutoFlowStyleValue.h | 2 +- .../StyleValues/GridTemplateAreaStyleValue.h | 2 +- .../GridTrackPlacementStyleValue.h | 2 +- .../StyleValues/GridTrackSizeListStyleValue.h | 2 +- .../CSS/StyleValues/IdentifierStyleValue.h | 2 +- .../CSS/StyleValues/ImageStyleValue.cpp | 2 +- .../LibWeb/CSS/StyleValues/ImageStyleValue.h | 4 +- .../CSS/StyleValues/InheritStyleValue.h | 2 +- .../CSS/StyleValues/InitialStyleValue.h | 2 +- .../CSS/StyleValues/IntegerStyleValue.h | 2 +- .../CSS/StyleValues/LengthStyleValue.cpp | 2 +- .../LibWeb/CSS/StyleValues/LengthStyleValue.h | 4 +- .../StyleValues/LinearGradientStyleValue.cpp | 2 +- .../StyleValues/LinearGradientStyleValue.h | 2 +- .../CSS/StyleValues/MathDepthStyleValue.cpp | 6 +- .../CSS/StyleValues/MathDepthStyleValue.h | 10 +- .../LibWeb/CSS/StyleValues/NumberStyleValue.h | 2 +- .../CSS/StyleValues/PercentageStyleValue.h | 2 +- .../CSS/StyleValues/PositionStyleValue.h | 2 +- .../StyleValues/RadialGradientStyleValue.cpp | 2 +- .../StyleValues/RadialGradientStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/RatioStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/RectStyleValue.h | 2 +- .../CSS/StyleValues/ResolutionStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/RevertStyleValue.h | 2 +- .../StyleValues/ScrollbarGutterStyleValue.h | 2 +- .../CSS/StyleValues/ShadowStyleValue.cpp | 2 +- .../LibWeb/CSS/StyleValues/ShadowStyleValue.h | 36 +-- .../CSS/StyleValues/ShorthandStyleValue.cpp | 6 +- .../CSS/StyleValues/ShorthandStyleValue.h | 12 +- .../LibWeb/CSS/StyleValues/StringStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/StyleValueList.h | 4 +- .../LibWeb/CSS/StyleValues/TimeStyleValue.h | 2 +- .../StyleValues/TransformationStyleValue.h | 2 +- .../CSS/StyleValues/TransitionStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/URLStyleValue.h | 2 +- .../CSS/StyleValues/UnresolvedStyleValue.cpp | 2 +- .../CSS/StyleValues/UnresolvedStyleValue.h | 8 +- .../LibWeb/CSS/StyleValues/UnsetStyleValue.h | 2 +- Userland/Libraries/LibWeb/Forward.h | 2 +- .../LibWeb/HTML/Canvas/CanvasState.h | 2 +- .../LibWeb/HTML/Parser/HTMLParser.cpp | 6 +- .../Libraries/LibWeb/HTML/Parser/HTMLParser.h | 4 +- Userland/Libraries/LibWeb/Layout/Node.cpp | 2 +- .../WebContent/WebDriverConnection.cpp | 2 +- 100 files changed, 576 insertions(+), 575 deletions(-) rename Userland/Libraries/LibWeb/CSS/{StyleValue.cpp => CSSStyleValue.cpp} (76%) rename Userland/Libraries/LibWeb/CSS/{StyleValue.h => CSSStyleValue.h} (73%) diff --git a/Documentation/Browser/LibWebFromLoadingToPainting.md b/Documentation/Browser/LibWebFromLoadingToPainting.md index 3fbdfc9b353..baea191dbec 100644 --- a/Documentation/Browser/LibWebFromLoadingToPainting.md +++ b/Documentation/Browser/LibWebFromLoadingToPainting.md @@ -80,7 +80,7 @@ The cascade origin determines the processing order for rules. The "user-agent" s Note: the user-agent style is a built-in CSS style sheet that lives in the LibWeb source code [here](https://github.com/LadybirdBrowser/ladybird/blob/master/Userland/Libraries/LibWeb/CSS/Default.css). -The end product of style computation is a fully populated StyleProperties object. It has a StyleValue for each CSS::PropertyID. In spec parlance, these are the *computed* values. (Note that these are not the same as you get from `getComputedStyle()`, that API returns the *resolved* values.) +The end product of style computation is a fully populated StyleProperties object. It has a CSSStyleValue for each CSS::PropertyID. In spec parlance, these are the *computed* values. (Note that these are not the same as you get from `getComputedStyle()`, that API returns the *resolved* values.) #### Resolving CSS custom properties ("variables") diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index ce5c1cfa32b..e3fa7e5446b 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -195,7 +195,7 @@ Optional property_id_from_string(StringView); [[nodiscard]] FlyString const& string_from_property_id(PropertyID); [[nodiscard]] FlyString const& camel_case_string_from_property_id(PropertyID); bool is_inherited_property(PropertyID); -NonnullRefPtr property_initial_value(JS::Realm&, PropertyID); +NonnullRefPtr property_initial_value(JS::Realm&, PropertyID); enum class ValueType { Angle, @@ -373,7 +373,7 @@ ErrorOr generate_implementation_file(JsonObject& properties, Core::File& f #include #include #include -#include +#include #include #include #include @@ -628,9 +628,9 @@ bool property_affects_stacking_context(PropertyID property_id) } } -NonnullRefPtr property_initial_value(JS::Realm& context_realm, PropertyID property_id) +NonnullRefPtr property_initial_value(JS::Realm& context_realm, PropertyID property_id) { - static Array, to_underlying(last_property_id) + 1> initial_values; + static Array, to_underlying(last_property_id) + 1> initial_values; if (auto initial_value = initial_values[to_underlying(property_id)]) return initial_value.release_nonnull(); diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/BUILD.gn index 780aa63e0a1..32a432fdabd 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/BUILD.gn @@ -25,6 +25,7 @@ source_set("CSS") { "CSSStyleDeclaration.cpp", "CSSStyleRule.cpp", "CSSStyleSheet.cpp", + "CSSStyleValue.cpp", "CSSSupportsRule.cpp", "CSSTransition.cpp", "CalculatedOr.cpp", @@ -63,7 +64,6 @@ source_set("CSS") { "StyleProperty.cpp", "StyleSheet.cpp", "StyleSheetList.cpp", - "StyleValue.cpp", "Supports.cpp", "SystemColor.cpp", "Time.cpp", diff --git a/Userland/Libraries/LibWeb/Animations/AnimationEffect.cpp b/Userland/Libraries/LibWeb/Animations/AnimationEffect.cpp index a4796640da5..0d0615f83b8 100644 --- a/Userland/Libraries/LibWeb/Animations/AnimationEffect.cpp +++ b/Userland/Libraries/LibWeb/Animations/AnimationEffect.cpp @@ -154,7 +154,7 @@ WebIDL::ExceptionOr AnimationEffect::update_timing(OptionalEffectTiming ti // 4. If the easing member of input exists but cannot be parsed using the production // [CSS-EASING-1], throw a TypeError and abort this procedure. - RefPtr easing_value; + RefPtr easing_value; if (timing.easing.has_value()) { easing_value = parse_easing_string(realm(), timing.easing.value()); if (!easing_value) @@ -592,7 +592,7 @@ Optional AnimationEffect::transformed_progress() const return m_timing_function.evaluate_at(directed_progress.value(), before_flag); } -RefPtr AnimationEffect::parse_easing_string(JS::Realm& realm, StringView value) +RefPtr AnimationEffect::parse_easing_string(JS::Realm& realm, StringView value) { auto parser = CSS::Parser::Parser::create(CSS::Parser::ParsingContext(realm), value); diff --git a/Userland/Libraries/LibWeb/Animations/AnimationEffect.h b/Userland/Libraries/LibWeb/Animations/AnimationEffect.h index ff370a31111..fe51fd0c530 100644 --- a/Userland/Libraries/LibWeb/Animations/AnimationEffect.h +++ b/Userland/Libraries/LibWeb/Animations/AnimationEffect.h @@ -65,7 +65,7 @@ class AnimationEffect : public Bindings::PlatformObject { JS_DECLARE_ALLOCATOR(AnimationEffect); public: - static RefPtr parse_easing_string(JS::Realm& realm, StringView value); + static RefPtr parse_easing_string(JS::Realm& realm, StringView value); EffectTiming get_timing() const; ComputedEffectTiming get_computed_timing() const; diff --git a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp index 668475f4aae..2b19378f5de 100644 --- a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -561,7 +561,7 @@ static WebIDL::ExceptionOr> process_a_keyframes_argument(JS if (!easing_value) return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Invalid animation easing value: \"{}\"", easing_string)) }; - keyframe.easing.set(NonnullRefPtr { *easing_value }); + keyframe.easing.set(NonnullRefPtr { *easing_value }); } // 9. Parse each of the values in unused easings using the CSS syntax defined for easing member of the EffectTiming @@ -843,7 +843,7 @@ WebIDL::ExceptionOr> KeyframeEffect::get_keyframes auto object = JS::Object::create(realm, realm.intrinsics().object_prototype()); TRY(object->set(vm.names.offset, keyframe.offset.has_value() ? JS::Value(keyframe.offset.value()) : JS::js_null(), ShouldThrowExceptions::Yes)); TRY(object->set(vm.names.computedOffset, JS::Value(keyframe.computed_offset.value()), ShouldThrowExceptions::Yes)); - auto easing_value = keyframe.easing.get>(); + auto easing_value = keyframe.easing.get>(); TRY(object->set(vm.names.easing, JS::PrimitiveString::create(vm, easing_value->to_string()), ShouldThrowExceptions::Yes)); if (keyframe.composite == Bindings::CompositeOperationOrAuto::Replace) { @@ -894,9 +894,9 @@ WebIDL::ExceptionOr KeyframeEffect::set_keyframes(Optionalis_unresolved() && target) property_value = CSS::Parser::Parser::resolve_unresolved_style_value(CSS::Parser::ParsingContext { target->document() }, *target, pseudo_element_type(), property_id, property_value->as_unresolved()); - CSS::StyleComputer::for_each_property_expanding_shorthands(property_id, property_value, CSS::StyleComputer::AllowUnresolved::Yes, [&](CSS::PropertyID shorthand_id, CSS::StyleValue const& shorthand_value) { + CSS::StyleComputer::for_each_property_expanding_shorthands(property_id, property_value, CSS::StyleComputer::AllowUnresolved::Yes, [&](CSS::PropertyID shorthand_id, CSS::CSSStyleValue const& shorthand_value) { m_target_properties.set(shorthand_id); - resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr { shorthand_value }); + resolved_keyframe.properties.set(shorthand_id, NonnullRefPtr { shorthand_value }); }); } @@ -927,7 +927,7 @@ void KeyframeEffect::visit_edges(Cell::Visitor& visitor) visitor.visit(m_keyframe_objects); } -static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation(HashMap> const& old_properties, HashMap> const& new_properties) +static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation(HashMap> const& old_properties, HashMap> const& new_properties) { CSS::RequiredInvalidationAfterStyleChange invalidation; auto old_and_new_properties = MUST(Bitmap::create(to_underlying(CSS::last_property_id) + 1, 0)); diff --git a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.h b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.h index 33d34262eef..a716afce74a 100644 --- a/Userland/Libraries/LibWeb/Animations/KeyframeEffect.h +++ b/Userland/Libraries/LibWeb/Animations/KeyframeEffect.h @@ -11,13 +11,13 @@ #include #include #include +#include #include #include -#include namespace Web::Animations { -using EasingValue = Variant>; +using EasingValue = Variant>; // https://www.w3.org/TR/web-animations-1/#the-keyframeeffectoptions-dictionary struct KeyframeEffectOptions : public EffectTiming { @@ -39,7 +39,7 @@ struct BasePropertyIndexedKeyframe { // https://www.w3.org/TR/web-animations-1/#dictdef-basekeyframe struct BaseKeyframe { using UnparsedProperties = HashMap; - using ParsedProperties = HashMap>; + using ParsedProperties = HashMap>; Optional offset {}; EasingValue easing { "linear"_string }; @@ -64,9 +64,9 @@ public: struct KeyFrameSet : public RefCounted { struct UseInitial { }; struct ResolvedKeyFrame { - // These StyleValue properties can be unresolved, as they may be generated from a @keyframes rule, well + // These CSSStyleValue properties can be unresolved, as they may be generated from a @keyframes rule, well // before they are applied to an element - HashMap>> properties {}; + HashMap>> properties {}; }; RedBlackTree keyframes_by_key; }; diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index f1107f71c4f..1fe1dfa3805 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -51,6 +51,7 @@ set(SOURCES CSS/CSSStyleDeclaration.cpp CSS/CSSStyleRule.cpp CSS/CSSStyleSheet.cpp + CSS/CSSStyleValue.cpp CSS/CSSSupportsRule.cpp CSS/CSSTransition.cpp CSS/Display.cpp @@ -101,7 +102,6 @@ set(SOURCES CSS/StyleProperty.cpp CSS/StyleSheet.cpp CSS/StyleSheetList.cpp - CSS/StyleValue.cpp CSS/StyleValues/AngleStyleValue.cpp CSS/StyleValues/BackgroundRepeatStyleValue.cpp CSS/StyleValues/BackgroundSizeStyleValue.cpp diff --git a/Userland/Libraries/LibWeb/CSS/BackdropFilter.h b/Userland/Libraries/LibWeb/CSS/BackdropFilter.h index 5dd1e5be8da..695cf01f19d 100644 --- a/Userland/Libraries/LibWeb/CSS/BackdropFilter.h +++ b/Userland/Libraries/LibWeb/CSS/BackdropFilter.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include namespace Web::CSS { diff --git a/Userland/Libraries/LibWeb/CSS/CSSAnimation.h b/Userland/Libraries/LibWeb/CSS/CSSAnimation.h index 638dfef555a..65e3180bf09 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSAnimation.h +++ b/Userland/Libraries/LibWeb/CSS/CSSAnimation.h @@ -7,8 +7,8 @@ #pragma once #include +#include #include -#include namespace Web::CSS { diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index 8529d76c5f3..6b314e3651b 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -200,7 +200,7 @@ void ElementInlineCSSStyleDeclaration::update_style_attribute() } // https://drafts.csswg.org/cssom/#set-a-css-declaration -bool PropertyOwningCSSStyleDeclaration::set_a_css_declaration(PropertyID property_id, NonnullRefPtr value, Important important) +bool PropertyOwningCSSStyleDeclaration::set_a_css_declaration(PropertyID property_id, NonnullRefPtr value, Important important) { // FIXME: Handle logical property groups. diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index 62be62dada8..075c277881a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include namespace Web::CSS { @@ -91,7 +91,7 @@ protected: void set_the_declarations(Vector properties, HashMap custom_properties); private: - bool set_a_css_declaration(PropertyID, NonnullRefPtr, Important); + bool set_a_css_declaration(PropertyID, NonnullRefPtr, Important); virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.cpp similarity index 76% rename from Userland/Libraries/LibWeb/CSS/StyleValue.cpp rename to Userland/Libraries/LibWeb/CSS/CSSStyleValue.cpp index 4c6fc69f72c..d9c7978420e 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -63,329 +63,329 @@ namespace Web::CSS { -StyleValue::StyleValue(Type type) +CSSStyleValue::CSSStyleValue(Type type) : m_type(type) { } -AbstractImageStyleValue const& StyleValue::as_abstract_image() const +AbstractImageStyleValue const& CSSStyleValue::as_abstract_image() const { VERIFY(is_abstract_image()); return static_cast(*this); } -AngleStyleValue const& StyleValue::as_angle() const +AngleStyleValue const& CSSStyleValue::as_angle() const { VERIFY(is_angle()); return static_cast(*this); } -BackgroundRepeatStyleValue const& StyleValue::as_background_repeat() const +BackgroundRepeatStyleValue const& CSSStyleValue::as_background_repeat() const { VERIFY(is_background_repeat()); return static_cast(*this); } -BackgroundSizeStyleValue const& StyleValue::as_background_size() const +BackgroundSizeStyleValue const& CSSStyleValue::as_background_size() const { VERIFY(is_background_size()); return static_cast(*this); } -BasicShapeStyleValue const& StyleValue::as_basic_shape() const +BasicShapeStyleValue const& CSSStyleValue::as_basic_shape() const { VERIFY(is_basic_shape()); return static_cast(*this); } -BorderRadiusStyleValue const& StyleValue::as_border_radius() const +BorderRadiusStyleValue const& CSSStyleValue::as_border_radius() const { VERIFY(is_border_radius()); return static_cast(*this); } -CalculatedStyleValue const& StyleValue::as_calculated() const +CalculatedStyleValue const& CSSStyleValue::as_calculated() const { VERIFY(is_calculated()); return static_cast(*this); } -ColorStyleValue const& StyleValue::as_color() const +ColorStyleValue const& CSSStyleValue::as_color() const { VERIFY(is_color()); return static_cast(*this); } -ConicGradientStyleValue const& StyleValue::as_conic_gradient() const +ConicGradientStyleValue const& CSSStyleValue::as_conic_gradient() const { VERIFY(is_conic_gradient()); return static_cast(*this); } -ContentStyleValue const& StyleValue::as_content() const +ContentStyleValue const& CSSStyleValue::as_content() const { VERIFY(is_content()); return static_cast(*this); } -CounterStyleValue const& StyleValue::as_counter() const +CounterStyleValue const& CSSStyleValue::as_counter() const { VERIFY(is_counter()); return static_cast(*this); } -CounterDefinitionsStyleValue const& StyleValue::as_counter_definitions() const +CounterDefinitionsStyleValue const& CSSStyleValue::as_counter_definitions() const { VERIFY(is_counter_definitions()); return static_cast(*this); } -CustomIdentStyleValue const& StyleValue::as_custom_ident() const +CustomIdentStyleValue const& CSSStyleValue::as_custom_ident() const { VERIFY(is_custom_ident()); return static_cast(*this); } -DisplayStyleValue const& StyleValue::as_display() const +DisplayStyleValue const& CSSStyleValue::as_display() const { VERIFY(is_display()); return static_cast(*this); } -EasingStyleValue const& StyleValue::as_easing() const +EasingStyleValue const& CSSStyleValue::as_easing() const { VERIFY(is_easing()); return static_cast(*this); } -EdgeStyleValue const& StyleValue::as_edge() const +EdgeStyleValue const& CSSStyleValue::as_edge() const { VERIFY(is_edge()); return static_cast(*this); } -FilterValueListStyleValue const& StyleValue::as_filter_value_list() const +FilterValueListStyleValue const& CSSStyleValue::as_filter_value_list() const { VERIFY(is_filter_value_list()); return static_cast(*this); } -FlexStyleValue const& StyleValue::as_flex() const +FlexStyleValue const& CSSStyleValue::as_flex() const { VERIFY(is_flex()); return static_cast(*this); } -FrequencyStyleValue const& StyleValue::as_frequency() const +FrequencyStyleValue const& CSSStyleValue::as_frequency() const { VERIFY(is_frequency()); return static_cast(*this); } -GridAutoFlowStyleValue const& StyleValue::as_grid_auto_flow() const +GridAutoFlowStyleValue const& CSSStyleValue::as_grid_auto_flow() const { VERIFY(is_grid_auto_flow()); return static_cast(*this); } -GridTemplateAreaStyleValue const& StyleValue::as_grid_template_area() const +GridTemplateAreaStyleValue const& CSSStyleValue::as_grid_template_area() const { VERIFY(is_grid_template_area()); return static_cast(*this); } -GridTrackPlacementStyleValue const& StyleValue::as_grid_track_placement() const +GridTrackPlacementStyleValue const& CSSStyleValue::as_grid_track_placement() const { VERIFY(is_grid_track_placement()); return static_cast(*this); } -GridTrackSizeListStyleValue const& StyleValue::as_grid_track_size_list() const +GridTrackSizeListStyleValue const& CSSStyleValue::as_grid_track_size_list() const { VERIFY(is_grid_track_size_list()); return static_cast(*this); } -IdentifierStyleValue const& StyleValue::as_identifier() const +IdentifierStyleValue const& CSSStyleValue::as_identifier() const { VERIFY(is_identifier()); return static_cast(*this); } -ImageStyleValue const& StyleValue::as_image() const +ImageStyleValue const& CSSStyleValue::as_image() const { VERIFY(is_image()); return static_cast(*this); } -InheritStyleValue const& StyleValue::as_inherit() const +InheritStyleValue const& CSSStyleValue::as_inherit() const { VERIFY(is_inherit()); return static_cast(*this); } -InitialStyleValue const& StyleValue::as_initial() const +InitialStyleValue const& CSSStyleValue::as_initial() const { VERIFY(is_initial()); return static_cast(*this); } -IntegerStyleValue const& StyleValue::as_integer() const +IntegerStyleValue const& CSSStyleValue::as_integer() const { VERIFY(is_integer()); return static_cast(*this); } -LengthStyleValue const& StyleValue::as_length() const +LengthStyleValue const& CSSStyleValue::as_length() const { VERIFY(is_length()); return static_cast(*this); } -LinearGradientStyleValue const& StyleValue::as_linear_gradient() const +LinearGradientStyleValue const& CSSStyleValue::as_linear_gradient() const { VERIFY(is_linear_gradient()); return static_cast(*this); } -MathDepthStyleValue const& StyleValue::as_math_depth() const +MathDepthStyleValue const& CSSStyleValue::as_math_depth() const { VERIFY(is_math_depth()); return static_cast(*this); } -NumberStyleValue const& StyleValue::as_number() const +NumberStyleValue const& CSSStyleValue::as_number() const { VERIFY(is_number()); return static_cast(*this); } -PercentageStyleValue const& StyleValue::as_percentage() const +PercentageStyleValue const& CSSStyleValue::as_percentage() const { VERIFY(is_percentage()); return static_cast(*this); } -PositionStyleValue const& StyleValue::as_position() const +PositionStyleValue const& CSSStyleValue::as_position() const { VERIFY(is_position()); return static_cast(*this); } -RadialGradientStyleValue const& StyleValue::as_radial_gradient() const +RadialGradientStyleValue const& CSSStyleValue::as_radial_gradient() const { VERIFY(is_radial_gradient()); return static_cast(*this); } -RatioStyleValue const& StyleValue::as_ratio() const +RatioStyleValue const& CSSStyleValue::as_ratio() const { VERIFY(is_ratio()); return static_cast(*this); } -RectStyleValue const& StyleValue::as_rect() const +RectStyleValue const& CSSStyleValue::as_rect() const { VERIFY(is_rect()); return static_cast(*this); } -ResolutionStyleValue const& StyleValue::as_resolution() const +ResolutionStyleValue const& CSSStyleValue::as_resolution() const { VERIFY(is_resolution()); return static_cast(*this); } -RevertStyleValue const& StyleValue::as_revert() const +RevertStyleValue const& CSSStyleValue::as_revert() const { VERIFY(is_revert()); return static_cast(*this); } -ScrollbarGutterStyleValue const& StyleValue::as_scrollbar_gutter() const +ScrollbarGutterStyleValue const& CSSStyleValue::as_scrollbar_gutter() const { VERIFY(is_scrollbar_gutter()); return static_cast(*this); } -ShadowStyleValue const& StyleValue::as_shadow() const +ShadowStyleValue const& CSSStyleValue::as_shadow() const { VERIFY(is_shadow()); return static_cast(*this); } -ShorthandStyleValue const& StyleValue::as_shorthand() const +ShorthandStyleValue const& CSSStyleValue::as_shorthand() const { VERIFY(is_shorthand()); return static_cast(*this); } -StringStyleValue const& StyleValue::as_string() const +StringStyleValue const& CSSStyleValue::as_string() const { VERIFY(is_string()); return static_cast(*this); } -TimeStyleValue const& StyleValue::as_time() const +TimeStyleValue const& CSSStyleValue::as_time() const { VERIFY(is_time()); return static_cast(*this); } -TransformationStyleValue const& StyleValue::as_transformation() const +TransformationStyleValue const& CSSStyleValue::as_transformation() const { VERIFY(is_transformation()); return static_cast(*this); } -TransitionStyleValue const& StyleValue::as_transition() const +TransitionStyleValue const& CSSStyleValue::as_transition() const { VERIFY(is_transition()); return static_cast(*this); } -UnresolvedStyleValue const& StyleValue::as_unresolved() const +UnresolvedStyleValue const& CSSStyleValue::as_unresolved() const { VERIFY(is_unresolved()); return static_cast(*this); } -UnsetStyleValue const& StyleValue::as_unset() const +UnsetStyleValue const& CSSStyleValue::as_unset() const { VERIFY(is_unset()); return static_cast(*this); } -URLStyleValue const& StyleValue::as_url() const +URLStyleValue const& CSSStyleValue::as_url() const { VERIFY(is_url()); return static_cast(*this); } -StyleValueList const& StyleValue::as_value_list() const +StyleValueList const& CSSStyleValue::as_value_list() const { VERIFY(is_value_list()); return static_cast(*this); } -ValueComparingNonnullRefPtr StyleValue::absolutized(CSSPixelRect const&, Length::FontMetrics const&, Length::FontMetrics const&) const +ValueComparingNonnullRefPtr CSSStyleValue::absolutized(CSSPixelRect const&, Length::FontMetrics const&, Length::FontMetrics const&) const { return *this; } -bool StyleValue::has_auto() const +bool CSSStyleValue::has_auto() const { return is_identifier() && as_identifier().id() == ValueID::Auto; } -ValueID StyleValue::to_identifier() const +ValueID CSSStyleValue::to_identifier() const { if (is_identifier()) return as_identifier().id(); return ValueID::Invalid; } -int StyleValue::to_font_weight() const +int CSSStyleValue::to_font_weight() const { if (is_identifier()) { switch (static_cast(*this).id()) { @@ -414,7 +414,7 @@ int StyleValue::to_font_weight() const return Gfx::FontWeight::Regular; } -int StyleValue::to_font_slope() const +int CSSStyleValue::to_font_slope() const { // FIXME: Implement oblique if (is_identifier()) { @@ -435,7 +435,7 @@ int StyleValue::to_font_slope() const return normal_slope; } -int StyleValue::to_font_stretch_width() const +int CSSStyleValue::to_font_stretch_width() const { int width = Gfx::FontWidth::Normal; if (is_identifier()) { diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h similarity index 73% rename from Userland/Libraries/LibWeb/CSS/StyleValue.h rename to Userland/Libraries/LibWeb/CSS/CSSStyleValue.h index 42821558faf..0e32fb3e221 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h @@ -80,11 +80,12 @@ private: using RefPtr::operator==; }; -using StyleValueVector = Vector>; +using StyleValueVector = Vector>; -class StyleValue : public RefCounted { +// https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue +class CSSStyleValue : public RefCounted { public: - virtual ~StyleValue() = default; + virtual ~CSSStyleValue() = default; enum class Type { Angle, @@ -145,203 +146,203 @@ public: return AK::first_is_one_of(type(), Type::Image, Type::LinearGradient, Type::ConicGradient, Type::RadialGradient); } AbstractImageStyleValue const& as_abstract_image() const; - AbstractImageStyleValue& as_abstract_image() { return const_cast(const_cast(*this).as_abstract_image()); } + AbstractImageStyleValue& as_abstract_image() { return const_cast(const_cast(*this).as_abstract_image()); } bool is_angle() const { return type() == Type::Angle; } AngleStyleValue const& as_angle() const; - AngleStyleValue& as_angle() { return const_cast(const_cast(*this).as_angle()); } + AngleStyleValue& as_angle() { return const_cast(const_cast(*this).as_angle()); } bool is_background_repeat() const { return type() == Type::BackgroundRepeat; } BackgroundRepeatStyleValue const& as_background_repeat() const; - BackgroundRepeatStyleValue& as_background_repeat() { return const_cast(const_cast(*this).as_background_repeat()); } + BackgroundRepeatStyleValue& as_background_repeat() { return const_cast(const_cast(*this).as_background_repeat()); } bool is_background_size() const { return type() == Type::BackgroundSize; } BackgroundSizeStyleValue const& as_background_size() const; - BackgroundSizeStyleValue& as_background_size() { return const_cast(const_cast(*this).as_background_size()); } + BackgroundSizeStyleValue& as_background_size() { return const_cast(const_cast(*this).as_background_size()); } bool is_basic_shape() const { return type() == Type::BasicShape; } BasicShapeStyleValue const& as_basic_shape() const; - BasicShapeStyleValue& as_basic_shape() { return const_cast(const_cast(*this).as_basic_shape()); } + BasicShapeStyleValue& as_basic_shape() { return const_cast(const_cast(*this).as_basic_shape()); } bool is_border_radius() const { return type() == Type::BorderRadius; } BorderRadiusStyleValue const& as_border_radius() const; - BorderRadiusStyleValue& as_border_radius() { return const_cast(const_cast(*this).as_border_radius()); } + BorderRadiusStyleValue& as_border_radius() { return const_cast(const_cast(*this).as_border_radius()); } bool is_calculated() const { return type() == Type::Calculated; } CalculatedStyleValue const& as_calculated() const; - CalculatedStyleValue& as_calculated() { return const_cast(const_cast(*this).as_calculated()); } + CalculatedStyleValue& as_calculated() { return const_cast(const_cast(*this).as_calculated()); } bool is_color() const { return type() == Type::Color; } ColorStyleValue const& as_color() const; - ColorStyleValue& as_color() { return const_cast(const_cast(*this).as_color()); } + ColorStyleValue& as_color() { return const_cast(const_cast(*this).as_color()); } bool is_conic_gradient() const { return type() == Type::ConicGradient; } ConicGradientStyleValue const& as_conic_gradient() const; - ConicGradientStyleValue& as_conic_gradient() { return const_cast(const_cast(*this).as_conic_gradient()); } + ConicGradientStyleValue& as_conic_gradient() { return const_cast(const_cast(*this).as_conic_gradient()); } bool is_content() const { return type() == Type::Content; } ContentStyleValue const& as_content() const; - ContentStyleValue& as_content() { return const_cast(const_cast(*this).as_content()); } + ContentStyleValue& as_content() { return const_cast(const_cast(*this).as_content()); } bool is_counter() const { return type() == Type::Counter; } CounterStyleValue const& as_counter() const; - CounterStyleValue& as_counter() { return const_cast(const_cast(*this).as_counter()); } + CounterStyleValue& as_counter() { return const_cast(const_cast(*this).as_counter()); } bool is_counter_definitions() const { return type() == Type::CounterDefinitions; } CounterDefinitionsStyleValue const& as_counter_definitions() const; - CounterDefinitionsStyleValue& as_counter_definitions() { return const_cast(const_cast(*this).as_counter_definitions()); } + CounterDefinitionsStyleValue& as_counter_definitions() { return const_cast(const_cast(*this).as_counter_definitions()); } bool is_custom_ident() const { return type() == Type::CustomIdent; } CustomIdentStyleValue const& as_custom_ident() const; - CustomIdentStyleValue& as_custom_ident() { return const_cast(const_cast(*this).as_custom_ident()); } + CustomIdentStyleValue& as_custom_ident() { return const_cast(const_cast(*this).as_custom_ident()); } bool is_display() const { return type() == Type::Display; } DisplayStyleValue const& as_display() const; - DisplayStyleValue& as_display() { return const_cast(const_cast(*this).as_display()); } + DisplayStyleValue& as_display() { return const_cast(const_cast(*this).as_display()); } bool is_easing() const { return type() == Type::Easing; } EasingStyleValue const& as_easing() const; - EasingStyleValue& as_easing() { return const_cast(const_cast(*this).as_easing()); } + EasingStyleValue& as_easing() { return const_cast(const_cast(*this).as_easing()); } bool is_edge() const { return type() == Type::Edge; } EdgeStyleValue const& as_edge() const; - EdgeStyleValue& as_edge() { return const_cast(const_cast(*this).as_edge()); } + EdgeStyleValue& as_edge() { return const_cast(const_cast(*this).as_edge()); } bool is_filter_value_list() const { return type() == Type::FilterValueList; } FilterValueListStyleValue const& as_filter_value_list() const; - FilterValueListStyleValue& as_filter_value_list() { return const_cast(const_cast(*this).as_filter_value_list()); } + FilterValueListStyleValue& as_filter_value_list() { return const_cast(const_cast(*this).as_filter_value_list()); } bool is_flex() const { return type() == Type::Flex; } FlexStyleValue const& as_flex() const; - FlexStyleValue& as_flex() { return const_cast(const_cast(*this).as_flex()); } + FlexStyleValue& as_flex() { return const_cast(const_cast(*this).as_flex()); } bool is_frequency() const { return type() == Type::Frequency; } FrequencyStyleValue const& as_frequency() const; - FrequencyStyleValue& as_frequency() { return const_cast(const_cast(*this).as_frequency()); } + FrequencyStyleValue& as_frequency() { return const_cast(const_cast(*this).as_frequency()); } bool is_grid_auto_flow() const { return type() == Type::GridAutoFlow; } GridAutoFlowStyleValue const& as_grid_auto_flow() const; - GridAutoFlowStyleValue& as_grid_auto_flow() { return const_cast(const_cast(*this).as_grid_auto_flow()); } + GridAutoFlowStyleValue& as_grid_auto_flow() { return const_cast(const_cast(*this).as_grid_auto_flow()); } bool is_grid_template_area() const { return type() == Type::GridTemplateArea; } GridTemplateAreaStyleValue const& as_grid_template_area() const; - GridTemplateAreaStyleValue& as_grid_template_area() { return const_cast(const_cast(*this).as_grid_template_area()); } + GridTemplateAreaStyleValue& as_grid_template_area() { return const_cast(const_cast(*this).as_grid_template_area()); } bool is_grid_track_placement() const { return type() == Type::GridTrackPlacement; } GridTrackPlacementStyleValue const& as_grid_track_placement() const; - GridTrackPlacementStyleValue& as_grid_track_placement() { return const_cast(const_cast(*this).as_grid_track_placement()); } + GridTrackPlacementStyleValue& as_grid_track_placement() { return const_cast(const_cast(*this).as_grid_track_placement()); } bool is_grid_track_size_list() const { return type() == Type::GridTrackSizeList; } GridTrackSizeListStyleValue const& as_grid_track_size_list() const; - GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast(const_cast(*this).as_grid_track_size_list()); } + GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast(const_cast(*this).as_grid_track_size_list()); } bool is_identifier() const { return type() == Type::Identifier; } IdentifierStyleValue const& as_identifier() const; - IdentifierStyleValue& as_identifier() { return const_cast(const_cast(*this).as_identifier()); } + IdentifierStyleValue& as_identifier() { return const_cast(const_cast(*this).as_identifier()); } bool is_image() const { return type() == Type::Image; } ImageStyleValue const& as_image() const; - ImageStyleValue& as_image() { return const_cast(const_cast(*this).as_image()); } + ImageStyleValue& as_image() { return const_cast(const_cast(*this).as_image()); } bool is_inherit() const { return type() == Type::Inherit; } InheritStyleValue const& as_inherit() const; - InheritStyleValue& as_inherit() { return const_cast(const_cast(*this).as_inherit()); } + InheritStyleValue& as_inherit() { return const_cast(const_cast(*this).as_inherit()); } bool is_initial() const { return type() == Type::Initial; } InitialStyleValue const& as_initial() const; - InitialStyleValue& as_initial() { return const_cast(const_cast(*this).as_initial()); } + InitialStyleValue& as_initial() { return const_cast(const_cast(*this).as_initial()); } bool is_integer() const { return type() == Type::Integer; } IntegerStyleValue const& as_integer() const; - IntegerStyleValue& as_integer() { return const_cast(const_cast(*this).as_integer()); } + IntegerStyleValue& as_integer() { return const_cast(const_cast(*this).as_integer()); } bool is_length() const { return type() == Type::Length; } LengthStyleValue const& as_length() const; - LengthStyleValue& as_length() { return const_cast(const_cast(*this).as_length()); } + LengthStyleValue& as_length() { return const_cast(const_cast(*this).as_length()); } bool is_linear_gradient() const { return type() == Type::LinearGradient; } LinearGradientStyleValue const& as_linear_gradient() const; - LinearGradientStyleValue& as_linear_gradient() { return const_cast(const_cast(*this).as_linear_gradient()); } + LinearGradientStyleValue& as_linear_gradient() { return const_cast(const_cast(*this).as_linear_gradient()); } bool is_math_depth() const { return type() == Type::MathDepth; } MathDepthStyleValue const& as_math_depth() const; - MathDepthStyleValue& as_math_depth() { return const_cast(const_cast(*this).as_math_depth()); } + MathDepthStyleValue& as_math_depth() { return const_cast(const_cast(*this).as_math_depth()); } bool is_number() const { return type() == Type::Number; } NumberStyleValue const& as_number() const; - NumberStyleValue& as_number() { return const_cast(const_cast(*this).as_number()); } + NumberStyleValue& as_number() { return const_cast(const_cast(*this).as_number()); } bool is_percentage() const { return type() == Type::Percentage; } PercentageStyleValue const& as_percentage() const; - PercentageStyleValue& as_percentage() { return const_cast(const_cast(*this).as_percentage()); } + PercentageStyleValue& as_percentage() { return const_cast(const_cast(*this).as_percentage()); } bool is_position() const { return type() == Type::Position; } PositionStyleValue const& as_position() const; - PositionStyleValue& as_position() { return const_cast(const_cast(*this).as_position()); } + PositionStyleValue& as_position() { return const_cast(const_cast(*this).as_position()); } bool is_radial_gradient() const { return type() == Type::RadialGradient; } RadialGradientStyleValue const& as_radial_gradient() const; - RadialGradientStyleValue& as_radial_gradient() { return const_cast(const_cast(*this).as_radial_gradient()); } + RadialGradientStyleValue& as_radial_gradient() { return const_cast(const_cast(*this).as_radial_gradient()); } bool is_ratio() const { return type() == Type::Ratio; } RatioStyleValue const& as_ratio() const; - RatioStyleValue& as_ratio() { return const_cast(const_cast(*this).as_ratio()); } + RatioStyleValue& as_ratio() { return const_cast(const_cast(*this).as_ratio()); } bool is_rect() const { return type() == Type::Rect; } RectStyleValue const& as_rect() const; - RectStyleValue& as_rect() { return const_cast(const_cast(*this).as_rect()); } + RectStyleValue& as_rect() { return const_cast(const_cast(*this).as_rect()); } bool is_resolution() const { return type() == Type::Resolution; } ResolutionStyleValue const& as_resolution() const; - ResolutionStyleValue& as_resolution() { return const_cast(const_cast(*this).as_resolution()); } + ResolutionStyleValue& as_resolution() { return const_cast(const_cast(*this).as_resolution()); } bool is_revert() const { return type() == Type::Revert; } RevertStyleValue const& as_revert() const; - RevertStyleValue& as_revert() { return const_cast(const_cast(*this).as_revert()); } + RevertStyleValue& as_revert() { return const_cast(const_cast(*this).as_revert()); } bool is_scrollbar_gutter() const { return type() == Type::ScrollbarGutter; } ScrollbarGutterStyleValue const& as_scrollbar_gutter() const; - ScrollbarGutterStyleValue& as_scrollbar_gutter() { return const_cast(const_cast(*this).as_scrollbar_gutter()); } + ScrollbarGutterStyleValue& as_scrollbar_gutter() { return const_cast(const_cast(*this).as_scrollbar_gutter()); } bool is_shadow() const { return type() == Type::Shadow; } ShadowStyleValue const& as_shadow() const; - ShadowStyleValue& as_shadow() { return const_cast(const_cast(*this).as_shadow()); } + ShadowStyleValue& as_shadow() { return const_cast(const_cast(*this).as_shadow()); } bool is_shorthand() const { return type() == Type::Shorthand; } ShorthandStyleValue const& as_shorthand() const; - ShorthandStyleValue& as_shorthand() { return const_cast(const_cast(*this).as_shorthand()); } + ShorthandStyleValue& as_shorthand() { return const_cast(const_cast(*this).as_shorthand()); } bool is_string() const { return type() == Type::String; } StringStyleValue const& as_string() const; - StringStyleValue& as_string() { return const_cast(const_cast(*this).as_string()); } + StringStyleValue& as_string() { return const_cast(const_cast(*this).as_string()); } bool is_time() const { return type() == Type::Time; } TimeStyleValue const& as_time() const; - TimeStyleValue& as_time() { return const_cast(const_cast(*this).as_time()); } + TimeStyleValue& as_time() { return const_cast(const_cast(*this).as_time()); } bool is_transformation() const { return type() == Type::Transformation; } TransformationStyleValue const& as_transformation() const; - TransformationStyleValue& as_transformation() { return const_cast(const_cast(*this).as_transformation()); } + TransformationStyleValue& as_transformation() { return const_cast(const_cast(*this).as_transformation()); } bool is_transition() const { return type() == Type::Transition; } TransitionStyleValue const& as_transition() const; - TransitionStyleValue& as_transition() { return const_cast(const_cast(*this).as_transition()); } + TransitionStyleValue& as_transition() { return const_cast(const_cast(*this).as_transition()); } bool is_unresolved() const { return type() == Type::Unresolved; } UnresolvedStyleValue const& as_unresolved() const; - UnresolvedStyleValue& as_unresolved() { return const_cast(const_cast(*this).as_unresolved()); } + UnresolvedStyleValue& as_unresolved() { return const_cast(const_cast(*this).as_unresolved()); } bool is_unset() const { return type() == Type::Unset; } UnsetStyleValue const& as_unset() const; - UnsetStyleValue& as_unset() { return const_cast(const_cast(*this).as_unset()); } + UnsetStyleValue& as_unset() { return const_cast(const_cast(*this).as_unset()); } bool is_url() const { return type() == Type::URL; } URLStyleValue const& as_url() const; - URLStyleValue& as_url() { return const_cast(const_cast(*this).as_url()); } + URLStyleValue& as_url() { return const_cast(const_cast(*this).as_url()); } bool is_value_list() const { return type() == Type::ValueList; } StyleValueList const& as_value_list() const; - StyleValueList& as_value_list() { return const_cast(const_cast(*this).as_value_list()); } + StyleValueList& as_value_list() { return const_cast(const_cast(*this).as_value_list()); } // https://www.w3.org/TR/css-values-4/#common-keywords // https://drafts.csswg.org/css-cascade-4/#valdef-all-revert @@ -350,7 +351,7 @@ public: bool has_auto() const; virtual bool has_color() const { return false; } - virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const; virtual Color to_color(Optional) const { return {}; } ValueID to_identifier() const; @@ -360,25 +361,25 @@ public: [[nodiscard]] int to_font_slope() const; [[nodiscard]] int to_font_stretch_width() const; - virtual bool equals(StyleValue const& other) const = 0; + virtual bool equals(CSSStyleValue const& other) const = 0; - bool operator==(StyleValue const& other) const + bool operator==(CSSStyleValue const& other) const { return this->equals(other); } protected: - explicit StyleValue(Type); + explicit CSSStyleValue(Type); private: Type m_type; }; template -struct StyleValueWithDefaultOperators : public StyleValue { - using StyleValue::StyleValue; +struct StyleValueWithDefaultOperators : public CSSStyleValue { + using CSSStyleValue::CSSStyleValue; - virtual bool equals(StyleValue const& other) const override + virtual bool equals(CSSStyleValue const& other) const override { if (type() != other.type()) return false; @@ -390,8 +391,8 @@ struct StyleValueWithDefaultOperators : public StyleValue { } template<> -struct AK::Formatter : Formatter { - ErrorOr format(FormatBuilder& builder, Web::CSS::StyleValue const& style_value) +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, Web::CSS::CSSStyleValue const& style_value) { return Formatter::format(builder, style_value.to_string()); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSTransition.h b/Userland/Libraries/LibWeb/CSS/CSSTransition.h index 4e82319cf2c..4aac633c3b7 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSTransition.h +++ b/Userland/Libraries/LibWeb/CSS/CSSTransition.h @@ -7,8 +7,8 @@ #pragma once #include +#include #include -#include #include namespace Web::CSS { diff --git a/Userland/Libraries/LibWeb/CSS/CalculatedOr.cpp b/Userland/Libraries/LibWeb/CSS/CalculatedOr.cpp index 16f12bc1c70..4743a6a468b 100644 --- a/Userland/Libraries/LibWeb/CSS/CalculatedOr.cpp +++ b/Userland/Libraries/LibWeb/CSS/CalculatedOr.cpp @@ -22,7 +22,7 @@ Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr return calculated->resolve_angle().value(); } -NonnullRefPtr AngleOrCalculated::create_style_value() const +NonnullRefPtr AngleOrCalculated::create_style_value() const { return AngleStyleValue::create(value()); } @@ -32,7 +32,7 @@ Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr co return calculated->resolve_flex().value(); } -NonnullRefPtr FlexOrCalculated::create_style_value() const +NonnullRefPtr FlexOrCalculated::create_style_value() const { return FlexStyleValue::create(value()); } @@ -42,7 +42,7 @@ Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtrresolve_frequency().value(); } -NonnullRefPtr FrequencyOrCalculated::create_style_value() const +NonnullRefPtr FrequencyOrCalculated::create_style_value() const { return FrequencyStyleValue::create(value()); } @@ -52,7 +52,7 @@ i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr return calculated->resolve_integer().value(); } -NonnullRefPtr IntegerOrCalculated::create_style_value() const +NonnullRefPtr IntegerOrCalculated::create_style_value() const { return IntegerStyleValue::create(value()); } @@ -69,7 +69,7 @@ Length LengthOrCalculated::resolved(Length::ResolutionContext const& context) co return value(); } -NonnullRefPtr LengthOrCalculated::create_style_value() const +NonnullRefPtr LengthOrCalculated::create_style_value() const { return LengthStyleValue::create(value()); } @@ -79,7 +79,7 @@ double NumberOrCalculated::resolve_calculated(NonnullRefPtrresolve_number().value(); } -NonnullRefPtr NumberOrCalculated::create_style_value() const +NonnullRefPtr NumberOrCalculated::create_style_value() const { return NumberStyleValue::create(value()); } @@ -89,7 +89,7 @@ Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtrresolve_percentage().value(); } -NonnullRefPtr PercentageOrCalculated::create_style_value() const +NonnullRefPtr PercentageOrCalculated::create_style_value() const { return PercentageStyleValue::create(value()); } @@ -99,7 +99,7 @@ Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtrresolve_resolution().value(); } -NonnullRefPtr ResolutionOrCalculated::create_style_value() const +NonnullRefPtr ResolutionOrCalculated::create_style_value() const { return ResolutionStyleValue::create(value()); } @@ -109,7 +109,7 @@ Time TimeOrCalculated::resolve_calculated(NonnullRefPtr co return calculated->resolve_time().value(); } -NonnullRefPtr TimeOrCalculated::create_style_value() const +NonnullRefPtr TimeOrCalculated::create_style_value() const { return TimeStyleValue::create(value()); } diff --git a/Userland/Libraries/LibWeb/CSS/CalculatedOr.h b/Userland/Libraries/LibWeb/CSS/CalculatedOr.h index bbb64f2a62b..222fcc57457 100644 --- a/Userland/Libraries/LibWeb/CSS/CalculatedOr.h +++ b/Userland/Libraries/LibWeb/CSS/CalculatedOr.h @@ -41,7 +41,7 @@ public: return m_value.template get(); } - NonnullRefPtr as_style_value() const + NonnullRefPtr as_style_value() const { if (is_calculated()) return calculated(); @@ -82,7 +82,7 @@ public: protected: virtual T resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const = 0; - virtual NonnullRefPtr create_style_value() const = 0; + virtual NonnullRefPtr create_style_value() const = 0; private: Variant> m_value; @@ -94,7 +94,7 @@ public: private: virtual Angle resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class FlexOrCalculated : public CalculatedOr { @@ -103,7 +103,7 @@ public: private: virtual Flex resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class FrequencyOrCalculated : public CalculatedOr { @@ -112,7 +112,7 @@ public: private: virtual Frequency resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class IntegerOrCalculated : public CalculatedOr { @@ -121,7 +121,7 @@ public: private: virtual i64 resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class LengthOrCalculated : public CalculatedOr { @@ -132,7 +132,7 @@ public: private: virtual Length resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class NumberOrCalculated : public CalculatedOr { @@ -141,7 +141,7 @@ public: private: virtual double resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class PercentageOrCalculated : public CalculatedOr { @@ -150,7 +150,7 @@ public: private: virtual Percentage resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class ResolutionOrCalculated : public CalculatedOr { @@ -159,7 +159,7 @@ public: private: virtual Resolution resolve_calculated(NonnullRefPtr const&, Layout::Node const&) const override; - virtual NonnullRefPtr create_style_value() const override; + virtual NonnullRefPtr create_style_value() const override; }; class TimeOrCalculated : public CalculatedOr