SVGTitleElement.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/DOM/Document.h>
  8. #include <LibWeb/SVG/SVGTitleElement.h>
  9. namespace Web::SVG {
  10. SVGTitleElement::SVGTitleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  11. : SVGElement(document, move(qualified_name))
  12. {
  13. }
  14. JS::ThrowCompletionOr<void> SVGTitleElement::initialize(JS::Realm& realm)
  15. {
  16. MUST_OR_THROW_OOM(Base::initialize(realm));
  17. set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTitleElementPrototype>(realm, "SVGTitleElement"));
  18. return {};
  19. }
  20. JS::GCPtr<Layout::Node> SVGTitleElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>)
  21. {
  22. return nullptr;
  23. }
  24. void SVGTitleElement::children_changed()
  25. {
  26. Base::children_changed();
  27. auto* page = document().page();
  28. if (!page)
  29. return;
  30. if (document().browsing_context() != &page->top_level_browsing_context())
  31. return;
  32. auto* document_element = document().document_element();
  33. if (document_element == parent() && is<SVGElement>(document_element))
  34. page->client().page_did_change_title(document().title());
  35. }
  36. }