Bug 1874684 - Part 4: Prefer const references instead of copying Instant values....
[gecko.git] / dom / svg / SVGTitleElement.cpp
blob873499c40ed7721b73f18b5ff7fc3d76c0cbf09e
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/SVGTitleElement.h"
8 #include "mozilla/dom/SVGTitleElementBinding.h"
10 #include "mozilla/dom/Document.h"
12 NS_IMPL_NS_NEW_SVG_ELEMENT(Title)
14 namespace mozilla::dom {
16 JSObject* SVGTitleElement::WrapNode(JSContext* aCx,
17 JS::Handle<JSObject*> aGivenProto) {
18 return SVGTitleElement_Binding::Wrap(aCx, this, aGivenProto);
21 //----------------------------------------------------------------------
22 // nsISupports methods
24 NS_IMPL_ISUPPORTS_INHERITED(SVGTitleElement, SVGTitleElementBase,
25 nsIMutationObserver)
27 //----------------------------------------------------------------------
28 // Implementation
30 SVGTitleElement::SVGTitleElement(
31 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
32 : SVGTitleElementBase(std::move(aNodeInfo)) {
33 AddMutationObserver(this);
34 SetEnabledCallbacks(kCharacterDataChanged | kContentAppended |
35 kContentInserted | kContentRemoved);
38 void SVGTitleElement::CharacterDataChanged(nsIContent* aContent,
39 const CharacterDataChangeInfo&) {
40 SendTitleChangeEvent(false);
43 void SVGTitleElement::ContentAppended(nsIContent* aFirstNewContent) {
44 SendTitleChangeEvent(false);
47 void SVGTitleElement::ContentInserted(nsIContent* aChild) {
48 SendTitleChangeEvent(false);
51 void SVGTitleElement::ContentRemoved(nsIContent* aChild,
52 nsIContent* aPreviousSibling) {
53 SendTitleChangeEvent(false);
56 nsresult SVGTitleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
57 // Let this fall through.
58 nsresult rv = SVGTitleElementBase::BindToTree(aContext, aParent);
59 NS_ENSURE_SUCCESS(rv, rv);
61 SendTitleChangeEvent(true);
63 return NS_OK;
66 void SVGTitleElement::UnbindFromTree(UnbindContext& aContext) {
67 SendTitleChangeEvent(false);
69 // Let this fall through.
70 SVGTitleElementBase::UnbindFromTree(aContext);
73 void SVGTitleElement::DoneAddingChildren(bool aHaveNotified) {
74 if (!aHaveNotified) {
75 SendTitleChangeEvent(false);
79 void SVGTitleElement::SendTitleChangeEvent(bool aBound) {
80 Document* doc = GetUncomposedDoc();
81 if (doc) {
82 doc->NotifyPossibleTitleChange(aBound);
86 //----------------------------------------------------------------------
87 // nsINode methods
89 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement)
91 } // namespace mozilla::dom