Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / svg / SVGTitleElement.cpp
blobd56fc44934cfda42baa81b4406ce370d3206142c
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);
36 void SVGTitleElement::CharacterDataChanged(nsIContent* aContent,
37 const CharacterDataChangeInfo&) {
38 SendTitleChangeEvent(false);
41 void SVGTitleElement::ContentAppended(nsIContent* aFirstNewContent) {
42 SendTitleChangeEvent(false);
45 void SVGTitleElement::ContentInserted(nsIContent* aChild) {
46 SendTitleChangeEvent(false);
49 void SVGTitleElement::ContentRemoved(nsIContent* aChild,
50 nsIContent* aPreviousSibling) {
51 SendTitleChangeEvent(false);
54 nsresult SVGTitleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
55 // Let this fall through.
56 nsresult rv = SVGTitleElementBase::BindToTree(aContext, aParent);
57 NS_ENSURE_SUCCESS(rv, rv);
59 SendTitleChangeEvent(true);
61 return NS_OK;
64 void SVGTitleElement::UnbindFromTree(bool aNullParent) {
65 SendTitleChangeEvent(false);
67 // Let this fall through.
68 SVGTitleElementBase::UnbindFromTree(aNullParent);
71 void SVGTitleElement::DoneAddingChildren(bool aHaveNotified) {
72 if (!aHaveNotified) {
73 SendTitleChangeEvent(false);
77 void SVGTitleElement::SendTitleChangeEvent(bool aBound) {
78 Document* doc = GetUncomposedDoc();
79 if (doc) {
80 doc->NotifyPossibleTitleChange(aBound);
84 //----------------------------------------------------------------------
85 // nsINode methods
87 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement)
89 } // namespace mozilla::dom