SVGStyleElement.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #ifndef mozilla_dom_SVGStyleElement_h
  6. #define mozilla_dom_SVGStyleElement_h
  7. #include "mozilla/Attributes.h"
  8. #include "nsSVGElement.h"
  9. #include "nsStyleLinkElement.h"
  10. #include "nsStubMutationObserver.h"
  11. nsresult NS_NewSVGStyleElement(nsIContent **aResult,
  12. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
  13. typedef nsSVGElement SVGStyleElementBase;
  14. namespace mozilla {
  15. namespace dom {
  16. class SVGStyleElement final : public SVGStyleElementBase,
  17. public nsStyleLinkElement,
  18. public nsStubMutationObserver
  19. {
  20. protected:
  21. friend nsresult (::NS_NewSVGStyleElement(nsIContent **aResult,
  22. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
  23. explicit SVGStyleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
  24. ~SVGStyleElement();
  25. virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
  26. public:
  27. NS_DECL_ISUPPORTS_INHERITED
  28. NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement,
  29. SVGStyleElementBase)
  30. // nsIContent
  31. virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
  32. nsIContent* aBindingParent,
  33. bool aCompileEventHandlers) override;
  34. virtual void UnbindFromTree(bool aDeep = true,
  35. bool aNullParent = true) override;
  36. nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
  37. const nsAString& aValue, bool aNotify)
  38. {
  39. return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
  40. }
  41. virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
  42. nsIAtom* aPrefix, const nsAString& aValue,
  43. bool aNotify) override;
  44. virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
  45. bool aNotify) override;
  46. virtual bool ParseAttribute(int32_t aNamespaceID,
  47. nsIAtom* aAttribute,
  48. const nsAString& aValue,
  49. nsAttrValue& aResult) override;
  50. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
  51. // nsIMutationObserver
  52. NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
  53. NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
  54. NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
  55. NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
  56. // WebIDL
  57. void GetXmlspace(nsAString & aXmlspace);
  58. void SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv);
  59. void GetMedia(nsAString & aMedia);
  60. void SetMedia(const nsAString& aMedia, ErrorResult& rv);
  61. bool Scoped() const;
  62. void SetScoped(bool aScoped, ErrorResult& rv);
  63. void GetType(nsAString & aType);
  64. void SetType(const nsAString& aType, ErrorResult& rv);
  65. void GetTitle(nsAString & aTitle);
  66. void SetTitle(const nsAString& aTitle, ErrorResult& rv);
  67. protected:
  68. // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
  69. // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
  70. // completely optimized away.
  71. inline nsresult Init()
  72. {
  73. return NS_OK;
  74. }
  75. // nsStyleLinkElement overrides
  76. already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline) override;
  77. void GetStyleSheetInfo(nsAString& aTitle,
  78. nsAString& aType,
  79. nsAString& aMedia,
  80. bool* aIsScoped,
  81. bool* aIsAlternate,
  82. bool* aIsExplicitlyEnabled) override;
  83. virtual CORSMode GetCORSMode() const override;
  84. /**
  85. * Common method to call from the various mutation observer methods.
  86. * aContent is a content node that's either the one that changed or its
  87. * parent; we should only respond to the change if aContent is non-anonymous.
  88. */
  89. void ContentChanged(nsIContent* aContent);
  90. };
  91. } // namespace dom
  92. } // namespace mozilla
  93. #endif // mozilla_dom_SVGStyleElement_h