SVGTitleElement.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/Page/Page.h>
  9. #include <LibWeb/SVG/SVGTitleElement.h>
  10. namespace Web::SVG {
  11. JS_DEFINE_ALLOCATOR(SVGTitleElement);
  12. SVGTitleElement::SVGTitleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  13. : SVGElement(document, move(qualified_name))
  14. {
  15. }
  16. void SVGTitleElement::initialize(JS::Realm& realm)
  17. {
  18. Base::initialize(realm);
  19. WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTitleElement);
  20. }
  21. JS::GCPtr<Layout::Node> SVGTitleElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>)
  22. {
  23. return nullptr;
  24. }
  25. void SVGTitleElement::children_changed()
  26. {
  27. Base::children_changed();
  28. auto& page = document().page();
  29. if (document().browsing_context() != &page.top_level_browsing_context())
  30. return;
  31. auto* document_element = document().document_element();
  32. if (document_element == parent() && is<SVGElement>(document_element))
  33. page.client().page_did_change_title(document().title().to_byte_string());
  34. }
  35. }