SVGLength.cpp 958 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/SVGLengthPrototype.h>
  7. #include <LibWeb/HTML/Window.h>
  8. #include <LibWeb/SVG/SVGLength.h>
  9. namespace Web::SVG {
  10. JS::NonnullGCPtr<SVGLength> SVGLength::create(HTML::Window& window, u8 unit_type, float value)
  11. {
  12. return *window.heap().allocate<SVGLength>(window.realm(), window, unit_type, value);
  13. }
  14. SVGLength::SVGLength(HTML::Window& window, u8 unit_type, float value)
  15. : PlatformObject(window.realm())
  16. , m_unit_type(unit_type)
  17. , m_value(value)
  18. {
  19. set_prototype(&window.ensure_web_prototype<Bindings::SVGLengthPrototype>("SVGLength"));
  20. }
  21. SVGLength::~SVGLength() = default;
  22. // https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value
  23. DOM::ExceptionOr<void> SVGLength::set_value(float value)
  24. {
  25. // FIXME: Raise an exception if this <length> is read-only.
  26. m_value = value;
  27. return {};
  28. }
  29. }