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
,
27 //----------------------------------------------------------------------
30 SVGTitleElement::SVGTitleElement(
31 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
32 : SVGTitleElementBase(std::move(aNodeInfo
)) {
33 AddMutationObserver(this);
34 SetEnabledCallbacks(kCharacterDataChanged
| kContentAppended
|
35 kContentInserted
| kContentWillBeRemoved
);
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::ContentWillBeRemoved(nsIContent
* aChild
) {
52 SendTitleChangeEvent(false);
55 nsresult
SVGTitleElement::BindToTree(BindContext
& aContext
, nsINode
& aParent
) {
56 // Let this fall through.
57 nsresult rv
= SVGTitleElementBase::BindToTree(aContext
, aParent
);
58 NS_ENSURE_SUCCESS(rv
, rv
);
60 SendTitleChangeEvent(true);
65 void SVGTitleElement::UnbindFromTree(UnbindContext
& aContext
) {
66 SendTitleChangeEvent(false);
68 // Let this fall through.
69 SVGTitleElementBase::UnbindFromTree(aContext
);
72 void SVGTitleElement::DoneAddingChildren(bool aHaveNotified
) {
74 SendTitleChangeEvent(false);
78 void SVGTitleElement::SendTitleChangeEvent(bool aBound
) {
79 if (Document
* doc
= GetUncomposedDoc()) {
80 doc
->NotifyPossibleTitleChange(aBound
);
84 //----------------------------------------------------------------------
87 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement
)
89 } // namespace mozilla::dom