michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Implementation of DOM Core's nsIDOMAttr node. michael@0: */ michael@0: michael@0: #ifndef mozilla_dom_Attr_h michael@0: #define mozilla_dom_Attr_h michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsIAttribute.h" michael@0: #include "nsIDOMAttr.h" michael@0: #include "nsIDOMText.h" michael@0: #include "nsIDOMNodeList.h" michael@0: #include "nsString.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsINodeInfo.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsStubMutationObserver.h" michael@0: #include "nsIDocument.h" michael@0: michael@0: namespace mozilla { michael@0: class EventChainPreVisitor; michael@0: namespace dom { michael@0: michael@0: // Attribute helper class used to wrap up an attribute with a dom michael@0: // object that implements nsIDOMAttr and nsIDOMNode michael@0: class Attr MOZ_FINAL : public nsIAttribute, michael@0: public nsIDOMAttr michael@0: { michael@0: public: michael@0: Attr(nsDOMAttributeMap* aAttrMap, michael@0: already_AddRefed&& aNodeInfo, michael@0: const nsAString& aValue, michael@0: bool aNsAware); michael@0: virtual ~Attr() {} michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: michael@0: // nsIDOMNode interface michael@0: NS_FORWARD_NSIDOMNODE_TO_NSINODE michael@0: virtual void GetTextContentInternal(nsAString& aTextContent) MOZ_OVERRIDE; michael@0: virtual void SetTextContentInternal(const nsAString& aTextContent, michael@0: ErrorResult& aError) MOZ_OVERRIDE; michael@0: virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE; michael@0: virtual void SetNodeValueInternal(const nsAString& aNodeValue, michael@0: ErrorResult& aError) MOZ_OVERRIDE; michael@0: michael@0: // nsIDOMAttr interface michael@0: NS_DECL_NSIDOMATTR michael@0: michael@0: virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; michael@0: michael@0: // nsIAttribute interface michael@0: void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE; michael@0: Element* GetElement() const; michael@0: nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE; michael@0: michael@0: // nsINode interface michael@0: virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; michael@0: virtual uint32_t GetChildCount() const MOZ_OVERRIDE; michael@0: virtual nsIContent *GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE; michael@0: virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const MOZ_OVERRIDE; michael@0: virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE; michael@0: virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, michael@0: bool aNotify) MOZ_OVERRIDE; michael@0: virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE; michael@0: virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; michael@0: virtual already_AddRefed GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE; michael@0: michael@0: static void Initialize(); michael@0: static void Shutdown(); michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr, michael@0: nsIAttribute) michael@0: michael@0: virtual nsIDOMNode* AsDOMNode() { return this; } michael@0: michael@0: // WebIDL michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: // XPCOM GetName() is OK michael@0: // XPCOM GetValue() is OK michael@0: michael@0: void SetValue(const nsAString& aValue, ErrorResult& aRv); michael@0: michael@0: bool Specified() const; michael@0: michael@0: // XPCOM GetNamespaceURI() is OK michael@0: // XPCOM GetPrefix() is OK michael@0: // XPCOM GetLocalName() is OK michael@0: michael@0: Element* GetOwnerElement(ErrorResult& aRv); michael@0: michael@0: protected: michael@0: virtual Element* GetNameSpaceElement() michael@0: { michael@0: return GetElement(); michael@0: } michael@0: michael@0: static bool sInitialized; michael@0: michael@0: private: michael@0: already_AddRefed GetNameAtom(nsIContent* aContent); michael@0: michael@0: nsString mValue; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif /* mozilla_dom_Attr_h */