mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 19:10:26 +00:00
LibWeb: Add :not pseudoclass to the CSS parser
The selector given in the :not() is stored in the SimpleSelector as a String.
This commit is contained in:
parent
78f3bad7e6
commit
1ab82afee6
Notes:
sideshowbarker
2024-07-18 17:25:50 +09:00
Author: https://github.com/TobyAsE Commit: https://github.com/SerenityOS/serenity/commit/1ab82afee69 Pull-request: https://github.com/SerenityOS/serenity/pull/7422
3 changed files with 9 additions and 0 deletions
|
@ -579,6 +579,9 @@ public:
|
|||
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Enabled;
|
||||
} else if (pseudo_name.equals_ignoring_case("checked")) {
|
||||
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Checked;
|
||||
} else if (pseudo_name.starts_with("not", CaseSensitivity::CaseInsensitive)) {
|
||||
simple_selector.pseudo_class = CSS::Selector::SimpleSelector::PseudoClass::Not;
|
||||
simple_selector.not_selector = capture_selector_args(pseudo_name);
|
||||
} else {
|
||||
dbgln("Unknown pseudo class: '{}'", pseudo_name);
|
||||
return {};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -41,6 +42,7 @@ public:
|
|||
Disabled,
|
||||
Enabled,
|
||||
Checked,
|
||||
Not,
|
||||
};
|
||||
PseudoClass pseudo_class { PseudoClass::None };
|
||||
|
||||
|
@ -75,6 +77,7 @@ public:
|
|||
// FIXME: We don't need this field on every single SimpleSelector, but it's also annoying to malloc it somewhere.
|
||||
// Only used when "pseudo_class" is "NthChild" or "NthLastChild".
|
||||
NthChildPattern nth_child_pattern;
|
||||
String not_selector {};
|
||||
};
|
||||
|
||||
struct ComplexSelector {
|
||||
|
|
|
@ -384,6 +384,9 @@ void dump_selector(StringBuilder& builder, const CSS::Selector& selector)
|
|||
case CSS::Selector::SimpleSelector::PseudoClass::Checked:
|
||||
pseudo_class_description = "Checked";
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::PseudoClass::Not:
|
||||
pseudo_class_description = "Not";
|
||||
break;
|
||||
}
|
||||
|
||||
builder.appendff("{}:{}", type_description, simple_selector.value);
|
||||
|
|
Loading…
Reference in a new issue