LengthStyleValue.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 LengthStyleValue : public StyleValueWithDefaultOperators<LengthStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<LengthStyleValue> create(Length const&);
  15. virtual ~LengthStyleValue() override = default;
  16. Length const& length() const { return m_length; }
  17. virtual String to_string() const override { return m_length.to_string(); }
  18. virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override;
  19. bool properties_equal(LengthStyleValue const& other) const { return m_length == other.m_length; }
  20. private:
  21. explicit LengthStyleValue(Length const& length)
  22. : StyleValueWithDefaultOperators(Type::Length)
  23. , m_length(length)
  24. {
  25. }
  26. Length m_length;
  27. };
  28. }