mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +00:00
LibWeb: Implement the :dir() selector pseudo-class
This commit is contained in:
committed by
Andreas Kling
parent
5b125811f1
commit
b8e694c0f2
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/SelectorEngine.h>
|
||||
#include <LibWeb/CSS/ValueID.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
@@ -428,6 +429,19 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
||||
}
|
||||
case CSS::PseudoClass::Target:
|
||||
return element.is_target();
|
||||
case CSS::PseudoClass::Dir: {
|
||||
// "Values other than ltr and rtl are not invalid, but do not match anything."
|
||||
// - https://www.w3.org/TR/selectors-4/#the-dir-pseudo
|
||||
if (!first_is_one_of(pseudo_class.identifier, CSS::ValueID::Ltr, CSS::ValueID::Rtl))
|
||||
return false;
|
||||
switch (element.directionality()) {
|
||||
case DOM::Element::Directionality::Ltr:
|
||||
return pseudo_class.identifier == CSS::ValueID::Ltr;
|
||||
case DOM::Element::Directionality::Rtl:
|
||||
return pseudo_class.identifier == CSS::ValueID::Rtl;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user