SVGLength.cpp 883 B

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