mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:48:14 +00:00
LibWeb: Support the :root pseudo class
This commit is contained in:
parent
2f29e61203
commit
7bfd24ca76
5 changed files with 22 additions and 0 deletions
14
Base/home/anon/www/root.html
Normal file
14
Base/home/anon/www/root.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>:root test</title>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Background will be red.
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -50,6 +50,7 @@ span#ua {
|
||||||
<li><a href="last-child.html">:last-child</a></li>
|
<li><a href="last-child.html">:last-child</a></li>
|
||||||
<li><a href="only-child.html">:only-child</a></li>
|
<li><a href="only-child.html">:only-child</a></li>
|
||||||
<li><a href="empty.html">:empty</a></li>
|
<li><a href="empty.html">:empty</a></li>
|
||||||
|
<li><a href="root.html">:root</a></li>
|
||||||
<li><a href="form.html">form</a></li>
|
<li><a href="form.html">form</a></li>
|
||||||
<li><a href="borders.html">borders</a></li>
|
<li><a href="borders.html">borders</a></li>
|
||||||
<li><a href="css.html">css</a></li>
|
<li><a href="css.html">css</a></li>
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
LastChild,
|
LastChild,
|
||||||
OnlyChild,
|
OnlyChild,
|
||||||
Empty,
|
Empty,
|
||||||
|
Root,
|
||||||
};
|
};
|
||||||
PseudoClass pseudo_class { PseudoClass::None };
|
PseudoClass pseudo_class { PseudoClass::None };
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,10 @@ bool matches(const Selector::SimpleSelector& component, const Element& element)
|
||||||
if (element.first_child_of_type<Element>() || element.first_child_of_type<Text>())
|
if (element.first_child_of_type<Element>() || element.first_child_of_type<Text>())
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
case Selector::SimpleSelector::PseudoClass::Root:
|
||||||
|
if (!element.is_html_element())
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (component.attribute_match_type) {
|
switch (component.attribute_match_type) {
|
||||||
|
|
|
@ -414,6 +414,8 @@ public:
|
||||||
simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::OnlyChild;
|
simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::OnlyChild;
|
||||||
else if (pseudo_name.equals_ignoring_case("empty"))
|
else if (pseudo_name.equals_ignoring_case("empty"))
|
||||||
simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::Empty;
|
simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::Empty;
|
||||||
|
else if (pseudo_name.equals_ignoring_case("root"))
|
||||||
|
simple_selector.pseudo_class = Selector::SimpleSelector::PseudoClass::Root;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == index_at_start) {
|
if (index == index_at_start) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue