2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of DOM Core's nsIDOMAttr node.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsDOMAttribute_h___
|
|
|
|
#define nsDOMAttribute_h___
|
|
|
|
|
|
|
|
#include "nsIAttribute.h"
|
|
|
|
#include "nsIDOMAttr.h"
|
|
|
|
#include "nsIDOMText.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsDOMAttributeMap.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-05-27 12:10:33 -07:00
|
|
|
#include "nsStubMutationObserver.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Attribute helper class used to wrap up an attribute with a dom
|
2011-06-25 00:33:32 -07:00
|
|
|
// object that implements nsIDOMAttr and nsIDOMNode
|
2007-12-15 01:45:33 -08:00
|
|
|
class nsDOMAttribute : public nsIAttribute,
|
2012-04-03 00:25:39 -07:00
|
|
|
public nsIDOMAttr
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-07-23 02:49:57 -07:00
|
|
|
nsDOMAttribute(nsDOMAttributeMap* aAttrMap,
|
|
|
|
already_AddRefed<nsINodeInfo> aNodeInfo,
|
2010-10-14 07:07:20 -07:00
|
|
|
const nsAString& aValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNsAware);
|
2012-04-03 00:25:39 -07:00
|
|
|
virtual ~nsDOMAttribute() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIDOMNode interface
|
|
|
|
NS_DECL_NSIDOMNODE
|
|
|
|
|
|
|
|
// nsIDOMAttr interface
|
|
|
|
NS_DECL_NSIDOMATTR
|
|
|
|
|
2011-06-23 19:17:59 -07:00
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
2011-06-23 19:17:58 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIAttribute interface
|
|
|
|
void SetMap(nsDOMAttributeMap *aMap);
|
|
|
|
nsIContent *GetContent() const;
|
|
|
|
nsresult SetOwnerDocument(nsIDocument* aDocument);
|
|
|
|
|
|
|
|
// nsINode interface
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const;
|
|
|
|
virtual uint32_t GetChildCount() const;
|
|
|
|
virtual nsIContent *GetChildAt(uint32_t aIndex) const;
|
|
|
|
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const;
|
2012-10-06 00:19:46 -07:00
|
|
|
virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNotify);
|
|
|
|
virtual nsresult AppendChildTo(nsIContent* aKid, bool aNotify);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
2010-04-19 08:40:15 -07:00
|
|
|
virtual already_AddRefed<nsIURI> GetBaseURI() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2009-05-12 13:20:42 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMAttribute,
|
|
|
|
nsIAttribute)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
virtual nsXPCClassInfo* GetClassInfo();
|
2012-04-25 06:47:30 -07:00
|
|
|
|
|
|
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2010-04-19 08:40:16 -07:00
|
|
|
virtual mozilla::dom::Element* GetNameSpaceElement()
|
|
|
|
{
|
2010-07-30 06:42:11 -07:00
|
|
|
return GetContentInternal();
|
2010-04-19 08:40:16 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool sInitialized;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
2009-12-28 06:35:06 -08:00
|
|
|
already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent);
|
2010-07-30 06:42:11 -07:00
|
|
|
mozilla::dom::Element *GetContentInternal() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return mAttrMap ? mAttrMap->GetContent() : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-04-03 00:25:39 -07:00
|
|
|
|
|
|
|
nsString mValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* nsDOMAttribute_h___ */
|