Selector.h 684 B

123456789101112131415161718192021222324252627282930313233343536
  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. };
  19. Relation relation { Relation::None };
  20. String value;
  21. };
  22. explicit Selector(Vector<Component>&&);
  23. ~Selector();
  24. const Vector<Component>& components() const { return m_components; }
  25. Specificity specificity() const;
  26. private:
  27. Vector<Component> m_components;
  28. };