diff --git a/Libraries/LibDevTools/Actors/NodeActor.cpp b/Libraries/LibDevTools/Actors/NodeActor.cpp index 25668b8bcec..4b39b7d514d 100644 --- a/Libraries/LibDevTools/Actors/NodeActor.cpp +++ b/Libraries/LibDevTools/Actors/NodeActor.cpp @@ -66,9 +66,9 @@ NodeIdentifier NodeIdentifier::for_node(JsonObject const& node) { NodeIdentifier identifier; - identifier.pseudo_element = node.get_integer>("pseudo-element"sv).map([](auto value) { - VERIFY(value < to_underlying(Web::CSS::Selector::PseudoElement::Type::KnownPseudoElementCount)); - return static_cast(value); + identifier.pseudo_element = node.get_integer>("pseudo-element"sv).map([](auto value) { + VERIFY(value < to_underlying(Web::CSS::PseudoElement::KnownPseudoElementCount)); + return static_cast(value); }); if (identifier.pseudo_element.has_value()) diff --git a/Libraries/LibDevTools/Actors/NodeActor.h b/Libraries/LibDevTools/Actors/NodeActor.h index 09d4a8942d0..6b74694b190 100644 --- a/Libraries/LibDevTools/Actors/NodeActor.h +++ b/Libraries/LibDevTools/Actors/NodeActor.h @@ -21,7 +21,7 @@ struct NodeIdentifier { bool operator==(NodeIdentifier const&) const = default; Web::UniqueNodeID id { 0 }; - Optional pseudo_element; + Optional pseudo_element; }; class NodeActor final : public Actor { @@ -55,7 +55,7 @@ struct AK::Traits : public AK::DefaultTraits; virtual void listen_for_dom_properties(TabDescription const&, OnDOMNodePropertiesReceived) const { } virtual void stop_listening_for_dom_properties(TabDescription const&) const { } - virtual void inspect_dom_node(TabDescription const&, WebView::DOMNodeProperties::Type, Web::UniqueNodeID, Optional) const { } + virtual void inspect_dom_node(TabDescription const&, WebView::DOMNodeProperties::Type, Web::UniqueNodeID, Optional) const { } virtual void clear_inspected_dom_node(TabDescription const&) const { } - virtual void highlight_dom_node(TabDescription const&, Web::UniqueNodeID, Optional) const { } + virtual void highlight_dom_node(TabDescription const&, Web::UniqueNodeID, Optional) const { } virtual void clear_highlighted_dom_node(TabDescription const&) const { } using OnDOMMutationReceived = Function; diff --git a/Libraries/LibWeb/Animations/Animatable.cpp b/Libraries/LibWeb/Animations/Animatable.cpp index 41a706c99f2..1ece7cafc55 100644 --- a/Libraries/LibWeb/Animations/Animatable.cpp +++ b/Libraries/LibWeb/Animations/Animatable.cpp @@ -72,7 +72,7 @@ WebIDL::ExceptionOr>> Animatable::get_animations_inter // 2. Let pseudoElement be the result of pseudo-element parsing applied to pseudoElement of options, or null if options is not passed. // FIXME: Currently only DOM::Element includes Animatable, but that might not always be true. - Optional pseudo_element; + Optional pseudo_element; if (options.has_value() && options->pseudo_element.has_value()) { auto& realm = static_cast(*this).realm(); pseudo_element = TRY(pseudo_element_parsing(realm, options->pseudo_element)); @@ -185,10 +185,10 @@ void Animatable::visit_edges(JS::Cell::Visitor& visitor) visitor.visit(m_associated_transitions); } -GC::Ptr Animatable::cached_animation_name_source(Optional pseudo_element) const +GC::Ptr Animatable::cached_animation_name_source(Optional pseudo_element) const { if (pseudo_element.has_value()) { - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value())) { return {}; } return m_cached_animation_name_source[to_underlying(pseudo_element.value()) + 1]; @@ -196,10 +196,10 @@ GC::Ptr Animatable::cached_animation_name_source return m_cached_animation_name_source[0]; } -void Animatable::set_cached_animation_name_source(GC::Ptr value, Optional pseudo_element) +void Animatable::set_cached_animation_name_source(GC::Ptr value, Optional pseudo_element) { if (pseudo_element.has_value()) { - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value())) { return; } m_cached_animation_name_source[to_underlying(pseudo_element.value()) + 1] = value; @@ -208,10 +208,10 @@ void Animatable::set_cached_animation_name_source(GC::Ptr Animatable::cached_animation_name_animation(Optional pseudo_element) const +GC::Ptr Animatable::cached_animation_name_animation(Optional pseudo_element) const { if (pseudo_element.has_value()) { - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value())) { return {}; } @@ -220,11 +220,11 @@ GC::Ptr Animatable::cached_animation_name_animation(Optio return m_cached_animation_name_animation[0]; } -void Animatable::set_cached_animation_name_animation(GC::Ptr value, Optional pseudo_element) +void Animatable::set_cached_animation_name_animation(GC::Ptr value, Optional pseudo_element) { if (pseudo_element.has_value()) { - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value())) { return; } diff --git a/Libraries/LibWeb/Animations/Animatable.h b/Libraries/LibWeb/Animations/Animatable.h index 1ccaaa6d96f..b0c96efdb22 100644 --- a/Libraries/LibWeb/Animations/Animatable.h +++ b/Libraries/LibWeb/Animations/Animatable.h @@ -47,11 +47,11 @@ public: void associate_with_animation(GC::Ref); void disassociate_with_animation(GC::Ref); - GC::Ptr cached_animation_name_source(Optional) const; - void set_cached_animation_name_source(GC::Ptr value, Optional); + GC::Ptr cached_animation_name_source(Optional) const; + void set_cached_animation_name_source(GC::Ptr value, Optional); - GC::Ptr cached_animation_name_animation(Optional) const; - void set_cached_animation_name_animation(GC::Ptr value, Optional); + GC::Ptr cached_animation_name_animation(Optional) const; + void set_cached_animation_name_animation(GC::Ptr value, Optional); GC::Ptr cached_transition_property_source() const { return m_cached_transition_property_source; } void set_cached_transition_property_source(GC::Ptr value) { m_cached_transition_property_source = value; } @@ -70,8 +70,8 @@ private: Vector> m_associated_animations; bool m_is_sorted_by_composite_order { true }; - Array, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_source; - Array, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_animation; + Array, to_underlying(CSS::PseudoElement::KnownPseudoElementCount) + 1> m_cached_animation_name_source; + Array, to_underlying(CSS::PseudoElement::KnownPseudoElementCount) + 1> m_cached_animation_name_animation; HashMap m_transition_attribute_indices; Vector m_transition_attributes; diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index c6a4efd4df9..a3871722802 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -791,7 +791,7 @@ WebIDL::ExceptionOr KeyframeEffect::set_pseudo_element(Optional va return {}; } -Optional KeyframeEffect::pseudo_element_type() const +Optional KeyframeEffect::pseudo_element_type() const { if (!m_target_pseudo_selector.has_value()) return {}; diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.h b/Libraries/LibWeb/Animations/KeyframeEffect.h index 3951a53e0c9..438852fc796 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.h +++ b/Libraries/LibWeb/Animations/KeyframeEffect.h @@ -91,8 +91,8 @@ public: Optional pseudo_element() const; WebIDL::ExceptionOr set_pseudo_element(Optional); - Optional pseudo_element_type() const; - void set_pseudo_element(Optional pseudo_element) { m_target_pseudo_selector = pseudo_element; } + Optional pseudo_element_type() const; + void set_pseudo_element(Optional pseudo_element) { m_target_pseudo_selector = pseudo_element; } Bindings::CompositeOperation composite() const { return m_composite; } void set_composite(Bindings::CompositeOperation value) { m_composite = value; } @@ -121,7 +121,7 @@ private: GC::Ptr m_target_element {}; // https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-pseudoelement - Optional m_target_pseudo_selector {}; + Optional m_target_pseudo_selector {}; // https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-composite Bindings::CompositeOperation m_composite { Bindings::CompositeOperation::Replace }; diff --git a/Libraries/LibWeb/Animations/PseudoElementParsing.cpp b/Libraries/LibWeb/Animations/PseudoElementParsing.cpp index 347e0582e34..3286d7bbf5a 100644 --- a/Libraries/LibWeb/Animations/PseudoElementParsing.cpp +++ b/Libraries/LibWeb/Animations/PseudoElementParsing.cpp @@ -10,12 +10,12 @@ namespace Web::Animations { // https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-pseudo-element-parsing -WebIDL::ExceptionOr> pseudo_element_parsing(JS::Realm& realm, Optional const& value) +WebIDL::ExceptionOr> pseudo_element_parsing(JS::Realm& realm, Optional const& value) { // 1. Given the value value, perform the following steps: // 2. If value is not null and is an invalid , - Optional pseudo_element; + Optional pseudo_element; if (value.has_value()) { pseudo_element = parse_pseudo_element_selector(CSS::Parser::ParsingParams { realm }, *value); if (!pseudo_element.has_value()) { @@ -28,7 +28,7 @@ WebIDL::ExceptionOr> pseudo_element_parsi // 3. If value is one of the legacy Selectors Level 2 single-colon selectors (':before', ':after', ':first-letter', or ':first-line'), // then return the equivalent two-colon selector (e.g. '::before'). if (value.has_value() && value->is_one_of(":before", ":after", ":first-letter", ":first-line")) { - return CSS::Selector::PseudoElement::from_string(MUST(value->substring_from_byte_offset(1))); + return CSS::Selector::PseudoElementSelector::from_string(MUST(value->substring_from_byte_offset(1))); } // 4. Otherwise, return value. diff --git a/Libraries/LibWeb/Animations/PseudoElementParsing.h b/Libraries/LibWeb/Animations/PseudoElementParsing.h index 55d7acb316c..989f42a2148 100644 --- a/Libraries/LibWeb/Animations/PseudoElementParsing.h +++ b/Libraries/LibWeb/Animations/PseudoElementParsing.h @@ -14,6 +14,6 @@ namespace Web::Animations { // https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-pseudo-element-parsing -WebIDL::ExceptionOr> pseudo_element_parsing(JS::Realm&, Optional const&); +WebIDL::ExceptionOr> pseudo_element_parsing(JS::Realm&, Optional const&); } diff --git a/Libraries/LibWeb/CSS/CascadedProperties.cpp b/Libraries/LibWeb/CSS/CascadedProperties.cpp index 67aa5837392..5e2ea38b700 100644 --- a/Libraries/LibWeb/CSS/CascadedProperties.cpp +++ b/Libraries/LibWeb/CSS/CascadedProperties.cpp @@ -56,7 +56,7 @@ void CascadedProperties::revert_layer_property(PropertyID property_id, Important m_properties.remove(it); } -void CascadedProperties::resolve_unresolved_properties(GC::Ref element, Optional pseudo_element) +void CascadedProperties::resolve_unresolved_properties(GC::Ref element, Optional pseudo_element) { for (auto& [property_id, entries] : m_properties) { for (auto& entry : entries) { diff --git a/Libraries/LibWeb/CSS/CascadedProperties.h b/Libraries/LibWeb/CSS/CascadedProperties.h index 2876589491d..c5b673d8ef7 100644 --- a/Libraries/LibWeb/CSS/CascadedProperties.h +++ b/Libraries/LibWeb/CSS/CascadedProperties.h @@ -33,7 +33,7 @@ public: void revert_property(PropertyID, Important, CascadeOrigin); void revert_layer_property(PropertyID, Important, Optional layer_name); - void resolve_unresolved_properties(GC::Ref, Optional); + void resolve_unresolved_properties(GC::Ref, Optional); private: CascadedProperties(); diff --git a/Libraries/LibWeb/CSS/Parser/Helpers.cpp b/Libraries/LibWeb/CSS/Parser/Helpers.cpp index 8de40db92f0..52f7cb22d73 100644 --- a/Libraries/LibWeb/CSS/Parser/Helpers.cpp +++ b/Libraries/LibWeb/CSS/Parser/Helpers.cpp @@ -65,7 +65,7 @@ Optional parse_selector_for_nested_style_rule(CSS::Parser::Pa return adapt_nested_relative_selector_list(*maybe_selectors); } -Optional parse_pseudo_element_selector(CSS::Parser::ParsingParams const& context, StringView selector_text) +Optional parse_pseudo_element_selector(CSS::Parser::ParsingParams const& context, StringView selector_text) { return CSS::Parser::Parser::create(context, selector_text).parse_as_pseudo_element_selector(); } diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index 2c7a350ead3..5ce9bf95bf6 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -108,7 +108,7 @@ public: Optional parse_as_selector(SelectorParsingMode = SelectorParsingMode::Standard); Optional parse_as_relative_selector(SelectorParsingMode = SelectorParsingMode::Standard); - Optional parse_as_pseudo_element_selector(); + Optional parse_as_pseudo_element_selector(); Vector> parse_as_media_query_list(); RefPtr parse_as_media_query(); @@ -123,7 +123,7 @@ public: Vector parse_as_list_of_component_values(); - static NonnullRefPtr resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional, PropertyID, UnresolvedStyleValue const&); + static NonnullRefPtr resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional, PropertyID, UnresolvedStyleValue const&); [[nodiscard]] LengthOrCalculated parse_as_sizes_attribute(DOM::Element const& element, HTML::HTMLImageElement const* img = nullptr); @@ -450,8 +450,8 @@ private: OwnPtr parse_supports_feature(TokenStream&); - NonnullRefPtr resolve_unresolved_style_value(DOM::Element&, Optional, PropertyID, UnresolvedStyleValue const&); - bool expand_variables(DOM::Element&, Optional, FlyString const& property_name, HashMap>& dependencies, TokenStream& source, Vector& dest); + NonnullRefPtr resolve_unresolved_style_value(DOM::Element&, Optional, PropertyID, UnresolvedStyleValue const&); + bool expand_variables(DOM::Element&, Optional, FlyString const& property_name, HashMap>& dependencies, TokenStream& source, Vector& dest); bool expand_unresolved_values(DOM::Element&, FlyString const& property_name, TokenStream& source, Vector& dest); bool substitute_attr_function(DOM::Element& element, FlyString const& property_name, Function const& attr_function, Vector& dest); @@ -514,7 +514,7 @@ CSS::Parser::Parser::PropertiesAndCustomProperties parse_css_style_attribute(CSS RefPtr parse_css_value(CSS::Parser::ParsingParams const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid); Optional parse_selector(CSS::Parser::ParsingParams const&, StringView); Optional parse_selector_for_nested_style_rule(CSS::Parser::ParsingParams const&, StringView); -Optional parse_pseudo_element_selector(CSS::Parser::ParsingParams const&, StringView); +Optional parse_pseudo_element_selector(CSS::Parser::ParsingParams const&, StringView); CSS::CSSRule* parse_css_rule(CSS::Parser::ParsingParams const&, StringView); RefPtr parse_media_query(CSS::Parser::ParsingParams const&, StringView); Vector> parse_media_query_list(CSS::Parser::ParsingParams const&, StringView); diff --git a/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp b/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp index 8ac9ae304ed..4d060b4989e 100644 --- a/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp @@ -32,7 +32,7 @@ Optional Parser::parse_as_relative_selector(SelectorParsingMode pa return {}; } -Optional Parser::parse_as_pseudo_element_selector() +Optional Parser::parse_as_pseudo_element_selector() { // FIXME: This is quite janky. Selector parsing is not at all designed to allow parsing just a single part of a selector. // So, this code parses a whole selector, then rejects it if it's not a single pseudo-element simple selector. @@ -418,8 +418,7 @@ Parser::ParseErrorOr Parser::parse_pseudo_simple_selec auto pseudo_name = name_token.token().ident(); - // Note: We allow the "ignored" -webkit prefix here for -webkit-progress-bar/-webkit-progress-bar - if (auto pseudo_element = Selector::PseudoElement::from_string(pseudo_name); pseudo_element.has_value()) { + if (auto pseudo_element = Selector::PseudoElementSelector::from_string(pseudo_name); pseudo_element.has_value()) { // :has() is fussy about pseudo-elements inside it if (m_pseudo_class_context.contains_slow(PseudoClass::Has) && !is_has_allowed_pseudo_element(pseudo_element->type())) { return ParseError::SyntaxError; @@ -444,7 +443,7 @@ Parser::ParseErrorOr Parser::parse_pseudo_simple_selec return Selector::SimpleSelector { .type = Selector::SimpleSelector::Type::PseudoElement, // Unknown -webkit- pseudo-elements must be serialized in ASCII lowercase. - .value = Selector::PseudoElement { Selector::PseudoElement::Type::UnknownWebKit, pseudo_name.to_string().to_ascii_lowercase() }, + .value = Selector::PseudoElementSelector { PseudoElement::UnknownWebKit, pseudo_name.to_string().to_ascii_lowercase() }, }; } @@ -482,12 +481,12 @@ Parser::ParseErrorOr Parser::parse_pseudo_simple_selec // Single-colon syntax allowed for ::after, ::before, ::first-letter and ::first-line for compatibility. // https://www.w3.org/TR/selectors/#pseudo-element-syntax - if (auto pseudo_element = Selector::PseudoElement::from_string(pseudo_name); pseudo_element.has_value()) { + if (auto pseudo_element = Selector::PseudoElementSelector::from_string(pseudo_name); pseudo_element.has_value()) { switch (pseudo_element.value().type()) { - case Selector::PseudoElement::Type::After: - case Selector::PseudoElement::Type::Before: - case Selector::PseudoElement::Type::FirstLetter: - case Selector::PseudoElement::Type::FirstLine: + case PseudoElement::After: + case PseudoElement::Before: + case PseudoElement::FirstLetter: + case PseudoElement::FirstLine: // :has() is fussy about pseudo-elements inside it if (m_pseudo_class_context.contains_slow(PseudoClass::Has) && !is_has_allowed_pseudo_element(pseudo_element->type())) { return ParseError::SyntaxError; diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index 98737673a7f..19ec3ee5241 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -3555,7 +3555,7 @@ RefPtr Parser::parse_opentype_tag_value(TokenStream Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved) +NonnullRefPtr Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved) { // Unresolved always contains a var() or attr(), unless it is a custom property's value, in which case we shouldn't be trying // to produce a different CSSStyleValue from it. @@ -3610,7 +3610,7 @@ private: bool m_marked { false }; }; -NonnullRefPtr Parser::resolve_unresolved_style_value(DOM::Element& element, Optional pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved) +NonnullRefPtr Parser::resolve_unresolved_style_value(DOM::Element& element, Optional pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved) { TokenStream unresolved_values_without_variables_expanded { unresolved.values() }; Vector values_with_variables_expanded; @@ -3639,7 +3639,7 @@ NonnullRefPtr Parser::resolve_unresolved_style_value(DOM::Element return CSSKeywordValue::create(Keyword::Unset); } -static RefPtr get_custom_property(DOM::Element const& element, Optional pseudo_element, FlyString const& custom_property_name) +static RefPtr get_custom_property(DOM::Element const& element, Optional pseudo_element, FlyString const& custom_property_name) { if (pseudo_element.has_value()) { if (auto it = element.custom_properties(pseudo_element).find(custom_property_name); it != element.custom_properties(pseudo_element).end()) @@ -3653,7 +3653,7 @@ static RefPtr get_custom_property(DOM::Element const& eleme return nullptr; } -bool Parser::expand_variables(DOM::Element& element, Optional pseudo_element, FlyString const& property_name, HashMap>& dependencies, TokenStream& source, Vector& dest) +bool Parser::expand_variables(DOM::Element& element, Optional pseudo_element, FlyString const& property_name, HashMap>& dependencies, TokenStream& source, Vector& dest) { // Arbitrary large value chosen to avoid the billion-laughs attack. // https://www.w3.org/TR/css-variables-1/#long-variables diff --git a/Libraries/LibWeb/CSS/Selector.cpp b/Libraries/LibWeb/CSS/Selector.cpp index 8f9333fd61f..c2c2e10dc9c 100644 --- a/Libraries/LibWeb/CSS/Selector.cpp +++ b/Libraries/LibWeb/CSS/Selector.cpp @@ -535,70 +535,70 @@ String serialize_a_group_of_selectors(SelectorList const& selectors) return MUST(String::join(", "sv, selectors)); } -StringView Selector::PseudoElement::name(Selector::PseudoElement::Type pseudo_element) +StringView Selector::PseudoElementSelector::name(PseudoElement pseudo_element) { switch (pseudo_element) { - case Selector::PseudoElement::Type::Before: + case PseudoElement::Before: return "before"sv; - case Selector::PseudoElement::Type::After: + case PseudoElement::After: return "after"sv; - case Selector::PseudoElement::Type::FirstLine: + case PseudoElement::FirstLine: return "first-line"sv; - case Selector::PseudoElement::Type::FirstLetter: + case PseudoElement::FirstLetter: return "first-letter"sv; - case Selector::PseudoElement::Type::Marker: + case PseudoElement::Marker: return "marker"sv; - case Selector::PseudoElement::Type::Track: + case PseudoElement::Track: return "track"sv; - case Selector::PseudoElement::Type::Fill: + case PseudoElement::Fill: return "fill"sv; - case Selector::PseudoElement::Type::Thumb: + case PseudoElement::Thumb: return "thumb"sv; - case Selector::PseudoElement::Type::Placeholder: + case PseudoElement::Placeholder: return "placeholder"sv; - case Selector::PseudoElement::Type::Selection: + case PseudoElement::Selection: return "selection"sv; - case Selector::PseudoElement::Type::Backdrop: + case PseudoElement::Backdrop: return "backdrop"sv; - case Selector::PseudoElement::Type::FileSelectorButton: + case PseudoElement::FileSelectorButton: return "file-selector-button"sv; - case Selector::PseudoElement::Type::DetailsContent: + case PseudoElement::DetailsContent: return "details-content"sv; - case Selector::PseudoElement::Type::KnownPseudoElementCount: - case Selector::PseudoElement::Type::UnknownWebKit: + case PseudoElement::KnownPseudoElementCount: + case PseudoElement::UnknownWebKit: VERIFY_NOT_REACHED(); } VERIFY_NOT_REACHED(); } -Optional Selector::PseudoElement::from_string(FlyString const& name) +Optional Selector::PseudoElementSelector::from_string(FlyString const& name) { if (name.equals_ignoring_ascii_case("after"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::After }; + return Selector::PseudoElementSelector { PseudoElement::After }; } else if (name.equals_ignoring_ascii_case("before"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Before }; + return Selector::PseudoElementSelector { PseudoElement::Before }; } else if (name.equals_ignoring_ascii_case("first-letter"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::FirstLetter }; + return Selector::PseudoElementSelector { PseudoElement::FirstLetter }; } else if (name.equals_ignoring_ascii_case("first-line"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::FirstLine }; + return Selector::PseudoElementSelector { PseudoElement::FirstLine }; } else if (name.equals_ignoring_ascii_case("marker"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Marker }; + return Selector::PseudoElementSelector { PseudoElement::Marker }; } else if (name.equals_ignoring_ascii_case("track"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Track }; + return Selector::PseudoElementSelector { PseudoElement::Track }; } else if (name.equals_ignoring_ascii_case("fill"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Fill }; + return Selector::PseudoElementSelector { PseudoElement::Fill }; } else if (name.equals_ignoring_ascii_case("thumb"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Thumb }; + return Selector::PseudoElementSelector { PseudoElement::Thumb }; } else if (name.equals_ignoring_ascii_case("placeholder"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Placeholder }; + return Selector::PseudoElementSelector { PseudoElement::Placeholder }; } else if (name.equals_ignoring_ascii_case("selection"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Selection }; + return Selector::PseudoElementSelector { PseudoElement::Selection }; } else if (name.equals_ignoring_ascii_case("backdrop"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::Backdrop }; + return Selector::PseudoElementSelector { PseudoElement::Backdrop }; } else if (name.equals_ignoring_ascii_case("file-selector-button"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::FileSelectorButton }; + return Selector::PseudoElementSelector { PseudoElement::FileSelectorButton }; } else if (name.equals_ignoring_ascii_case("details-content"sv)) { - return Selector::PseudoElement { Selector::PseudoElement::Type::DetailsContent }; + return Selector::PseudoElementSelector { PseudoElement::DetailsContent }; } return {}; } @@ -636,7 +636,7 @@ bool Selector::contains_unknown_webkit_pseudo_element() const } } } - if (simple_selector.type == SimpleSelector::Type::PseudoElement && simple_selector.pseudo_element().type() == PseudoElement::Type::UnknownWebKit) + if (simple_selector.type == SimpleSelector::Type::PseudoElement && simple_selector.pseudo_element().type() == PseudoElement::UnknownWebKit) return true; } } @@ -828,7 +828,7 @@ SelectorList adapt_nested_relative_selector_list(SelectorList const& selectors) } // https://drafts.csswg.org/selectors/#has-allowed-pseudo-element -bool is_has_allowed_pseudo_element(Selector::PseudoElement::Type) +bool is_has_allowed_pseudo_element(PseudoElement) { // No spec currently defines any pseudo-elements that are allowed in :has() return false; diff --git a/Libraries/LibWeb/CSS/Selector.h b/Libraries/LibWeb/CSS/Selector.h index a670e402f45..e7ab692aaac 100644 --- a/Libraries/LibWeb/CSS/Selector.h +++ b/Libraries/LibWeb/CSS/Selector.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling - * Copyright (c) 2021-2024, Sam Atkins + * Copyright (c) 2021-2025, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -19,56 +19,56 @@ namespace Web::CSS { using SelectorList = Vector>; +enum class PseudoElement : u8 { + Before, + After, + FirstLine, + FirstLetter, + Marker, + Track, + Fill, + Thumb, + Placeholder, + Selection, + Backdrop, + FileSelectorButton, + DetailsContent, + + // Keep this last. + KnownPseudoElementCount, + + // https://www.w3.org/TR/selectors-4/#compat + // NOTE: This is not last as the 'unknown -webkit- pseudo-elements' are not stored as part of any Element. + UnknownWebKit, +}; + // This is a in the spec. https://www.w3.org/TR/selectors-4/#complex class Selector : public RefCounted { public: - class PseudoElement { + class PseudoElementSelector { public: - enum class Type : u8 { - Before, - After, - FirstLine, - FirstLetter, - Marker, - Track, - Fill, - Thumb, - Placeholder, - Selection, - Backdrop, - FileSelectorButton, - DetailsContent, - - // Keep this last. - KnownPseudoElementCount, - - // https://www.w3.org/TR/selectors-4/#compat - // NOTE: This is not last as the 'unknown -webkit- pseudo-elements' are not stored as part of any Element. - UnknownWebKit, - }; - - explicit PseudoElement(Type type) + explicit PseudoElementSelector(PseudoElement type) : m_type(type) { VERIFY(is_known_pseudo_element_type(type)); } - PseudoElement(Type type, String name) + PseudoElementSelector(PseudoElement type, String name) : m_type(type) , m_name(move(name)) { } - bool operator==(PseudoElement const&) const = default; + bool operator==(PseudoElementSelector const&) const = default; - static Optional from_string(FlyString const&); + static Optional from_string(FlyString const&); - [[nodiscard]] static bool is_known_pseudo_element_type(Type type) + [[nodiscard]] static bool is_known_pseudo_element_type(PseudoElement type) { - return to_underlying(type) < to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount); + return to_underlying(type) < to_underlying(PseudoElement::KnownPseudoElementCount); } - static StringView name(Selector::PseudoElement::Type pseudo_element); + static StringView name(PseudoElement pseudo_element); StringView name() const { @@ -78,10 +78,10 @@ public: return name(m_type); } - Type type() const { return m_type; } + PseudoElement type() const { return m_type; } private: - Type m_type; + PseudoElement m_type; String m_name; }; @@ -206,14 +206,14 @@ public: }; Type type; - Variant value {}; + Variant value {}; Attribute const& attribute() const { return value.get(); } Attribute& attribute() { return value.get(); } PseudoClassSelector const& pseudo_class() const { return value.get(); } PseudoClassSelector& pseudo_class() { return value.get(); } - PseudoElement const& pseudo_element() const { return value.get(); } - PseudoElement& pseudo_element() { return value.get(); } + PseudoElementSelector const& pseudo_element() const { return value.get(); } + PseudoElementSelector& pseudo_element() { return value.get(); } FlyString const& name() const { return value.get().name; } FlyString& name() { return value.get().name; } @@ -253,7 +253,7 @@ public: ~Selector() = default; Vector const& compound_selectors() const { return m_compound_selectors; } - Optional const& pseudo_element() const { return m_pseudo_element; } + Optional const& pseudo_element() const { return m_pseudo_element; } NonnullRefPtr relative_to(SimpleSelector const&) const; bool contains_the_nesting_selector() const { return m_contains_the_nesting_selector; } bool contains_hover_pseudo_class() const { return m_contains_hover_pseudo_class; } @@ -274,7 +274,7 @@ private: Vector m_compound_selectors; mutable Optional m_specificity; - Optional m_pseudo_element; + Optional m_pseudo_element; mutable Optional m_sibling_invalidation_distance; bool m_can_use_fast_matches { false }; bool m_can_use_ancestor_filter { false }; @@ -290,7 +290,7 @@ String serialize_a_group_of_selectors(SelectorList const& selectors); SelectorList adapt_nested_relative_selector_list(SelectorList const&); -bool is_has_allowed_pseudo_element(Selector::PseudoElement::Type); +bool is_has_allowed_pseudo_element(PseudoElement); } diff --git a/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Libraries/LibWeb/CSS/SelectorEngine.cpp index b7ee412148e..5c8d5eabb31 100644 --- a/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -1026,7 +1026,7 @@ bool matches(CSS::Selector const& selector, int component_list_index, DOM::Eleme bool fast_matches(CSS::Selector const& selector, DOM::Element const& element_to_match, GC::Ptr shadow_host, MatchContext& context); -bool matches(CSS::Selector const& selector, DOM::Element const& element, GC::Ptr shadow_host, MatchContext& context, Optional pseudo_element, GC::Ptr scope, SelectorKind selector_kind, GC::Ptr anchor) +bool matches(CSS::Selector const& selector, DOM::Element const& element, GC::Ptr shadow_host, MatchContext& context, Optional pseudo_element, GC::Ptr scope, SelectorKind selector_kind, GC::Ptr anchor) { if (selector_kind == SelectorKind::Normal && selector.can_use_fast_matches()) { return fast_matches(selector, element, shadow_host, context); diff --git a/Libraries/LibWeb/CSS/SelectorEngine.h b/Libraries/LibWeb/CSS/SelectorEngine.h index e62c0a298e9..7c45c67d3e7 100644 --- a/Libraries/LibWeb/CSS/SelectorEngine.h +++ b/Libraries/LibWeb/CSS/SelectorEngine.h @@ -23,6 +23,6 @@ struct MatchContext { bool did_match_any_hover_rules { false }; }; -bool matches(CSS::Selector const&, DOM::Element const&, GC::Ptr shadow_host, MatchContext& context, Optional = {}, GC::Ptr scope = {}, SelectorKind selector_kind = SelectorKind::Normal, GC::Ptr anchor = nullptr); +bool matches(CSS::Selector const&, DOM::Element const&, GC::Ptr shadow_host, MatchContext& context, Optional = {}, GC::Ptr scope = {}, SelectorKind selector_kind = SelectorKind::Normal, GC::Ptr anchor = nullptr); } diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 75cd39d664f..e5275a1a1e9 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -173,7 +173,7 @@ OwnFontFaceKey::operator FontFaceKey() const && slope == other.slope; } -static DOM::Element const* element_to_inherit_style_from(DOM::Element const*, Optional); +static DOM::Element const* element_to_inherit_style_from(DOM::Element const*, Optional); StyleComputer::StyleComputer(DOM::Document& document) : m_document(document) @@ -472,7 +472,7 @@ bool StyleComputer::invalidation_property_used_in_has_selector(InvalidationSet:: return false; } -Vector StyleComputer::collect_matching_rules(DOM::Element const& element, CascadeOrigin cascade_origin, Optional pseudo_element, bool& did_match_any_hover_rules, FlyString const& qualified_layer_name) const +Vector StyleComputer::collect_matching_rules(DOM::Element const& element, CascadeOrigin cascade_origin, Optional pseudo_element, bool& did_match_any_hover_rules, FlyString const& qualified_layer_name) const { auto const& root_node = element.root(); auto shadow_root = is(root_node) ? static_cast(&root_node) : nullptr; @@ -985,7 +985,7 @@ void StyleComputer::set_property_expanding_shorthands( void StyleComputer::set_all_properties( CascadedProperties& cascaded_properties, DOM::Element& element, - Optional pseudo_element, + Optional pseudo_element, CSSStyleValue const& value, DOM::Document& document, GC::Ptr declaration, @@ -1019,7 +1019,7 @@ void StyleComputer::set_all_properties( void StyleComputer::cascade_declarations( CascadedProperties& cascaded_properties, DOM::Element& element, - Optional pseudo_element, + Optional pseudo_element, Vector const& matching_rules, CascadeOrigin cascade_origin, Important important, @@ -1064,7 +1064,7 @@ void StyleComputer::cascade_declarations( } } -static void cascade_custom_properties(DOM::Element& element, Optional pseudo_element, Vector const& matching_rules, HashMap& custom_properties) +static void cascade_custom_properties(DOM::Element& element, Optional pseudo_element, Vector const& matching_rules, HashMap& custom_properties) { size_t needed_capacity = 0; for (auto const& matching_rule : matching_rules) @@ -1094,7 +1094,7 @@ static void cascade_custom_properties(DOM::Element& element, Optional pseudo_element, GC::Ref effect, ComputedProperties& computed_properties, AnimationRefresh refresh) const +void StyleComputer::collect_animation_into(DOM::Element& element, Optional pseudo_element, GC::Ref effect, ComputedProperties& computed_properties, AnimationRefresh refresh) const { auto animation = effect->associated_animation(); if (!animation) @@ -1285,7 +1285,7 @@ static void apply_dimension_attribute(CascadedProperties& cascaded_properties, D cascaded_properties.set_property_from_presentational_hint(property_id, parsed_value.release_nonnull()); } -static void compute_transitioned_properties(ComputedProperties const& style, DOM::Element& element, Optional pseudo_element) +static void compute_transitioned_properties(ComputedProperties const& style, DOM::Element& element, Optional pseudo_element) { // FIXME: Implement transitioning for pseudo-elements (void)pseudo_element; @@ -1369,7 +1369,7 @@ static void compute_transitioned_properties(ComputedProperties const& style, DOM } // https://drafts.csswg.org/css-transitions/#starting -void StyleComputer::start_needed_transitions(ComputedProperties const& previous_style, ComputedProperties& new_style, DOM::Element& element, Optional pseudo_element) const +void StyleComputer::start_needed_transitions(ComputedProperties const& previous_style, ComputedProperties& new_style, DOM::Element& element, Optional pseudo_element) const { // FIXME: Implement transitions for pseudo-elements if (pseudo_element.has_value()) @@ -1563,7 +1563,7 @@ void StyleComputer::start_needed_transitions(ComputedProperties const& previous_ // https://www.w3.org/TR/css-cascade/#cascading // https://drafts.csswg.org/css-cascade-5/#layering -GC::Ref StyleComputer::compute_cascaded_values(DOM::Element& element, Optional pseudo_element, bool& did_match_any_pseudo_element_rules, bool& did_match_any_hover_rules, ComputeStyleMode mode) const +GC::Ref StyleComputer::compute_cascaded_values(DOM::Element& element, Optional pseudo_element, bool& did_match_any_pseudo_element_rules, bool& did_match_any_hover_rules, ComputeStyleMode mode) const { auto cascaded_properties = m_document->heap().allocate(); @@ -1652,7 +1652,7 @@ GC::Ref StyleComputer::compute_cascaded_values(DOM::Element& return cascaded_properties; } -DOM::Element const* element_to_inherit_style_from(DOM::Element const* element, Optional pseudo_element) +DOM::Element const* element_to_inherit_style_from(DOM::Element const* element, Optional pseudo_element) { // Pseudo-elements treat their originating element as their parent. DOM::Element const* parent_element = nullptr; @@ -1664,7 +1664,7 @@ DOM::Element const* element_to_inherit_style_from(DOM::Element const* element, O return parent_element; } -NonnullRefPtr StyleComputer::get_inherit_value(CSS::PropertyID property_id, DOM::Element const* element, Optional pseudo_element) +NonnullRefPtr StyleComputer::get_inherit_value(CSS::PropertyID property_id, DOM::Element const* element, Optional pseudo_element) { auto* parent_element = element_to_inherit_style_from(element, pseudo_element); @@ -1673,7 +1673,7 @@ NonnullRefPtr StyleComputer::get_inherit_value(CSS::Propert return parent_element->computed_properties()->property(property_id); } -void StyleComputer::compute_defaulted_property_value(ComputedProperties& style, DOM::Element const* element, CSS::PropertyID property_id, Optional pseudo_element) const +void StyleComputer::compute_defaulted_property_value(ComputedProperties& style, DOM::Element const* element, CSS::PropertyID property_id, Optional pseudo_element) const { // FIXME: If we don't know the correct initial value for a property, we fall back to `initial`. @@ -1717,7 +1717,7 @@ void StyleComputer::compute_defaulted_property_value(ComputedProperties& style, } // https://www.w3.org/TR/css-cascade/#defaulting -void StyleComputer::compute_defaulted_values(ComputedProperties& style, DOM::Element const* element, Optional pseudo_element) const +void StyleComputer::compute_defaulted_values(ComputedProperties& style, DOM::Element const* element, Optional pseudo_element) const { // Walk the list of all known CSS properties and: // - Add them to `style` if they are missing. @@ -1880,7 +1880,7 @@ CSSPixelFraction StyleComputer::absolute_size_mapping(Keyword keyword) } } -RefPtr StyleComputer::compute_font_for_style_values(DOM::Element const* element, Optional pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth) const +RefPtr StyleComputer::compute_font_for_style_values(DOM::Element const* element, Optional pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth) const { auto* parent_element = element_to_inherit_style_from(element, pseudo_element); @@ -2100,7 +2100,7 @@ RefPtr StyleComputer::compute_font_for_style_values( return font_list; } -void StyleComputer::compute_font(ComputedProperties& style, DOM::Element const* element, Optional pseudo_element) const +void StyleComputer::compute_font(ComputedProperties& style, DOM::Element const* element, Optional pseudo_element) const { // To compute the font, first ensure that we've defaulted the relevant CSS font properties. // FIXME: This should be more sophisticated. @@ -2211,7 +2211,7 @@ void StyleComputer::resolve_effective_overflow_values(ComputedProperties& style) } } -static void compute_text_align(ComputedProperties& style, DOM::Element const& element, Optional pseudo_element) +static void compute_text_align(ComputedProperties& style, DOM::Element const& element, Optional pseudo_element) { // https://drafts.csswg.org/css-text-4/#valdef-text-align-match-parent // This value behaves the same as inherit (computes to its parent’s computed value) except that an inherited @@ -2261,7 +2261,7 @@ enum class BoxTypeTransformation { Inlinify, }; -static BoxTypeTransformation required_box_type_transformation(ComputedProperties const& style, DOM::Element const& element, Optional const& pseudo_element) +static BoxTypeTransformation required_box_type_transformation(ComputedProperties const& style, DOM::Element const& element, Optional const& pseudo_element) { // NOTE: We never blockify
elements. They are always inline. // There is currently no way to express in CSS how a
element really behaves. @@ -2289,7 +2289,7 @@ static BoxTypeTransformation required_box_type_transformation(ComputedProperties } // https://drafts.csswg.org/css-display/#transformations -void StyleComputer::transform_box_type_if_needed(ComputedProperties& style, DOM::Element const& element, Optional pseudo_element) const +void StyleComputer::transform_box_type_if_needed(ComputedProperties& style, DOM::Element const& element, Optional pseudo_element) const { // 2.7. Automatic Box Type Transformations @@ -2391,17 +2391,17 @@ GC::Ref StyleComputer::create_document_style() const return style; } -GC::Ref StyleComputer::compute_style(DOM::Element& element, Optional pseudo_element) const +GC::Ref StyleComputer::compute_style(DOM::Element& element, Optional pseudo_element) const { return *compute_style_impl(element, move(pseudo_element), ComputeStyleMode::Normal); } -GC::Ptr StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional pseudo_element) const +GC::Ptr StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional pseudo_element) const { return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::CreatePseudoElementStyleIfNeeded); } -GC::Ptr StyleComputer::compute_style_impl(DOM::Element& element, Optional pseudo_element, ComputeStyleMode mode) const +GC::Ptr StyleComputer::compute_style_impl(DOM::Element& element, Optional pseudo_element, ComputeStyleMode mode) const { build_rule_cache_if_needed(); @@ -2451,7 +2451,7 @@ GC::Ptr StyleComputer::compute_style_impl(DOM::Element& elem // NOTE: `normal` is the initial value, so the absence of a value is treated as `normal`. content_is_normal = true; } - if (content_is_normal && first_is_one_of(*pseudo_element, CSS::Selector::PseudoElement::Type::Before, CSS::Selector::PseudoElement::Type::After)) { + if (content_is_normal && first_is_one_of(*pseudo_element, CSS::PseudoElement::Before, CSS::PseudoElement::After)) { return {}; } } @@ -2483,7 +2483,7 @@ static bool is_monospace(CSSStyleValue const& value) // https://manishearth.github.io/blog/2017/08/10/font-size-an-unexpectedly-complex-css-property/ RefPtr StyleComputer::recascade_font_size_if_needed( DOM::Element& element, - Optional pseudo_element, + Optional pseudo_element, CascadedProperties& cascaded_properties) const { // Check for `font-family: monospace`. Note that `font-family: monospace, AnythingElse` does not trigger this path. @@ -2545,7 +2545,7 @@ RefPtr StyleComputer::recascade_font_size_if_needed( return CSS::LengthStyleValue::create(CSS::Length::make_px(current_size_in_px)); } -GC::Ref StyleComputer::compute_properties(DOM::Element& element, Optional pseudo_element, CascadedProperties& cascaded_properties) const +GC::Ref StyleComputer::compute_properties(DOM::Element& element, Optional pseudo_element, CascadedProperties& cascaded_properties) const { auto computed_style = document().heap().allocate(); @@ -2620,7 +2620,7 @@ GC::Ref StyleComputer::compute_properties(DOM::Element& elem animation->set_effect(effect); apply_animation_properties(m_document, cascaded_properties, animation); if (pseudo_element.has_value()) - effect->set_pseudo_element(Selector::PseudoElement { pseudo_element.value() }); + effect->set_pseudo_element(Selector::PseudoElementSelector { pseudo_element.value() }); if (auto* rule_cache = rule_cache_for_cascade_origin(CascadeOrigin::Author, {}, {})) { if (auto keyframe_set = rule_cache->rules_by_animation_keyframes.get(animation->id()); keyframe_set.has_value()) @@ -2811,7 +2811,7 @@ void StyleComputer::make_rule_cache_for_cascade_origin(CascadeOrigin cascade_ori auto& rule_cache = qualified_layer_name.is_empty() ? rule_caches.main : *rule_caches.by_layer.ensure(qualified_layer_name, [] { return make(); }); bool contains_root_pseudo_class = false; - Optional pseudo_element; + Optional pseudo_element; collect_selector_insights(selector, insights); @@ -3072,7 +3072,7 @@ void StyleComputer::unload_fonts_from_sheet(CSSStyleSheet& sheet) } } -void StyleComputer::compute_math_depth(ComputedProperties& style, DOM::Element const* element, Optional pseudo_element) const +void StyleComputer::compute_math_depth(ComputedProperties& style, DOM::Element const* element, Optional pseudo_element) const { // https://w3c.github.io/mathml-core/#propdef-math-depth @@ -3183,7 +3183,7 @@ bool StyleComputer::have_has_selectors() const return m_selector_insights->has_has_selectors; } -void RuleCache::add_rule(MatchingRule const& matching_rule, Optional pseudo_element, bool contains_root_pseudo_class) +void RuleCache::add_rule(MatchingRule const& matching_rule, Optional pseudo_element, bool contains_root_pseudo_class) { // NOTE: We traverse the simple selectors in reverse order to make sure that class/ID buckets are preferred over tag buckets // in the common case of div.foo or div#foo selectors. @@ -3230,7 +3230,7 @@ void RuleCache::add_rule(MatchingRule const& matching_rule, Optional pseudo_element, Function const&)> callback) const +void RuleCache::for_each_matching_rules(DOM::Element const& element, Optional pseudo_element, Function const&)> callback) const { for (auto const& class_name : element.class_names()) { if (auto it = rules_by_class.find(class_name); it != rules_by_class.end()) { @@ -3267,7 +3267,7 @@ void RuleCache::for_each_matching_rules(DOM::Element const& element, Optional> rules_by_class; HashMap> rules_by_tag_name; HashMap, AK::ASCIICaseInsensitiveFlyStringTraits> rules_by_attribute_name; - Array, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount)> rules_by_pseudo_element; + Array, to_underlying(CSS::PseudoElement::KnownPseudoElementCount)> rules_by_pseudo_element; Vector root_rules; Vector other_rules; HashMap> rules_by_animation_keyframes; - void add_rule(MatchingRule const&, Optional, bool contains_root_pseudo_class); - void for_each_matching_rules(DOM::Element const&, Optional, Function const&)> callback) const; + void add_rule(MatchingRule const&, Optional, bool contains_root_pseudo_class); + void for_each_matching_rules(DOM::Element const&, Optional, Function const&)> callback) const; }; class FontLoader; @@ -142,7 +142,7 @@ public: CascadeOrigin, Important, Optional layer_name); - static NonnullRefPtr get_inherit_value(CSS::PropertyID, DOM::Element const*, Optional = {}); + static NonnullRefPtr get_inherit_value(CSS::PropertyID, DOM::Element const*, Optional = {}); static Optional user_agent_style_sheet_source(StringView name); @@ -158,11 +158,11 @@ public: [[nodiscard]] GC::Ref create_document_style() const; - [[nodiscard]] GC::Ref compute_style(DOM::Element&, Optional = {}) const; - [[nodiscard]] GC::Ptr compute_pseudo_element_style_if_needed(DOM::Element&, Optional) const; + [[nodiscard]] GC::Ref compute_style(DOM::Element&, Optional = {}) const; + [[nodiscard]] GC::Ptr compute_pseudo_element_style_if_needed(DOM::Element&, Optional) const; RuleCache const& get_hover_rules() const; - [[nodiscard]] Vector collect_matching_rules(DOM::Element const&, CascadeOrigin, Optional, bool& did_match_any_hover_rules, FlyString const& qualified_layer_name = {}) const; + [[nodiscard]] Vector collect_matching_rules(DOM::Element const&, CascadeOrigin, Optional, bool& did_match_any_hover_rules, FlyString const& qualified_layer_name = {}) const; InvalidationSet invalidation_set_for_properties(Vector const&) const; bool invalidation_property_used_in_has_selector(InvalidationSet::Property const&) const; @@ -181,9 +181,9 @@ public: static CSSPixels default_user_font_size(); static CSSPixelFraction absolute_size_mapping(Keyword); - RefPtr compute_font_for_style_values(DOM::Element const* element, Optional pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth = 0) const; + RefPtr compute_font_for_style_values(DOM::Element const* element, Optional pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth = 0) const; - [[nodiscard]] RefPtr recascade_font_size_if_needed(DOM::Element&, Optional pseudo_element, CascadedProperties&) const; + [[nodiscard]] RefPtr recascade_font_size_if_needed(DOM::Element&, Optional pseudo_element, CascadedProperties&) const; void set_viewport_rect(Badge, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; } @@ -191,17 +191,17 @@ public: No, Yes, }; - void collect_animation_into(DOM::Element&, Optional, GC::Ref animation, ComputedProperties&, AnimationRefresh = AnimationRefresh::No) const; + void collect_animation_into(DOM::Element&, Optional, GC::Ref animation, ComputedProperties&, AnimationRefresh = AnimationRefresh::No) const; [[nodiscard]] bool may_have_has_selectors() const; [[nodiscard]] bool have_has_selectors() const; size_t number_of_css_font_faces_with_loading_in_progress() const; - [[nodiscard]] GC::Ref compute_properties(DOM::Element&, Optional, CascadedProperties&) const; + [[nodiscard]] GC::Ref compute_properties(DOM::Element&, Optional, CascadedProperties&) const; void absolutize_values(ComputedProperties&, GC::Ptr) const; - void compute_font(ComputedProperties&, DOM::Element const*, Optional) const; + void compute_font(ComputedProperties&, DOM::Element const*, Optional) const; [[nodiscard]] inline bool should_reject_with_ancestor_filter(Selector const&) const; @@ -213,23 +213,23 @@ private: struct MatchingFontCandidate; - [[nodiscard]] GC::Ptr compute_style_impl(DOM::Element&, Optional, ComputeStyleMode) const; - [[nodiscard]] GC::Ref compute_cascaded_values(DOM::Element&, Optional, bool& did_match_any_pseudo_element_rules, bool& did_match_any_hover_rules, ComputeStyleMode) const; + [[nodiscard]] GC::Ptr compute_style_impl(DOM::Element&, Optional, ComputeStyleMode) const; + [[nodiscard]] GC::Ref compute_cascaded_values(DOM::Element&, Optional, bool& did_match_any_pseudo_element_rules, bool& did_match_any_hover_rules, ComputeStyleMode) const; static RefPtr find_matching_font_weight_ascending(Vector const& candidates, int target_weight, float font_size_in_pt, bool inclusive); static RefPtr find_matching_font_weight_descending(Vector const& candidates, int target_weight, float font_size_in_pt, bool inclusive); RefPtr font_matching_algorithm(FlyString const& family_name, int weight, int slope, float font_size_in_pt) const; - void compute_math_depth(ComputedProperties&, DOM::Element const*, Optional) const; - void compute_defaulted_values(ComputedProperties&, DOM::Element const*, Optional) const; - void start_needed_transitions(ComputedProperties const& old_style, ComputedProperties& new_style, DOM::Element&, Optional) const; + void compute_math_depth(ComputedProperties&, DOM::Element const*, Optional) const; + void compute_defaulted_values(ComputedProperties&, DOM::Element const*, Optional) const; + void start_needed_transitions(ComputedProperties const& old_style, ComputedProperties& new_style, DOM::Element&, Optional) const; void resolve_effective_overflow_values(ComputedProperties&) const; - void transform_box_type_if_needed(ComputedProperties&, DOM::Element const&, Optional) const; + void transform_box_type_if_needed(ComputedProperties&, DOM::Element const&, Optional) const; - void compute_defaulted_property_value(ComputedProperties&, DOM::Element const*, CSS::PropertyID, Optional) const; + void compute_defaulted_property_value(ComputedProperties&, DOM::Element const*, CSS::PropertyID, Optional) const; void set_all_properties( CascadedProperties&, DOM::Element&, - Optional, + Optional, CSSStyleValue const&, DOM::Document&, GC::Ptr, @@ -261,7 +261,7 @@ private: void cascade_declarations( CascadedProperties&, DOM::Element&, - Optional, + Optional, Vector const&, CascadeOrigin, Important, diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index bf170ec5784..9d6f8659018 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -1685,7 +1685,7 @@ void Document::set_inspected_node(GC::Ptr node) m_inspected_node = node; } -void Document::set_highlighted_node(GC::Ptr node, Optional pseudo_element) +void Document::set_highlighted_node(GC::Ptr node, Optional pseudo_element) { if (m_highlighted_node == node && m_highlighted_pseudo_element == pseudo_element) return; @@ -1797,12 +1797,12 @@ void Document::invalidate_style_for_elements_affected_by_hover_change(Node& old_ SelectorEngine::MatchContext context; if (SelectorEngine::matches(selector, element, {}, context, {})) return true; - if (element.has_pseudo_element(CSS::Selector::PseudoElement::Type::Before)) { - if (SelectorEngine::matches(selector, element, {}, context, CSS::Selector::PseudoElement::Type::Before)) + if (element.has_pseudo_element(CSS::PseudoElement::Before)) { + if (SelectorEngine::matches(selector, element, {}, context, CSS::PseudoElement::Before)) return true; } - if (element.has_pseudo_element(CSS::Selector::PseudoElement::Type::After)) { - if (SelectorEngine::matches(selector, element, {}, context, CSS::Selector::PseudoElement::Type::After)) + if (element.has_pseudo_element(CSS::PseudoElement::After)) { + if (SelectorEngine::matches(selector, element, {}, context, CSS::PseudoElement::After)) return true; } return false; diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 3227961a75c..dbce147a627 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -265,7 +265,7 @@ public: void set_inspected_node(GC::Ptr); GC::Ptr inspected_node() const { return m_inspected_node; } - void set_highlighted_node(GC::Ptr, Optional); + void set_highlighted_node(GC::Ptr, Optional); GC::Ptr highlighted_node() const { return m_highlighted_node; } GC::Ptr highlighted_layout_node(); GC::Ptr highlighted_layout_node() const { return const_cast(this)->highlighted_layout_node(); } @@ -963,7 +963,7 @@ private: GC::Ptr m_hovered_node; GC::Ptr m_inspected_node; GC::Ptr m_highlighted_node; - Optional m_highlighted_pseudo_element; + Optional m_highlighted_pseudo_element; Optional m_normal_link_color; Optional m_active_link_color; diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 623aabffe5e..bf9bd43fb94 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -547,7 +547,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() } // Any document change that can cause this element's style to change, could also affect its pseudo-elements. - auto recompute_pseudo_element_style = [&](CSS::Selector::PseudoElement::Type pseudo_element) { + auto recompute_pseudo_element_style = [&](CSS::PseudoElement pseudo_element) { style_computer.push_ancestor(*this); auto pseudo_element_style = pseudo_element_computed_properties(pseudo_element); @@ -564,10 +564,10 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() style_computer.pop_ancestor(*this); }; - recompute_pseudo_element_style(CSS::Selector::PseudoElement::Type::Before); - recompute_pseudo_element_style(CSS::Selector::PseudoElement::Type::After); + recompute_pseudo_element_style(CSS::PseudoElement::Before); + recompute_pseudo_element_style(CSS::PseudoElement::After); if (had_list_marker || m_computed_properties->display().is_list_item()) - recompute_pseudo_element_style(CSS::Selector::PseudoElement::Type::Marker); + recompute_pseudo_element_style(CSS::PseudoElement::Marker); if (invalidation.is_none()) return invalidation; @@ -582,8 +582,8 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() paintable()->set_needs_display(); // Do the same for pseudo-elements. - for (auto i = 0; i < to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount); i++) { - auto pseudo_element_type = static_cast(i); + for (auto i = 0; i < to_underlying(CSS::PseudoElement::KnownPseudoElementCount); i++) { + auto pseudo_element_type = static_cast(i); auto pseudo_element = get_pseudo_element(pseudo_element_type); if (!pseudo_element.has_value() || !pseudo_element->layout_node) continue; @@ -647,7 +647,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_inherited_style() return invalidation; } -GC::Ref Element::resolved_css_values(Optional type) +GC::Ref Element::resolved_css_values(Optional type) { auto element_computed_style = CSS::CSSStyleProperties::create_resolved_style({ *this, type }); auto properties = heap().allocate(); @@ -1180,20 +1180,20 @@ void Element::children_changed(ChildrenChangedMetadata const* metadata) set_needs_style_update(true); } -void Element::set_pseudo_element_node(Badge, CSS::Selector::PseudoElement::Type pseudo_element, GC::Ptr pseudo_element_node) +void Element::set_pseudo_element_node(Badge, CSS::PseudoElement pseudo_element, GC::Ptr pseudo_element_node) { auto existing_pseudo_element = get_pseudo_element(pseudo_element); if (!existing_pseudo_element.has_value() && !pseudo_element_node) return; - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element)) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element)) { return; } ensure_pseudo_element(pseudo_element).layout_node = move(pseudo_element_node); } -GC::Ptr Element::get_pseudo_element_node(CSS::Selector::PseudoElement::Type pseudo_element) const +GC::Ptr Element::get_pseudo_element_node(CSS::PseudoElement pseudo_element) const { if (auto element_data = get_pseudo_element(pseudo_element); element_data.has_value()) return element_data->layout_node; @@ -1401,7 +1401,7 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer(i)))))); + MUST(object.add("name"sv, MUST(String::formatted("::{}", CSS::Selector::PseudoElementSelector::name(static_cast(i)))))); MUST(object.add("type"sv, "pseudo-element")); MUST(object.add("parent-id"sv, unique_id().value())); MUST(object.add("pseudo-element"sv, i)); @@ -2661,7 +2661,7 @@ size_t Element::attribute_list_size() const return m_attributes->length(); } -GC::Ptr Element::cascaded_properties(Optional pseudo_element) const +GC::Ptr Element::cascaded_properties(Optional pseudo_element) const { if (pseudo_element.has_value()) { auto pseudo_element_data = get_pseudo_element(pseudo_element.value()); @@ -2672,10 +2672,10 @@ GC::Ptr Element::cascaded_properties(Optional pseudo_element, GC::Ptr cascaded_properties) +void Element::set_cascaded_properties(Optional pseudo_element, GC::Ptr cascaded_properties) { if (pseudo_element.has_value()) { - if (pseudo_element.value() >= CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + if (pseudo_element.value() >= CSS::PseudoElement::KnownPseudoElementCount) return; ensure_pseudo_element(pseudo_element.value()).cascaded_properties = cascaded_properties; } else { @@ -2689,19 +2689,19 @@ void Element::set_computed_properties(GC::Ptr style) computed_properties_changed(); } -void Element::set_pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type pseudo_element, GC::Ptr style) +void Element::set_pseudo_element_computed_properties(CSS::PseudoElement pseudo_element, GC::Ptr style) { if (!m_pseudo_element_data && !style) return; - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element)) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element)) { return; } ensure_pseudo_element(pseudo_element).computed_properties = style; } -GC::Ptr Element::pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type type) +GC::Ptr Element::pseudo_element_computed_properties(CSS::PseudoElement type) { auto pseudo_element = get_pseudo_element(type); if (pseudo_element.has_value()) @@ -2709,48 +2709,48 @@ GC::Ptr Element::pseudo_element_computed_properties(CSS return {}; } -Optional Element::get_pseudo_element(CSS::Selector::PseudoElement::Type type) const +Optional Element::get_pseudo_element(CSS::PseudoElement type) const { if (!m_pseudo_element_data) return {}; - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(type)) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(type)) { return {}; } return m_pseudo_element_data->at(to_underlying(type)); } -Element::PseudoElement& Element::ensure_pseudo_element(CSS::Selector::PseudoElement::Type type) const +Element::PseudoElement& Element::ensure_pseudo_element(CSS::PseudoElement type) const { if (!m_pseudo_element_data) m_pseudo_element_data = make(); - VERIFY(CSS::Selector::PseudoElement::is_known_pseudo_element_type(type)); + VERIFY(CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(type)); return m_pseudo_element_data->at(to_underlying(type)); } -void Element::set_custom_properties(Optional pseudo_element, HashMap custom_properties) +void Element::set_custom_properties(Optional pseudo_element, HashMap custom_properties) { if (!pseudo_element.has_value()) { m_custom_properties = move(custom_properties); return; } - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) { + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value())) { return; } ensure_pseudo_element(pseudo_element.value()).custom_properties = move(custom_properties); } -HashMap const& Element::custom_properties(Optional pseudo_element) const +HashMap const& Element::custom_properties(Optional pseudo_element) const { if (!pseudo_element.has_value()) return m_custom_properties; - VERIFY(CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())); + VERIFY(CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value())); return ensure_pseudo_element(pseudo_element.value()).custom_properties; } diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index 573a199e1c0..fb4494cb14a 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -192,8 +192,8 @@ public: CSS::RequiredInvalidationAfterStyleChange recompute_style(); CSS::RequiredInvalidationAfterStyleChange recompute_inherited_style(); - Optional use_pseudo_element() const { return m_use_pseudo_element; } - void set_use_pseudo_element(Optional use_pseudo_element) { m_use_pseudo_element = move(use_pseudo_element); } + Optional use_pseudo_element() const { return m_use_pseudo_element; } + void set_use_pseudo_element(Optional use_pseudo_element) { m_use_pseudo_element = move(use_pseudo_element); } GC::Ptr layout_node(); GC::Ptr layout_node() const; @@ -201,13 +201,13 @@ public: GC::Ptr computed_properties() { return m_computed_properties; } GC::Ptr computed_properties() const { return m_computed_properties; } void set_computed_properties(GC::Ptr); - GC::Ref resolved_css_values(Optional = {}); + GC::Ref resolved_css_values(Optional = {}); - [[nodiscard]] GC::Ptr cascaded_properties(Optional) const; - void set_cascaded_properties(Optional, GC::Ptr); + [[nodiscard]] GC::Ptr cascaded_properties(Optional) const; + void set_cascaded_properties(Optional, GC::Ptr); - void set_pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type, GC::Ptr); - GC::Ptr pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type); + void set_pseudo_element_computed_properties(CSS::PseudoElement, GC::Ptr); + GC::Ptr pseudo_element_computed_properties(CSS::PseudoElement); void reset_animated_css_properties(); @@ -242,8 +242,8 @@ public: GC::Ptr shadow_root() const { return m_shadow_root; } void set_shadow_root(GC::Ptr); - void set_custom_properties(Optional, HashMap custom_properties); - [[nodiscard]] HashMap const& custom_properties(Optional) const; + void set_custom_properties(Optional, HashMap custom_properties); + [[nodiscard]] HashMap const& custom_properties(Optional) const; bool style_uses_css_custom_properties() const { return m_style_uses_css_custom_properties; } void set_style_uses_css_custom_properties(bool value) { m_style_uses_css_custom_properties = value; } @@ -271,9 +271,9 @@ public: bool affected_by_hover() const; bool includes_properties_from_invalidation_set(CSS::InvalidationSet const&) const; - void set_pseudo_element_node(Badge, CSS::Selector::PseudoElement::Type, GC::Ptr); - GC::Ptr get_pseudo_element_node(CSS::Selector::PseudoElement::Type) const; - bool has_pseudo_element(CSS::Selector::PseudoElement::Type) const; + void set_pseudo_element_node(Badge, CSS::PseudoElement, GC::Ptr); + GC::Ptr get_pseudo_element_node(CSS::PseudoElement) const; + bool has_pseudo_element(CSS::PseudoElement) const; bool has_pseudo_elements() const; void clear_pseudo_element_nodes(Badge); void serialize_pseudo_elements_as_json(JsonArraySerializer& children_array) const; @@ -516,14 +516,14 @@ private: GC::Ptr computed_properties; HashMap custom_properties; }; - // TODO: CSS::Selector::PseudoElement::Type includes a lot of pseudo-elements that exist in shadow trees, + // TODO: CSS::Selector::PseudoElement includes a lot of pseudo-elements that exist in shadow trees, // and so we don't want to include data for them here. - using PseudoElementData = Array; + using PseudoElementData = Array; mutable OwnPtr m_pseudo_element_data; - Optional get_pseudo_element(CSS::Selector::PseudoElement::Type) const; - PseudoElement& ensure_pseudo_element(CSS::Selector::PseudoElement::Type) const; + Optional get_pseudo_element(CSS::PseudoElement) const; + PseudoElement& ensure_pseudo_element(CSS::PseudoElement) const; - Optional m_use_pseudo_element; + Optional m_use_pseudo_element; Vector m_classes; Optional m_dir; @@ -603,11 +603,11 @@ inline bool Element::has_class(FlyString const& class_name, CaseSensitivity case }); } -inline bool Element::has_pseudo_element(CSS::Selector::PseudoElement::Type type) const +inline bool Element::has_pseudo_element(CSS::PseudoElement type) const { if (!m_pseudo_element_data) return false; - if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(type)) + if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(type)) return false; return m_pseudo_element_data->at(to_underlying(type)).layout_node; } diff --git a/Libraries/LibWeb/DOM/ElementReference.h b/Libraries/LibWeb/DOM/ElementReference.h index d8c23b38f6b..80f656f5da4 100644 --- a/Libraries/LibWeb/DOM/ElementReference.h +++ b/Libraries/LibWeb/DOM/ElementReference.h @@ -14,7 +14,7 @@ namespace Web::DOM { class ElementReference { public: - ElementReference(GC::Ref element, Optional pseudo_element = {}) + ElementReference(GC::Ref element, Optional pseudo_element = {}) : m_element(element) , m_pseudo_element(move(pseudo_element)) { @@ -22,7 +22,7 @@ public: Element& element() { return m_element; } Element const& element() const { return m_element; } - Optional pseudo_element() const { return m_pseudo_element; } + Optional pseudo_element() const { return m_pseudo_element; } void visit(GC::Cell::Visitor& visitor) const { @@ -31,7 +31,7 @@ public: private: GC::Ref m_element; - Optional m_pseudo_element; + Optional m_pseudo_element; }; } diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index d2d9b440814..62d020cea44 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -2750,7 +2750,7 @@ ErrorOr Node::name_or_description(NameOrDescription target, Document con // b. For ::after pseudo elements, User agents MUST append CSS textual content, without a space, to the textual // content of the current node. NOTE: The code for handling the ::after pseudo elements case is further below, // following the “iii. For each child node of the current node” code. - if (auto before = element->get_pseudo_element_node(CSS::Selector::PseudoElement::Type::Before)) { + if (auto before = element->get_pseudo_element_node(CSS::PseudoElement::Before)) { if (before->computed_values().content().alt_text.has_value()) total_accumulated_text.append(before->computed_values().content().alt_text.release_value()); else @@ -2806,7 +2806,7 @@ ErrorOr Node::name_or_description(NameOrDescription target, Document con } // NOTE: See step ii.b above. - if (auto after = element->get_pseudo_element_node(CSS::Selector::PseudoElement::Type::After)) { + if (auto after = element->get_pseudo_element_node(CSS::PseudoElement::After)) { if (after->computed_values().content().alt_text.has_value()) total_accumulated_text.append(after->computed_values().content().alt_text.release_value()); else @@ -2960,8 +2960,8 @@ void Node::play_or_cancel_animations_after_display_property_change() auto const& element = static_cast(node); if (auto animation = element.cached_animation_name_animation({})) play_or_cancel_depending_on_display(*animation); - for (auto i = 0; i < to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount); i++) { - auto pseudo_element = static_cast(i); + for (auto i = 0; i < to_underlying(CSS::PseudoElement::KnownPseudoElementCount); i++) { + auto pseudo_element = static_cast(i); if (auto animation = element.cached_animation_name_animation(pseudo_element)) play_or_cancel_depending_on_display(*animation); } diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index 6a870f1d8c0..ac5b1443cba 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -99,7 +99,7 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node) if (element.use_pseudo_element().has_value()) { for (int i = 0; i < indent; ++i) builder.append(" "sv); - builder.appendff(" (pseudo-element: {})\n", CSS::Selector::PseudoElement::name(element.use_pseudo_element().value())); + builder.appendff(" (pseudo-element: {})\n", CSS::Selector::PseudoElementSelector::name(element.use_pseudo_element().value())); } } else if (is(node)) { builder.appendff("\"{}\"\n", as(node).data()); diff --git a/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index c585bbf01a2..cc0073d1599 100644 --- a/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -243,7 +243,7 @@ WebIDL::ExceptionOr HTMLDetailsElement::create_shadow_tree_if_needed() // The second child element is a slot that is expected to take the details element's remaining descendants, if any. auto descendants_slot = TRY(DOM::create_element(document(), HTML::TagNames::slot, Namespace::HTML)); - descendants_slot->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::DetailsContent); + descendants_slot->set_use_pseudo_element(CSS::PseudoElement::DetailsContent); MUST(shadow_root->append_child(descendants_slot)); // The third child element is either a link or style element with the following styles for the default summary: diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 8031eaf6d64..67788647970 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -1000,7 +1000,7 @@ void HTMLInputElement::create_text_input_shadow_tree() MUST(shadow_root->append_child(element)); m_placeholder_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - m_placeholder_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Placeholder); + m_placeholder_element->set_use_pseudo_element(CSS::PseudoElement::Placeholder); // https://www.w3.org/TR/css-ui-4/#input-rules MUST(m_placeholder_element->set_attribute(HTML::AttributeNames::style, R"~~~( @@ -1137,7 +1137,7 @@ void HTMLInputElement::create_file_input_shadow_tree() auto shadow_root = realm.create(document(), *this, Bindings::ShadowRootMode::Closed); m_file_button = DOM::create_element(document(), HTML::TagNames::button, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); - m_file_button->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::FileSelectorButton); + m_file_button->set_use_pseudo_element(CSS::PseudoElement::FileSelectorButton); m_file_label = DOM::create_element(document(), HTML::TagNames::label, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); MUST(m_file_label->set_attribute(HTML::AttributeNames::style, "padding-left: 4px;"_string)); @@ -1183,15 +1183,15 @@ void HTMLInputElement::create_range_input_shadow_tree() set_shadow_root(shadow_root); m_slider_runnable_track = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - m_slider_runnable_track->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Track); + m_slider_runnable_track->set_use_pseudo_element(CSS::PseudoElement::Track); MUST(shadow_root->append_child(*m_slider_runnable_track)); m_slider_progress_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - m_slider_progress_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Fill); + m_slider_progress_element->set_use_pseudo_element(CSS::PseudoElement::Fill); MUST(m_slider_runnable_track->append_child(*m_slider_progress_element)); m_slider_thumb = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - m_slider_thumb->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Thumb); + m_slider_thumb->set_use_pseudo_element(CSS::PseudoElement::Thumb); MUST(m_slider_runnable_track->append_child(*m_slider_thumb)); update_slider_shadow_tree_elements(); diff --git a/Libraries/LibWeb/HTML/HTMLMeterElement.cpp b/Libraries/LibWeb/HTML/HTMLMeterElement.cpp index 40edeafe877..e1111ba878e 100644 --- a/Libraries/LibWeb/HTML/HTMLMeterElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMeterElement.cpp @@ -197,11 +197,11 @@ void HTMLMeterElement::create_shadow_tree_if_needed() set_shadow_root(shadow_root); auto meter_bar_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - meter_bar_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Track); + meter_bar_element->set_use_pseudo_element(CSS::PseudoElement::Track); MUST(shadow_root->append_child(*meter_bar_element)); m_meter_value_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - m_meter_value_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Fill); + m_meter_value_element->set_use_pseudo_element(CSS::PseudoElement::Fill); MUST(meter_bar_element->append_child(*m_meter_value_element)); update_meter_value_element(); } diff --git a/Libraries/LibWeb/HTML/HTMLProgressElement.cpp b/Libraries/LibWeb/HTML/HTMLProgressElement.cpp index 87201df72b3..325dd034b48 100644 --- a/Libraries/LibWeb/HTML/HTMLProgressElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLProgressElement.cpp @@ -118,11 +118,11 @@ void HTMLProgressElement::create_shadow_tree_if_needed() set_shadow_root(shadow_root); auto progress_bar_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - progress_bar_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Track); + progress_bar_element->set_use_pseudo_element(CSS::PseudoElement::Track); MUST(shadow_root->append_child(*progress_bar_element)); m_progress_value_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - m_progress_value_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Fill); + m_progress_value_element->set_use_pseudo_element(CSS::PseudoElement::Fill); MUST(progress_bar_element->append_child(*m_progress_value_element)); update_progress_value_element(); } diff --git a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index fbc6910d89f..de2816c2a9a 100644 --- a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -372,7 +372,7 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed() MUST(shadow_root->append_child(element)); m_placeholder_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); - m_placeholder_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Placeholder); + m_placeholder_element->set_use_pseudo_element(CSS::PseudoElement::Placeholder); MUST(element->append_child(*m_placeholder_element)); m_placeholder_text_node = realm().create(document(), String {}); diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp index 627298277d5..3b238c86e1f 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -186,7 +186,7 @@ void TreeBuilder::insert_node_into_inline_or_block_ancestor(Layout::Node& node, } } -void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Selector::PseudoElement::Type pseudo_element, AppendOrPrepend mode) +void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::PseudoElement pseudo_element, AppendOrPrepend mode) { auto& document = element.document(); @@ -213,7 +213,7 @@ void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Se // FIXME: This code actually computes style for element::marker, and shouldn't for element::pseudo::marker if (is(*pseudo_element_node)) { - auto marker_style = style_computer.compute_style(element, CSS::Selector::PseudoElement::Type::Marker); + auto marker_style = style_computer.compute_style(element, CSS::PseudoElement::Marker); auto list_item_marker = document.heap().allocate( document, pseudo_element_node->computed_values().list_style_type(), @@ -221,14 +221,14 @@ void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Se element, marker_style); static_cast(*pseudo_element_node).set_marker(list_item_marker); - element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::Type::Marker, list_item_marker); + element.set_pseudo_element_node({}, CSS::PseudoElement::Marker, list_item_marker); pseudo_element_node->append_child(*list_item_marker); } auto generated_for = Node::GeneratedFor::NotGenerated; - if (pseudo_element == CSS::Selector::PseudoElement::Type::Before) { + if (pseudo_element == CSS::PseudoElement::Before) { generated_for = Node::GeneratedFor::PseudoBefore; - } else if (pseudo_element == CSS::Selector::PseudoElement::Type::After) { + } else if (pseudo_element == CSS::PseudoElement::After) { generated_for = Node::GeneratedFor::PseudoAfter; } else { VERIFY_NOT_REACHED(); @@ -694,7 +694,7 @@ void TreeBuilder::update_layout_tree_before_children(DOM::Node& dom_node, GC::Re if (is(dom_node) && layout_node->can_have_children() && !element_has_content_visibility_hidden) { auto& element = static_cast(dom_node); push_parent(as(*layout_node)); - create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Type::Before, AppendOrPrepend::Prepend); + create_pseudo_element_if_needed(element, CSS::PseudoElement::Before, AppendOrPrepend::Prepend); pop_parent(); } } @@ -706,10 +706,10 @@ void TreeBuilder::update_layout_tree_after_children(DOM::Node& dom_node, GC::Ref if (is(*layout_node)) { auto& element = static_cast(dom_node); - auto marker_style = style_computer.compute_style(element, CSS::Selector::PseudoElement::Type::Marker); + auto marker_style = style_computer.compute_style(element, CSS::PseudoElement::Marker); auto list_item_marker = document.heap().allocate(document, layout_node->computed_values().list_style_type(), layout_node->computed_values().list_style_position(), element, marker_style); static_cast(*layout_node).set_marker(list_item_marker); - element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::Type::Marker, list_item_marker); + element.set_pseudo_element_node({}, CSS::PseudoElement::Marker, list_item_marker); layout_node->append_child(*list_item_marker); } @@ -735,7 +735,7 @@ void TreeBuilder::update_layout_tree_after_children(DOM::Node& dom_node, GC::Ref if (is(dom_node) && layout_node->can_have_children() && !element_has_content_visibility_hidden) { auto& element = static_cast(dom_node); push_parent(as(*layout_node)); - create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Type::After, AppendOrPrepend::Append); + create_pseudo_element_if_needed(element, CSS::PseudoElement::After, AppendOrPrepend::Append); pop_parent(); } } diff --git a/Libraries/LibWeb/Layout/TreeBuilder.h b/Libraries/LibWeb/Layout/TreeBuilder.h index 34d6c2ed81f..2d5a5783f20 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.h +++ b/Libraries/LibWeb/Layout/TreeBuilder.h @@ -58,7 +58,7 @@ private: Prepend, }; void insert_node_into_inline_or_block_ancestor(Layout::Node&, CSS::Display, AppendOrPrepend); - void create_pseudo_element_if_needed(DOM::Element&, CSS::Selector::PseudoElement::Type, AppendOrPrepend); + void create_pseudo_element_if_needed(DOM::Element&, CSS::PseudoElement, AppendOrPrepend); void restructure_block_node_in_inline_parent(NodeWithStyleAndBoxModelMetrics&); GC::Ptr m_layout_root; diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp index 3634ec2e910..9119e8e22b1 100644 --- a/Libraries/LibWebView/Application.cpp +++ b/Libraries/LibWebView/Application.cpp @@ -499,7 +499,7 @@ void Application::stop_listening_for_dom_properties(DevTools::TabDescription con view->on_received_dom_node_properties = nullptr; } -void Application::inspect_dom_node(DevTools::TabDescription const& description, DOMNodeProperties::Type property_type, Web::UniqueNodeID node_id, Optional pseudo_element) const +void Application::inspect_dom_node(DevTools::TabDescription const& description, DOMNodeProperties::Type property_type, Web::UniqueNodeID node_id, Optional pseudo_element) const { auto view = ViewImplementation::find_view_by_id(description.id); if (!view.has_value()) @@ -514,7 +514,7 @@ void Application::clear_inspected_dom_node(DevTools::TabDescription const& descr view->clear_inspected_dom_node(); } -void Application::highlight_dom_node(DevTools::TabDescription const& description, Web::UniqueNodeID node_id, Optional pseudo_element) const +void Application::highlight_dom_node(DevTools::TabDescription const& description, Web::UniqueNodeID node_id, Optional pseudo_element) const { if (auto view = ViewImplementation::find_view_by_id(description.id); view.has_value()) view->highlight_dom_node(node_id, pseudo_element); diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.h index 04522eb2572..64d959ead1a 100644 --- a/Libraries/LibWebView/Application.h +++ b/Libraries/LibWebView/Application.h @@ -105,9 +105,9 @@ private: virtual void inspect_tab(DevTools::TabDescription const&, OnTabInspectionComplete) const override; virtual void listen_for_dom_properties(DevTools::TabDescription const&, OnDOMNodePropertiesReceived) const override; virtual void stop_listening_for_dom_properties(DevTools::TabDescription const&) const override; - virtual void inspect_dom_node(DevTools::TabDescription const&, DOMNodeProperties::Type, Web::UniqueNodeID, Optional) const override; + virtual void inspect_dom_node(DevTools::TabDescription const&, DOMNodeProperties::Type, Web::UniqueNodeID, Optional) const override; virtual void clear_inspected_dom_node(DevTools::TabDescription const&) const override; - virtual void highlight_dom_node(DevTools::TabDescription const&, Web::UniqueNodeID, Optional) const override; + virtual void highlight_dom_node(DevTools::TabDescription const&, Web::UniqueNodeID, Optional) const override; virtual void clear_highlighted_dom_node(DevTools::TabDescription const&) const override; virtual void listen_for_dom_mutations(DevTools::TabDescription const&, OnDOMMutationReceived) const override; virtual void stop_listening_for_dom_mutations(DevTools::TabDescription const&) const override; diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cpp index e90c4fd1f22..6d541dc2583 100644 --- a/Libraries/LibWebView/ViewImplementation.cpp +++ b/Libraries/LibWebView/ViewImplementation.cpp @@ -329,7 +329,7 @@ void ViewImplementation::get_hovered_node_id() client().async_get_hovered_node_id(page_id()); } -void ViewImplementation::inspect_dom_node(Web::UniqueNodeID node_id, DOMNodeProperties::Type property_type, Optional pseudo_element) +void ViewImplementation::inspect_dom_node(Web::UniqueNodeID node_id, DOMNodeProperties::Type property_type, Optional pseudo_element) { client().async_inspect_dom_node(page_id(), property_type, node_id, pseudo_element); } @@ -339,7 +339,7 @@ void ViewImplementation::clear_inspected_dom_node() client().async_clear_inspected_dom_node(page_id()); } -void ViewImplementation::highlight_dom_node(Web::UniqueNodeID node_id, Optional pseudo_element) +void ViewImplementation::highlight_dom_node(Web::UniqueNodeID node_id, Optional pseudo_element) { client().async_highlight_dom_node(page_id(), node_id, pseudo_element); } diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.h index 3c58e1979f0..c213093762e 100644 --- a/Libraries/LibWebView/ViewImplementation.h +++ b/Libraries/LibWebView/ViewImplementation.h @@ -99,10 +99,10 @@ public: void inspect_accessibility_tree(); void get_hovered_node_id(); - void inspect_dom_node(Web::UniqueNodeID node_id, DOMNodeProperties::Type, Optional pseudo_element); + void inspect_dom_node(Web::UniqueNodeID node_id, DOMNodeProperties::Type, Optional pseudo_element); void clear_inspected_dom_node(); - void highlight_dom_node(Web::UniqueNodeID node_id, Optional pseudo_element); + void highlight_dom_node(Web::UniqueNodeID node_id, Optional pseudo_element); void clear_highlighted_dom_node(); void set_listen_for_dom_mutations(bool); diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp index 8c9638e2fcf..4feb100e23a 100644 --- a/Services/WebContent/ConnectionFromClient.cpp +++ b/Services/WebContent/ConnectionFromClient.cpp @@ -438,7 +438,7 @@ void ConnectionFromClient::inspect_dom_tree(u64 page_id) } } -void ConnectionFromClient::inspect_dom_node(u64 page_id, WebView::DOMNodeProperties::Type property_type, Web::UniqueNodeID node_id, Optional pseudo_element) +void ConnectionFromClient::inspect_dom_node(u64 page_id, WebView::DOMNodeProperties::Type property_type, Web::UniqueNodeID node_id, Optional pseudo_element) { auto page = this->page(page_id); if (!page.has_value()) @@ -565,7 +565,7 @@ void ConnectionFromClient::clear_inspected_dom_node(u64 page_id) } } -void ConnectionFromClient::highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional pseudo_element) +void ConnectionFromClient::highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional pseudo_element) { auto page = this->page(page_id); if (!page.has_value()) diff --git a/Services/WebContent/ConnectionFromClient.h b/Services/WebContent/ConnectionFromClient.h index 3e6d8c55890..edc083edb89 100644 --- a/Services/WebContent/ConnectionFromClient.h +++ b/Services/WebContent/ConnectionFromClient.h @@ -76,9 +76,9 @@ private: virtual void debug_request(u64 page_id, ByteString, ByteString) override; virtual void get_source(u64 page_id) override; virtual void inspect_dom_tree(u64 page_id) override; - virtual void inspect_dom_node(u64 page_id, WebView::DOMNodeProperties::Type, Web::UniqueNodeID node_id, Optional pseudo_element) override; + virtual void inspect_dom_node(u64 page_id, WebView::DOMNodeProperties::Type, Web::UniqueNodeID node_id, Optional pseudo_element) override; virtual void clear_inspected_dom_node(u64 page_id) override; - virtual void highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional pseudo_element) override; + virtual void highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional pseudo_element) override; virtual void inspect_accessibility_tree(u64 page_id) override; virtual void get_hovered_node_id(u64 page_id) override; diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipc index bc40bc2f4d5..ee34cacd306 100644 --- a/Services/WebContent/WebContentServer.ipc +++ b/Services/WebContent/WebContentServer.ipc @@ -45,9 +45,9 @@ endpoint WebContentServer debug_request(u64 page_id, ByteString request, ByteString argument) =| get_source(u64 page_id) =| inspect_dom_tree(u64 page_id) =| - inspect_dom_node(u64 page_id, WebView::DOMNodeProperties::Type property_type, Web::UniqueNodeID node_id, Optional pseudo_element) =| + inspect_dom_node(u64 page_id, WebView::DOMNodeProperties::Type property_type, Web::UniqueNodeID node_id, Optional pseudo_element) =| clear_inspected_dom_node(u64 page_id) =| - highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional pseudo_element) =| + highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional pseudo_element) =| inspect_accessibility_tree(u64 page_id) =| get_hovered_node_id(u64 page_id) =|