summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-02-24 15:13:20 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-25 19:35:34 +0100
commitcaef4ec15760ee06322aa2a03ab1968cfe01f750 (patch)
tree949bfd5775b50f1834ba9b0eb62ed4eea65d6d92 /Userland
parent5390e058511b0fafa1c087d015a8b30830a6c88e (diff)
downloadserenity-caef4ec15760ee06322aa2a03ab1968cfe01f750.zip
LibWeb: Move PseudoElement enum up a level
This in preparation for changing how we store these, plus it's unwieldy having to type CSS::Selector::SimpleSelector::PseudoElement.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp16
-rw-r--r--Userland/Libraries/LibWeb/CSS/Selector.cpp12
-rw-r--r--Userland/Libraries/LibWeb/CSS/Selector.h18
-rw-r--r--Userland/Libraries/LibWeb/Dump.cpp10
4 files changed, 28 insertions, 28 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index a55787c6d0..8dd64dd342 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -497,13 +497,13 @@ Result<Selector::SimpleSelector, Parser::ParsingResult> Parser::parse_simple_sel
return ParsingResult::IncludesIgnoredVendorPrefix;
if (pseudo_name.equals_ignoring_case("after")) {
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::After;
+ simple_selector.pseudo_element = Selector::PseudoElement::After;
} else if (pseudo_name.equals_ignoring_case("before")) {
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::Before;
+ simple_selector.pseudo_element = Selector::PseudoElement::Before;
} else if (pseudo_name.equals_ignoring_case("first-letter")) {
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::FirstLetter;
+ simple_selector.pseudo_element = Selector::PseudoElement::FirstLetter;
} else if (pseudo_name.equals_ignoring_case("first-line")) {
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::FirstLine;
+ simple_selector.pseudo_element = Selector::PseudoElement::FirstLine;
} else {
dbgln_if(CSS_PARSER_DEBUG, "Unrecognized pseudo-element: '::{}'", pseudo_name);
return ParsingResult::SyntaxError;
@@ -561,19 +561,19 @@ Result<Selector::SimpleSelector, Parser::ParsingResult> Parser::parse_simple_sel
} else if (pseudo_name.equals_ignoring_case("after")) {
// Single-colon syntax allowed for compatibility. https://www.w3.org/TR/selectors/#pseudo-element-syntax
simple_selector.type = Selector::SimpleSelector::Type::PseudoElement;
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::After;
+ simple_selector.pseudo_element = Selector::PseudoElement::After;
} else if (pseudo_name.equals_ignoring_case("before")) {
// See :after
simple_selector.type = Selector::SimpleSelector::Type::PseudoElement;
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::Before;
+ simple_selector.pseudo_element = Selector::PseudoElement::Before;
} else if (pseudo_name.equals_ignoring_case("first-letter")) {
// See :after
simple_selector.type = Selector::SimpleSelector::Type::PseudoElement;
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::FirstLetter;
+ simple_selector.pseudo_element = Selector::PseudoElement::FirstLetter;
} else if (pseudo_name.equals_ignoring_case("first-line")) {
// See :after
simple_selector.type = Selector::SimpleSelector::Type::PseudoElement;
- simple_selector.pseudo_element = Selector::SimpleSelector::PseudoElement::FirstLine;
+ simple_selector.pseudo_element = Selector::PseudoElement::FirstLine;
} else {
dbgln_if(CSS_PARSER_DEBUG, "Unrecognized pseudo-class: ':{}'", pseudo_name);
return ParsingResult::SyntaxError;
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.cpp b/Userland/Libraries/LibWeb/CSS/Selector.cpp
index 6b9e27d2f9..6b8e495370 100644
--- a/Userland/Libraries/LibWeb/CSS/Selector.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Selector.cpp
@@ -240,18 +240,18 @@ String serialize_a_group_of_selectors(NonnullRefPtrVector<Selector> const& selec
return builder.to_string();
}
-constexpr StringView pseudo_element_name(Selector::SimpleSelector::PseudoElement pseudo_element)
+constexpr StringView pseudo_element_name(Selector::PseudoElement pseudo_element)
{
switch (pseudo_element) {
- case Selector::SimpleSelector::PseudoElement::Before:
+ case Selector::PseudoElement::Before:
return "before"sv;
- case Selector::SimpleSelector::PseudoElement::After:
+ case Selector::PseudoElement::After:
return "after"sv;
- case Selector::SimpleSelector::PseudoElement::FirstLine:
+ case Selector::PseudoElement::FirstLine:
return "first-line"sv;
- case Selector::SimpleSelector::PseudoElement::FirstLetter:
+ case Selector::PseudoElement::FirstLetter:
return "first-letter"sv;
- case Selector::SimpleSelector::PseudoElement::None:
+ case Selector::PseudoElement::None:
break;
}
VERIFY_NOT_REACHED();
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h
index ce5b7dc109..29112dfed2 100644
--- a/Userland/Libraries/LibWeb/CSS/Selector.h
+++ b/Userland/Libraries/LibWeb/CSS/Selector.h
@@ -20,6 +20,14 @@ using SelectorList = NonnullRefPtrVector<class Selector>;
// This is a <complex-selector> in the spec. https://www.w3.org/TR/selectors-4/#complex
class Selector : public RefCounted<Selector> {
public:
+ enum class PseudoElement {
+ None,
+ Before,
+ After,
+ FirstLine,
+ FirstLetter,
+ };
+
struct SimpleSelector {
enum class Type {
Invalid,
@@ -75,14 +83,6 @@ public:
SelectorList not_selector {};
};
PseudoClass pseudo_class {};
-
- enum class PseudoElement {
- None,
- Before,
- After,
- FirstLine,
- FirstLetter,
- };
PseudoElement pseudo_element { PseudoElement::None };
FlyString value {};
@@ -142,7 +142,7 @@ private:
mutable Optional<u32> m_specificity;
};
-constexpr StringView pseudo_element_name(Selector::SimpleSelector::PseudoElement);
+constexpr StringView pseudo_element_name(Selector::PseudoElement);
constexpr StringView pseudo_class_name(Selector::SimpleSelector::PseudoClass::Type);
String serialize_a_group_of_selectors(NonnullRefPtrVector<Selector> const& selectors);
diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp
index cee57d23d4..59499440af 100644
--- a/Userland/Libraries/LibWeb/Dump.cpp
+++ b/Userland/Libraries/LibWeb/Dump.cpp
@@ -438,19 +438,19 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector)
if (simple_selector.type == CSS::Selector::SimpleSelector::Type::PseudoElement) {
char const* pseudo_element_description = "";
switch (simple_selector.pseudo_element) {
- case CSS::Selector::SimpleSelector::PseudoElement::None:
+ case CSS::Selector::PseudoElement::None:
pseudo_element_description = "NONE";
break;
- case CSS::Selector::SimpleSelector::PseudoElement::Before:
+ case CSS::Selector::PseudoElement::Before:
pseudo_element_description = "before";
break;
- case CSS::Selector::SimpleSelector::PseudoElement::After:
+ case CSS::Selector::PseudoElement::After:
pseudo_element_description = "after";
break;
- case CSS::Selector::SimpleSelector::PseudoElement::FirstLine:
+ case CSS::Selector::PseudoElement::FirstLine:
pseudo_element_description = "first-line";
break;
- case CSS::Selector::SimpleSelector::PseudoElement::FirstLetter:
+ case CSS::Selector::PseudoElement::FirstLetter:
pseudo_element_description = "first-letter";
break;
}