SVGAnimatedLength.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/SVGAnimatedLength.h>
  8. namespace Web::SVG {
  9. WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGAnimatedLength>> SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
  10. {
  11. return MUST_OR_THROW_OOM(realm.heap().allocate<SVGAnimatedLength>(realm, realm, move(base_val), move(anim_val)));
  12. }
  13. SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
  14. : PlatformObject(realm)
  15. , m_base_val(move(base_val))
  16. , m_anim_val(move(anim_val))
  17. {
  18. // The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated.
  19. VERIFY(m_base_val.ptr() != m_anim_val.ptr());
  20. }
  21. SVGAnimatedLength::~SVGAnimatedLength() = default;
  22. JS::ThrowCompletionOr<void> SVGAnimatedLength::initialize(JS::Realm& realm)
  23. {
  24. MUST_OR_THROW_OOM(Base::initialize(realm));
  25. set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGAnimatedLengthPrototype>(realm, "SVGAnimatedLength"));
  26. return {};
  27. }
  28. void SVGAnimatedLength::visit_edges(Cell::Visitor& visitor)
  29. {
  30. Base::visit_edges(visitor);
  31. visitor.visit(m_base_val.ptr());
  32. visitor.visit(m_anim_val.ptr());
  33. }
  34. }