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/Bindings/SVGTitleElementPrototype.h>
  8. #include <LibWeb/DOM/Document.h>
  9. #include <LibWeb/Page/Page.h>
  10. #include <LibWeb/SVG/SVGTitleElement.h>
  11. namespace Web::SVG {
  12. GC_DEFINE_ALLOCATOR(SVGTitleElement);
  13. SVGTitleElement::SVGTitleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  14. : SVGElement(document, move(qualified_name))
  15. {
  16. }
  17. void SVGTitleElement::initialize(JS::Realm& realm)
  18. {
  19. Base::initialize(realm);
  20. WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTitleElement);
  21. }
  22. GC::Ptr<Layout::Node> SVGTitleElement::create_layout_node(CSS::StyleProperties)
  23. {
  24. return nullptr;
  25. }
  26. void SVGTitleElement::children_changed()
  27. {
  28. Base::children_changed();
  29. auto& page = document().page();
  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().to_byte_string());
  35. }
  36. }