FlexFlowStyleValue.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
  4. * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
  5. * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
  6. *
  7. * SPDX-License-Identifier: BSD-2-Clause
  8. */
  9. #pragma once
  10. #include <LibWeb/CSS/StyleValue.h>
  11. namespace Web::CSS {
  12. class FlexFlowStyleValue final : public StyleValueWithDefaultOperators<FlexFlowStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<FlexFlowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap)
  15. {
  16. return adopt_ref(*new FlexFlowStyleValue(move(flex_direction), move(flex_wrap)));
  17. }
  18. virtual ~FlexFlowStyleValue() override = default;
  19. ValueComparingNonnullRefPtr<StyleValue> flex_direction() const { return m_properties.flex_direction; }
  20. ValueComparingNonnullRefPtr<StyleValue> flex_wrap() const { return m_properties.flex_wrap; }
  21. virtual ErrorOr<String> to_string() const override;
  22. bool properties_equal(FlexFlowStyleValue const& other) const { return m_properties == other.m_properties; };
  23. private:
  24. FlexFlowStyleValue(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap)
  25. : StyleValueWithDefaultOperators(Type::FlexFlow)
  26. , m_properties { .flex_direction = move(flex_direction), .flex_wrap = move(flex_wrap) }
  27. {
  28. }
  29. struct Properties {
  30. ValueComparingNonnullRefPtr<StyleValue> flex_direction;
  31. ValueComparingNonnullRefPtr<StyleValue> flex_wrap;
  32. bool operator==(Properties const&) const = default;
  33. } m_properties;
  34. };
  35. }