SVGLength.cpp 981 B

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