SVGLength.h 902 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/RefCounted.h>
  8. #include <AK/Types.h>
  9. #include <AK/Weakable.h>
  10. #include <LibWeb/Bindings/Wrappable.h>
  11. #include <LibWeb/DOM/ExceptionOr.h>
  12. namespace Web::SVG {
  13. // https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLength
  14. class SVGLength
  15. : public RefCounted<SVGLength>
  16. , public Bindings::Wrappable
  17. , public Weakable<SVGLength> {
  18. public:
  19. using WrapperType = Bindings::SVGLengthWrapper;
  20. static NonnullRefPtr<SVGLength> create(u8 unit_type, float value);
  21. virtual ~SVGLength() = default;
  22. u8 unit_type() const { return m_unit_type; }
  23. float value() const { return m_value; }
  24. DOM::ExceptionOr<void> set_value(float value);
  25. private:
  26. SVGLength(u8 unit_type, float value);
  27. u8 m_unit_type { 0 };
  28. float m_value { 0 };
  29. };
  30. }