content/base/src/Attr.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* -*- Mode: C++; tab-width: 2; 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/. */
     6 /*
     7  * Implementation of DOM Core's nsIDOMAttr node.
     8  */
    10 #ifndef mozilla_dom_Attr_h
    11 #define mozilla_dom_Attr_h
    13 #include "mozilla/Attributes.h"
    14 #include "nsIAttribute.h"
    15 #include "nsIDOMAttr.h"
    16 #include "nsIDOMText.h"
    17 #include "nsIDOMNodeList.h"
    18 #include "nsString.h"
    19 #include "nsCOMPtr.h"
    20 #include "nsINodeInfo.h"
    21 #include "nsCycleCollectionParticipant.h"
    22 #include "nsStubMutationObserver.h"
    23 #include "nsIDocument.h"
    25 namespace mozilla {
    26 class EventChainPreVisitor;
    27 namespace dom {
    29 // Attribute helper class used to wrap up an attribute with a dom
    30 // object that implements nsIDOMAttr and nsIDOMNode
    31 class Attr MOZ_FINAL : public nsIAttribute,
    32                        public nsIDOMAttr
    33 {
    34 public:
    35   Attr(nsDOMAttributeMap* aAttrMap,
    36        already_AddRefed<nsINodeInfo>&& aNodeInfo,
    37        const nsAString& aValue,
    38        bool aNsAware);
    39   virtual ~Attr() {}
    41   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    43   // nsIDOMNode interface
    44   NS_FORWARD_NSIDOMNODE_TO_NSINODE
    45   virtual void GetTextContentInternal(nsAString& aTextContent) MOZ_OVERRIDE;
    46   virtual void SetTextContentInternal(const nsAString& aTextContent,
    47                                       ErrorResult& aError) MOZ_OVERRIDE;
    48   virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE;
    49   virtual void SetNodeValueInternal(const nsAString& aNodeValue,
    50                                     ErrorResult& aError) MOZ_OVERRIDE;
    52   // nsIDOMAttr interface
    53   NS_DECL_NSIDOMATTR
    55   virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
    57   // nsIAttribute interface
    58   void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE;
    59   Element* GetElement() const;
    60   nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
    62   // nsINode interface
    63   virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
    64   virtual uint32_t GetChildCount() const MOZ_OVERRIDE;
    65   virtual nsIContent *GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
    66   virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const MOZ_OVERRIDE;
    67   virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
    68   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
    69                                  bool aNotify) MOZ_OVERRIDE;
    70   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
    71   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
    72   virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE;
    74   static void Initialize();
    75   static void Shutdown();
    77   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
    78                                                                    nsIAttribute)
    80   virtual nsIDOMNode* AsDOMNode() { return this; }
    82   // WebIDL
    83   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    85   // XPCOM GetName() is OK
    86   // XPCOM GetValue() is OK
    88   void SetValue(const nsAString& aValue, ErrorResult& aRv);
    90   bool Specified() const;
    92   // XPCOM GetNamespaceURI() is OK
    93   // XPCOM GetPrefix() is OK
    94   // XPCOM GetLocalName() is OK
    96   Element* GetOwnerElement(ErrorResult& aRv);
    98 protected:
    99   virtual Element* GetNameSpaceElement()
   100   {
   101     return GetElement();
   102   }
   104   static bool sInitialized;
   106 private:
   107   already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent);
   109   nsString mValue;
   110 };
   112 } // namespace dom
   113 } // namespace mozilla
   115 #endif /* mozilla_dom_Attr_h */

mercurial