diff options
author | Sam Atkins <atkinssj@gmail.com> | 2021-07-12 14:13:29 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-14 13:31:00 +0200 |
commit | dadcb4634430d6e963e53dc8465261fad87470ee (patch) | |
tree | 22c0da2af39386edc8d44d7b5b754ee0dce1ceed /Userland/Libraries/LibWeb/CSS | |
parent | cd55b817cfa776f002d21c2acdd26f2412e94fa0 (diff) | |
download | serenity-dadcb4634430d6e963e53dc8465261fad87470ee.zip |
LibWeb: Convert CSS Dump, Selector, & SelectorEngine to east const
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Selector.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Selector.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/SelectorEngine.h | 2 |
4 files changed, 16 insertions, 16 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.cpp b/Userland/Libraries/LibWeb/CSS/Selector.cpp index 1ddd9de306..896534daf4 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.cpp +++ b/Userland/Libraries/LibWeb/CSS/Selector.cpp @@ -47,7 +47,7 @@ u32 Selector::specificity() const return ids * 0x10000 + classes * 0x100 + tag_names; } -Selector::SimpleSelector::NthChildPattern Selector::SimpleSelector::NthChildPattern::parse(const StringView& args) +Selector::SimpleSelector::NthChildPattern Selector::SimpleSelector::NthChildPattern::parse(StringView const& args) { CSS::Selector::SimpleSelector::NthChildPattern pattern; if (args.equals_ignoring_case("odd")) { @@ -56,7 +56,7 @@ Selector::SimpleSelector::NthChildPattern Selector::SimpleSelector::NthChildPatt } else if (args.equals_ignoring_case("even")) { pattern.step_size = 2; } else { - const auto consume_int = [](GenericLexer& lexer) -> Optional<int> { + auto const consume_int = [](GenericLexer& lexer) -> Optional<int> { return AK::StringUtils::convert_to_int(lexer.consume_while([](char c) -> bool { return isdigit(c) || c == '+' || c == '-'; })); @@ -81,7 +81,7 @@ Selector::SimpleSelector::NthChildPattern Selector::SimpleSelector::NthChildPatt step_size_or_offset = -1; lexer.retreat(); } else { - const auto value = consume_int(lexer); + auto const value = consume_int(lexer); if (!value.has_value()) return {}; step_size_or_offset = value.value(); @@ -90,12 +90,12 @@ Selector::SimpleSelector::NthChildPattern Selector::SimpleSelector::NthChildPatt if (lexer.consume_specific("n")) { lexer.ignore_while(isspace); if (lexer.next_is('+') || lexer.next_is('-')) { - const auto sign = lexer.next_is('+') ? 1 : -1; + auto const sign = lexer.next_is('+') ? 1 : -1; lexer.ignore(); lexer.ignore_while(isspace); // "An+B" pattern - const auto offset = consume_int(lexer); + auto const offset = consume_int(lexer); if (!offset.has_value()) return {}; pattern.step_size = step_size_or_offset; diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h index 2e724307f9..7bed123dd0 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.h +++ b/Userland/Libraries/LibWeb/CSS/Selector.h @@ -75,7 +75,7 @@ public: int step_size = 0; int offset = 0; - static NthChildPattern parse(const StringView& args); + static NthChildPattern parse(StringView const& args); }; // FIXME: We don't need this field on every single SimpleSelector, but it's also annoying to malloc it somewhere. @@ -103,7 +103,7 @@ public: explicit Selector(Vector<ComplexSelector>&&); ~Selector(); - const Vector<ComplexSelector>& complex_selectors() const { return m_complex_selectors; } + Vector<ComplexSelector> const& complex_selectors() const { return m_complex_selectors; } u32 specificity() const; diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index 141e426adf..364a405959 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -14,7 +14,7 @@ namespace Web::SelectorEngine { -static bool matches_hover_pseudo_class(const DOM::Element& element) +static bool matches_hover_pseudo_class(DOM::Element const& element) { auto* hovered_node = element.document().hovered_node(); if (!hovered_node) @@ -24,7 +24,7 @@ static bool matches_hover_pseudo_class(const DOM::Element& element) return element.is_ancestor_of(*hovered_node); } -static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::Element& element) +static bool matches(CSS::Selector::SimpleSelector const& component, DOM::Element const& element) { switch (component.pseudo_element) { case CSS::Selector::SimpleSelector::PseudoElement::None: @@ -119,12 +119,12 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E } case CSS::Selector::SimpleSelector::PseudoClass::NthChild: case CSS::Selector::SimpleSelector::PseudoClass::NthLastChild: - const auto step_size = component.nth_child_pattern.step_size; - const auto offset = component.nth_child_pattern.offset; + auto const step_size = component.nth_child_pattern.step_size; + auto const offset = component.nth_child_pattern.offset; if (step_size == 0 && offset == 0) return false; // "If both a and b are equal to zero, the pseudo-class represents no element in the document tree." - const auto* parent = element.parent_element(); + auto const* parent = element.parent_element(); if (!parent) return false; @@ -152,7 +152,7 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E } // Like "a % b", but handles negative integers correctly. - const auto canonical_modulo = [](int a, int b) -> int { + auto const canonical_modulo = [](int a, int b) -> int { int c = a % b; if ((c < 0 && b > 0) || (c > 0 && b < 0)) { c += b; @@ -218,7 +218,7 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E } } -static bool matches(const CSS::Selector& selector, int component_list_index, const DOM::Element& element) +static bool matches(CSS::Selector const& selector, int component_list_index, DOM::Element const& element) { auto& component_list = selector.complex_selectors()[component_list_index]; for (auto& component : component_list.compound_selector) { @@ -260,7 +260,7 @@ static bool matches(const CSS::Selector& selector, int component_list_index, con VERIFY_NOT_REACHED(); } -bool matches(const CSS::Selector& selector, const DOM::Element& element) +bool matches(CSS::Selector const& selector, DOM::Element const& element) { VERIFY(!selector.complex_selectors().is_empty()); return matches(selector, selector.complex_selectors().size() - 1, element); diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.h b/Userland/Libraries/LibWeb/CSS/SelectorEngine.h index 1035fb6dc2..42e13855a5 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.h +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.h @@ -11,6 +11,6 @@ namespace Web::SelectorEngine { -bool matches(const CSS::Selector&, const DOM::Element&); +bool matches(CSS::Selector const&, DOM::Element const&); } |