Selector.h 708 B

12345678910111213141516171819202122232425262728293031323334353637
  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. TagName,
  11. Id,
  12. Class,
  13. };
  14. Type type { Type::Invalid };
  15. enum class Relation {
  16. None,
  17. ImmediateChild,
  18. Descendant,
  19. };
  20. Relation relation { Relation::None };
  21. String value;
  22. };
  23. explicit Selector(Vector<Component>&&);
  24. ~Selector();
  25. const Vector<Component>& components() const { return m_components; }
  26. Specificity specificity() const;
  27. private:
  28. Vector<Component> m_components;
  29. };