SVGTitleElement.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "mozilla/dom/SVGTitleElement.h"
  6. #include "mozilla/dom/SVGTitleElementBinding.h"
  7. NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Title)
  8. namespace mozilla {
  9. namespace dom {
  10. JSObject*
  11. SVGTitleElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
  12. {
  13. return SVGTitleElementBinding::Wrap(aCx, this, aGivenProto);
  14. }
  15. //----------------------------------------------------------------------
  16. // nsISupports methods
  17. NS_IMPL_ISUPPORTS_INHERITED(SVGTitleElement, SVGTitleElementBase,
  18. nsIDOMNode, nsIDOMElement,
  19. nsIDOMSVGElement,
  20. nsIMutationObserver)
  21. //----------------------------------------------------------------------
  22. // Implementation
  23. SVGTitleElement::SVGTitleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  24. : SVGTitleElementBase(aNodeInfo)
  25. {
  26. AddMutationObserver(this);
  27. }
  28. SVGTitleElement::~SVGTitleElement()
  29. {
  30. }
  31. void
  32. SVGTitleElement::CharacterDataChanged(nsIDocument *aDocument,
  33. nsIContent *aContent,
  34. CharacterDataChangeInfo *aInfo)
  35. {
  36. SendTitleChangeEvent(false);
  37. }
  38. void
  39. SVGTitleElement::ContentAppended(nsIDocument *aDocument,
  40. nsIContent *aContainer,
  41. nsIContent *aFirstNewContent,
  42. int32_t aNewIndexInContainer)
  43. {
  44. SendTitleChangeEvent(false);
  45. }
  46. void
  47. SVGTitleElement::ContentInserted(nsIDocument *aDocument,
  48. nsIContent *aContainer,
  49. nsIContent *aChild,
  50. int32_t aIndexInContainer)
  51. {
  52. SendTitleChangeEvent(false);
  53. }
  54. void
  55. SVGTitleElement::ContentRemoved(nsIDocument *aDocument,
  56. nsIContent *aContainer,
  57. nsIContent *aChild,
  58. int32_t aIndexInContainer,
  59. nsIContent *aPreviousSibling)
  60. {
  61. SendTitleChangeEvent(false);
  62. }
  63. nsresult
  64. SVGTitleElement::BindToTree(nsIDocument *aDocument,
  65. nsIContent *aParent,
  66. nsIContent *aBindingParent,
  67. bool aCompileEventHandlers)
  68. {
  69. // Let this fall through.
  70. nsresult rv = SVGTitleElementBase::BindToTree(aDocument, aParent,
  71. aBindingParent,
  72. aCompileEventHandlers);
  73. NS_ENSURE_SUCCESS(rv, rv);
  74. SendTitleChangeEvent(true);
  75. return NS_OK;
  76. }
  77. void
  78. SVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent)
  79. {
  80. SendTitleChangeEvent(false);
  81. // Let this fall through.
  82. SVGTitleElementBase::UnbindFromTree(aDeep, aNullParent);
  83. }
  84. void
  85. SVGTitleElement::DoneAddingChildren(bool aHaveNotified)
  86. {
  87. if (!aHaveNotified) {
  88. SendTitleChangeEvent(false);
  89. }
  90. }
  91. void
  92. SVGTitleElement::SendTitleChangeEvent(bool aBound)
  93. {
  94. nsIDocument* doc = GetUncomposedDoc();
  95. if (doc) {
  96. doc->NotifyPossibleTitleChange(aBound);
  97. }
  98. }
  99. //----------------------------------------------------------------------
  100. // nsIDOMNode methods
  101. NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement)
  102. } // namespace dom
  103. } // namespace mozilla