summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-10-14 15:42:59 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-16 15:16:27 +0100
commit5c1427f3e04d83e41e2007ec8d0dd953455db5bc (patch)
treede0b5630d0df49313d89c03560660c0a2f5e9c09 /Userland/Libraries/LibWeb/CSS
parent4d555e8b95010084a105baba1e5fcd12ca273204 (diff)
downloadserenity-5c1427f3e04d83e41e2007ec8d0dd953455db5bc.zip
LibWeb: Remove old ANPlusB parsing code
This was left over from the old CSS parser, so we no longer need it. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Selector.cpp74
-rw-r--r--Userland/Libraries/LibWeb/CSS/Selector.h1
2 files changed, 0 insertions, 75 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.cpp b/Userland/Libraries/LibWeb/CSS/Selector.cpp
index a532df7dd9..e20647dd4a 100644
--- a/Userland/Libraries/LibWeb/CSS/Selector.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Selector.cpp
@@ -5,9 +5,6 @@
*/
#include "Selector.h"
-#include <AK/GenericLexer.h>
-#include <AK/StringUtils.h>
-#include <ctype.h>
namespace Web::CSS {
@@ -47,75 +44,4 @@ u32 Selector::specificity() const
return ids * 0x10000 + classes * 0x100 + tag_names;
}
-Selector::SimpleSelector::ANPlusBPattern Selector::SimpleSelector::ANPlusBPattern::parse(StringView const& args)
-{
- // FIXME: Remove this when the DeprecatedCSSParser is gone.
- // The new Parser::parse_nth_child_pattern() does the same as this, using Tokens.
- CSS::Selector::SimpleSelector::ANPlusBPattern pattern;
- if (args.equals_ignoring_case("odd")) {
- pattern.step_size = 2;
- pattern.offset = 1;
- } else if (args.equals_ignoring_case("even")) {
- pattern.step_size = 2;
- } else {
- 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 == '-';
- }));
- };
-
- // Try to match any of following patterns:
- // 1. An+B
- // 2. An
- // 3. B
- // ...where "A" is "step_size", "B" is "offset" and rest are literals.
- // "A" can be omitted, in that case "A" = 1.
- // "A" may have "+" or "-" sign, "B" always must be predated by sign for pattern (1).
-
- int step_size_or_offset = 0;
- GenericLexer lexer { args };
-
- // "When a=1, or a=-1, the 1 may be omitted from the rule."
- if (lexer.consume_specific("n") || lexer.consume_specific("+n")) {
- step_size_or_offset = +1;
- lexer.retreat();
- } else if (lexer.consume_specific("-n")) {
- step_size_or_offset = -1;
- lexer.retreat();
- } else {
- auto const value = consume_int(lexer);
- if (!value.has_value())
- return {};
- step_size_or_offset = value.value();
- }
-
- if (lexer.consume_specific("n")) {
- lexer.ignore_while(isspace);
- if (lexer.next_is('+') || lexer.next_is('-')) {
- auto const sign = lexer.next_is('+') ? 1 : -1;
- lexer.ignore();
- lexer.ignore_while(isspace);
-
- // "An+B" pattern
- auto const offset = consume_int(lexer);
- if (!offset.has_value())
- return {};
- pattern.step_size = step_size_or_offset;
- pattern.offset = sign * offset.value();
- } else {
- // "An" pattern
- pattern.step_size = step_size_or_offset;
- }
- } else {
- // "B" pattern
- pattern.offset = step_size_or_offset;
- }
-
- if (lexer.remaining().length() > 0)
- return {};
- }
-
- return pattern;
-}
-
}
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h
index e9a8ea6a19..d5941bd125 100644
--- a/Userland/Libraries/LibWeb/CSS/Selector.h
+++ b/Userland/Libraries/LibWeb/CSS/Selector.h
@@ -37,7 +37,6 @@ public:
int step_size { 0 }; // "A"
int offset = { 0 }; // "B"
- static ANPlusBPattern parse(StringView const& args);
String to_string() const
{
return String::formatted("{}n{:+}", step_size, offset);