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.
|
|
|
|
*/
|
|
|
|
|
2013-04-09 08:29:44 -07:00
|
|
|
#ifndef mozilla_dom_Attr_h
|
|
|
|
#define mozilla_dom_Attr_h
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIAttribute.h"
|
|
|
|
#include "nsIDOMAttr.h"
|
|
|
|
#include "nsIDOMText.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-05-27 12:10:33 -07:00
|
|
|
#include "nsStubMutationObserver.h"
|
2014-08-18 07:44:50 -07:00
|
|
|
|
|
|
|
class nsIDocument;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-09 08:29:44 -07:00
|
|
|
namespace mozilla {
|
2014-03-17 21:48:19 -07:00
|
|
|
class EventChainPreVisitor;
|
2013-04-09 08:29:44 -07:00
|
|
|
namespace dom {
|
|
|
|
|
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
|
2013-07-11 14:26:54 -07:00
|
|
|
class Attr MOZ_FINAL : public nsIAttribute,
|
|
|
|
public nsIDOMAttr
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-24 19:09:15 -07:00
|
|
|
virtual ~Attr() {}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2013-04-09 08:29:44 -07:00
|
|
|
Attr(nsDOMAttributeMap* aAttrMap,
|
2014-06-19 19:01:40 -07:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-04-09 08:29:44 -07:00
|
|
|
const nsAString& aValue,
|
|
|
|
bool aNsAware);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIDOMNode interface
|
2012-10-09 05:31:24 -07:00
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
2014-08-05 03:10:00 -07:00
|
|
|
virtual void GetTextContentInternal(nsAString& aTextContent,
|
|
|
|
ErrorResult& aError) MOZ_OVERRIDE;
|
2012-10-09 05:31:24 -07:00
|
|
|
virtual void SetTextContentInternal(const nsAString& aTextContent,
|
2013-05-29 13:43:41 -07:00
|
|
|
ErrorResult& aError) MOZ_OVERRIDE;
|
|
|
|
virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE;
|
2012-10-09 05:31:24 -07:00
|
|
|
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
ErrorResult& aError) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIDOMAttr interface
|
|
|
|
NS_DECL_NSIDOMATTR
|
|
|
|
|
2014-03-17 21:48:19 -07:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
2011-06-23 19:17:58 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIAttribute interface
|
2013-05-29 13:43:41 -07:00
|
|
|
void SetMap(nsDOMAttributeMap *aMap) MOZ_OVERRIDE;
|
2014-04-10 09:09:50 -07:00
|
|
|
Element* GetElement() const;
|
2013-05-29 13:43:41 -07:00
|
|
|
nsresult SetOwnerDocument(nsIDocument* aDocument) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsINode interface
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
|
|
|
|
virtual uint32_t GetChildCount() const MOZ_OVERRIDE;
|
|
|
|
virtual nsIContent *GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
|
|
|
|
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const MOZ_OVERRIDE;
|
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,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
|
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE;
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
2013-09-24 14:56:52 -07:00
|
|
|
virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2013-05-06 16:37:47 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
|
|
|
|
nsIAttribute)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-25 06:47:30 -07:00
|
|
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
2013-04-09 08:29:47 -07:00
|
|
|
|
|
|
|
// WebIDL
|
2014-10-07 02:44:48 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx) MOZ_OVERRIDE;
|
2013-04-09 08:29:47 -07:00
|
|
|
|
|
|
|
// XPCOM GetName() is OK
|
|
|
|
// XPCOM GetValue() is OK
|
|
|
|
|
|
|
|
void SetValue(const nsAString& aValue, ErrorResult& aRv);
|
|
|
|
|
|
|
|
bool Specified() const;
|
|
|
|
|
|
|
|
// XPCOM GetNamespaceURI() is OK
|
|
|
|
// XPCOM GetPrefix() is OK
|
|
|
|
// XPCOM GetLocalName() is OK
|
|
|
|
|
2014-03-21 13:04:09 -07:00
|
|
|
Element* GetOwnerElement(ErrorResult& aRv);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2013-05-04 00:55:53 -07:00
|
|
|
virtual Element* GetNameSpaceElement()
|
2010-04-19 08:40:16 -07:00
|
|
|
{
|
2014-04-10 09:09:50 -07:00
|
|
|
return GetElement();
|
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);
|
2012-04-03 00:25:39 -07:00
|
|
|
|
|
|
|
nsString mValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-04-09 08:29:44 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-09 08:29:44 -07:00
|
|
|
#endif /* mozilla_dom_Attr_h */
|