content/base/src/Attr.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/src/Attr.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,115 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * Implementation of DOM Core's nsIDOMAttr node.
    1.11 + */
    1.12 +
    1.13 +#ifndef mozilla_dom_Attr_h
    1.14 +#define mozilla_dom_Attr_h
    1.15 +
    1.16 +#include "mozilla/Attributes.h"
    1.17 +#include "nsIAttribute.h"
    1.18 +#include "nsIDOMAttr.h"
    1.19 +#include "nsIDOMText.h"
    1.20 +#include "nsIDOMNodeList.h"
    1.21 +#include "nsString.h"
    1.22 +#include "nsCOMPtr.h"
    1.23 +#include "nsINodeInfo.h"
    1.24 +#include "nsCycleCollectionParticipant.h"
    1.25 +#include "nsStubMutationObserver.h"
    1.26 +#include "nsIDocument.h"
    1.27 +
    1.28 +namespace mozilla {
    1.29 +class EventChainPreVisitor;
    1.30 +namespace dom {
    1.31 +
    1.32 +// Attribute helper class used to wrap up an attribute with a dom
    1.33 +// object that implements nsIDOMAttr and nsIDOMNode
    1.34 +class Attr MOZ_FINAL : public nsIAttribute,
    1.35 +                       public nsIDOMAttr
    1.36 +{
    1.37 +public:
    1.38 +  Attr(nsDOMAttributeMap* aAttrMap,
    1.39 +       already_AddRefed<nsINodeInfo>&& aNodeInfo,
    1.40 +       const nsAString& aValue,
    1.41 +       bool aNsAware);
    1.42 +  virtual ~Attr() {}
    1.43 +
    1.44 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.45 +
    1.46 +  // nsIDOMNode interface
    1.47 +  NS_FORWARD_NSIDOMNODE_TO_NSINODE
    1.48 +  virtual void GetTextContentInternal(nsAString& aTextContent) MOZ_OVERRIDE;
    1.49 +  virtual void SetTextContentInternal(const nsAString& aTextContent,
    1.50 +                                      ErrorResult& aError) MOZ_OVERRIDE;
    1.51 +  virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE;
    1.52 +  virtual void SetNodeValueInternal(const nsAString& aNodeValue,
    1.53 +                                    ErrorResult& aError) MOZ_OVERRIDE;
    1.54 +
    1.55 +  // nsIDOMAttr interface
    1.56 +  NS_DECL_NSIDOMATTR
    1.57 +
    1.58 +  virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
    1.59 +
    1.60 +  // nsIAttribute interface
    1.61 +  void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE;
    1.62 +  Element* GetElement() const;
    1.63 +  nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
    1.64 +
    1.65 +  // nsINode interface
    1.66 +  virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
    1.67 +  virtual uint32_t GetChildCount() const MOZ_OVERRIDE;
    1.68 +  virtual nsIContent *GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
    1.69 +  virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const MOZ_OVERRIDE;
    1.70 +  virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
    1.71 +  virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
    1.72 +                                 bool aNotify) MOZ_OVERRIDE;
    1.73 +  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
    1.74 +  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
    1.75 +  virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE;
    1.76 +
    1.77 +  static void Initialize();
    1.78 +  static void Shutdown();
    1.79 +
    1.80 +  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
    1.81 +                                                                   nsIAttribute)
    1.82 +
    1.83 +  virtual nsIDOMNode* AsDOMNode() { return this; }
    1.84 +
    1.85 +  // WebIDL
    1.86 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.87 +
    1.88 +  // XPCOM GetName() is OK
    1.89 +  // XPCOM GetValue() is OK
    1.90 +
    1.91 +  void SetValue(const nsAString& aValue, ErrorResult& aRv);
    1.92 +
    1.93 +  bool Specified() const;
    1.94 +
    1.95 +  // XPCOM GetNamespaceURI() is OK
    1.96 +  // XPCOM GetPrefix() is OK
    1.97 +  // XPCOM GetLocalName() is OK
    1.98 +
    1.99 +  Element* GetOwnerElement(ErrorResult& aRv);
   1.100 +
   1.101 +protected:
   1.102 +  virtual Element* GetNameSpaceElement()
   1.103 +  {
   1.104 +    return GetElement();
   1.105 +  }
   1.106 +
   1.107 +  static bool sInitialized;
   1.108 +
   1.109 +private:
   1.110 +  already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent);
   1.111 +
   1.112 +  nsString mValue;
   1.113 +};
   1.114 +
   1.115 +} // namespace dom
   1.116 +} // namespace mozilla
   1.117 +
   1.118 +#endif /* mozilla_dom_Attr_h */

mercurial