Selector.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include <AK/String.h>
  3. #include <AK/Vector.h>
  4. #include <LibHTML/CSS/Specificity.h>
  5. class Selector {
  6. public:
  7. struct Component {
  8. enum class Type {
  9. Invalid,
  10. Universal,
  11. TagName,
  12. Id,
  13. Class,
  14. };
  15. Type type { Type::Invalid };
  16. enum class PseudoClass {
  17. None,
  18. Link,
  19. Hover,
  20. };
  21. PseudoClass pseudo_class { PseudoClass::None };
  22. enum class Relation {
  23. None,
  24. ImmediateChild,
  25. Descendant,
  26. AdjacentSibling,
  27. GeneralSibling,
  28. };
  29. Relation relation { Relation::None };
  30. String value;
  31. enum class AttributeMatchType {
  32. None,
  33. HasAttribute,
  34. ExactValueMatch,
  35. };
  36. AttributeMatchType attribute_match_type { AttributeMatchType::None };
  37. String attribute_name;
  38. String attribute_value;
  39. };
  40. explicit Selector(Vector<Component>&&);
  41. ~Selector();
  42. const Vector<Component>& components() const { return m_components; }
  43. Specificity specificity() const;
  44. private:
  45. Vector<Component> m_components;
  46. };