MathMLElement.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/ExceptionOrUtils.h>
  7. #include <LibWeb/Bindings/MathMLElementPrototype.h>
  8. #include <LibWeb/MathML/MathMLElement.h>
  9. #include <LibWeb/MathML/TagNames.h>
  10. namespace Web::MathML {
  11. GC_DEFINE_ALLOCATOR(MathMLElement);
  12. MathMLElement::~MathMLElement() = default;
  13. MathMLElement::MathMLElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  14. : DOM::Element(document, move(qualified_name))
  15. {
  16. }
  17. void MathMLElement::attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
  18. {
  19. Base::attribute_changed(local_name, old_value, value, namespace_);
  20. HTMLOrSVGElement::attribute_changed(local_name, old_value, value, namespace_);
  21. }
  22. WebIDL::ExceptionOr<void> MathMLElement::cloned(DOM::Node& node, bool clone_children)
  23. {
  24. TRY(Base::cloned(node, clone_children));
  25. TRY(HTMLOrSVGElement::cloned(node, clone_children));
  26. return {};
  27. }
  28. void MathMLElement::inserted()
  29. {
  30. Base::inserted();
  31. HTMLOrSVGElement::inserted();
  32. }
  33. void MathMLElement::initialize(JS::Realm& realm)
  34. {
  35. Base::initialize(realm);
  36. WEB_SET_PROTOTYPE_FOR_INTERFACE(MathMLElement);
  37. }
  38. Optional<ARIA::Role> MathMLElement::default_role() const
  39. {
  40. // https://www.w3.org/TR/html-aria/#el-math
  41. if (local_name() == TagNames::math)
  42. return ARIA::Role::math;
  43. return {};
  44. }
  45. void MathMLElement::visit_edges(JS::Cell::Visitor& visitor)
  46. {
  47. Base::visit_edges(visitor);
  48. HTMLOrSVGElement::visit_edges(visitor);
  49. }
  50. }