SVGLength.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_DEFINE_ALLOCATOR(SVGLength);
  10. JS::NonnullGCPtr<SVGLength> SVGLength::create(JS::Realm& realm, u8 unit_type, float value)
  11. {
  12. return realm.heap().allocate<SVGLength>(realm, realm, unit_type, value);
  13. }
  14. SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)
  15. : PlatformObject(realm)
  16. , m_unit_type(unit_type)
  17. , m_value(value)
  18. {
  19. }
  20. void SVGLength::initialize(JS::Realm& realm)
  21. {
  22. Base::initialize(realm);
  23. set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLengthPrototype>(realm, "SVGLength"_fly_string));
  24. }
  25. SVGLength::~SVGLength() = default;
  26. // https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value
  27. WebIDL::ExceptionOr<void> SVGLength::set_value(float value)
  28. {
  29. // FIXME: Raise an exception if this <length> is read-only.
  30. m_value = value;
  31. return {};
  32. }
  33. }