CompositeStyleValue.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 CompositeStyleValue final : public StyleValueWithDefaultOperators<CompositeStyleValue> {
  10. public:
  11. static ErrorOr<ValueComparingNonnullRefPtr<CompositeStyleValue>> create(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
  12. {
  13. return adopt_nonnull_ref_or_enomem(new CompositeStyleValue(move(sub_properties), move(values)));
  14. }
  15. virtual ~CompositeStyleValue() 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. virtual ErrorOr<String> to_string() const override;
  19. bool properties_equal(CompositeStyleValue const& other) const { return m_properties == other.m_properties; }
  20. private:
  21. CompositeStyleValue(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values);
  22. struct Properties {
  23. Vector<PropertyID> sub_properties;
  24. Vector<ValueComparingNonnullRefPtr<StyleValue const>> values;
  25. bool operator==(Properties const&) const = default;
  26. } m_properties;
  27. };
  28. }