diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-11-30 18:27:26 -0500 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-12-01 11:18:11 -0500 |
commit | fddbc2e3788797d62caf21f78868412d3ab4ad0b (patch) | |
tree | 314eaf9a8396c5c066eecf151751a272c25376f6 | |
parent | c21e9a415de17d97584ba4803ade6a9e077eb65b (diff) | |
download | serenity-fddbc2e3788797d62caf21f78868412d3ab4ad0b.zip |
LibWeb: Ensure the number of pseudo elements stays up-to-date
The ::placeholder pseudo element was added in commit 1fbad9c, but the
total number of pseudo elements was not updated. Instead of this manual
bookkeeping, add a dummy value at the end of the enumeration for the
count.
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Selector.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Dump.cpp | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h index 81f65191f5..7f8ab37af0 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.h +++ b/Userland/Libraries/LibWeb/CSS/Selector.h @@ -29,8 +29,10 @@ public: ProgressValue, ProgressBar, Placeholder, + + // Keep this last. + PseudoElementCount, }; - static auto constexpr PseudoElementCount = to_underlying(PseudoElement::ProgressBar) + 1; struct SimpleSelector { enum class Type { @@ -227,6 +229,8 @@ constexpr StringView pseudo_element_name(Selector::PseudoElement pseudo_element) return "-webkit-progress-value"sv; case Selector::PseudoElement::Placeholder: return "placeholder"sv; + case Selector::PseudoElement::PseudoElementCount: + break; } VERIFY_NOT_REACHED(); } diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index e54e89de5a..93c91cf6d6 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -206,7 +206,7 @@ private: Vector<FlyString> m_classes; - Array<JS::GCPtr<Layout::Node>, CSS::Selector::PseudoElementCount> m_pseudo_element_nodes; + Array<JS::GCPtr<Layout::Node>, to_underlying(CSS::Selector::PseudoElement::PseudoElementCount)> m_pseudo_element_nodes; }; template<> diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index 08d4e6fb6d..4bd99992dc 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -508,6 +508,9 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector) case CSS::Selector::PseudoElement::Placeholder: pseudo_element_description = "placeholder"; break; + case CSS::Selector::PseudoElement::PseudoElementCount: + VERIFY_NOT_REACHED(); + break; } builder.appendff(" pseudo_element={}", pseudo_element_description); |