ShorthandStyleValue.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/CSS/StyleValue.h>
  8. namespace Web::CSS {
  9. class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> {
  10. public:
  11. static ValueComparingNonnullRefPtr<ShorthandStyleValue> create(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
  12. {
  13. return adopt_ref(*new ShorthandStyleValue(shorthand, move(sub_properties), move(values)));
  14. }
  15. virtual ~ShorthandStyleValue() override;
  16. Vector<PropertyID> const& sub_properties() const { return m_properties.sub_properties; }
  17. Vector<ValueComparingNonnullRefPtr<StyleValue const>> const& values() const { return m_properties.values; }
  18. ValueComparingRefPtr<StyleValue const> longhand(PropertyID) const;
  19. virtual String to_string() const override;
  20. bool properties_equal(ShorthandStyleValue const& other) const { return m_properties == other.m_properties; }
  21. private:
  22. ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values);
  23. struct Properties {
  24. PropertyID shorthand_property;
  25. Vector<PropertyID> sub_properties;
  26. Vector<ValueComparingNonnullRefPtr<StyleValue const>> values;
  27. bool operator==(Properties const&) const = default;
  28. } m_properties;
  29. };
  30. }