IntegerStyleValue.h 802 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2023, Sam Atkins <atkinssj@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 IntegerStyleValue : public StyleValueWithDefaultOperators<IntegerStyleValue> {
  10. public:
  11. static ValueComparingNonnullRefPtr<IntegerStyleValue> create(i64 value)
  12. {
  13. return adopt_ref(*new (nothrow) IntegerStyleValue(value));
  14. }
  15. i64 integer() const { return m_value; }
  16. virtual String to_string() const override;
  17. bool properties_equal(IntegerStyleValue const& other) const { return m_value == other.m_value; }
  18. private:
  19. explicit IntegerStyleValue(i64 value)
  20. : StyleValueWithDefaultOperators(Type::Integer)
  21. , m_value(value)
  22. {
  23. }
  24. i64 m_value { 0 };
  25. };
  26. }