SVGLength.h 910 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. #include <LibWeb/WebIDL/ExceptionOr.h>
  9. namespace Web::SVG {
  10. // https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLength
  11. class SVGLength : public Bindings::PlatformObject {
  12. WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject);
  13. JS_DECLARE_ALLOCATOR(SVGLength);
  14. public:
  15. [[nodiscard]] static JS::NonnullGCPtr<SVGLength> create(JS::Realm&, u8 unit_type, float value);
  16. virtual ~SVGLength() override;
  17. u8 unit_type() const { return m_unit_type; }
  18. float value() const { return m_value; }
  19. WebIDL::ExceptionOr<void> set_value(float value);
  20. private:
  21. SVGLength(JS::Realm&, u8 unit_type, float value);
  22. virtual void initialize(JS::Realm&) override;
  23. u8 m_unit_type { 0 };
  24. float m_value { 0 };
  25. };
  26. }