2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-03-30 08:03:04 +00:00
|
|
|
|
|
|
|
/*
|
2006-03-31 08:41:49 +00:00
|
|
|
* Implementation of DOM Core's nsIDOMAttr node.
|
2006-03-30 08:03:04 +00:00
|
|
|
*/
|
|
|
|
|
2013-04-09 15:29:44 +00:00
|
|
|
#ifndef mozilla_dom_Attr_h
|
|
|
|
#define mozilla_dom_Attr_h
|
1999-01-12 08:45:23 +00:00
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2003-01-22 03:25:51 +00:00
|
|
|
#include "nsIAttribute.h"
|
1999-01-12 08:45:23 +00:00
|
|
|
#include "nsIDOMAttr.h"
|
|
|
|
#include "nsIDOMText.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsString.h"
|
2000-06-23 00:21:32 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2007-01-04 22:31:26 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-05-27 19:10:33 +00:00
|
|
|
#include "nsStubMutationObserver.h"
|
2014-08-18 14:44:50 +00:00
|
|
|
|
|
|
|
class nsIDocument;
|
1999-01-12 08:45:23 +00:00
|
|
|
|
2013-04-09 15:29:44 +00:00
|
|
|
namespace mozilla {
|
2014-03-18 04:48:19 +00:00
|
|
|
class EventChainPreVisitor;
|
2013-04-09 15:29:44 +00:00
|
|
|
namespace dom {
|
|
|
|
|
1999-01-12 08:45:23 +00:00
|
|
|
// Attribute helper class used to wrap up an attribute with a dom
|
2011-06-25 07:33:32 +00:00
|
|
|
// object that implements nsIDOMAttr and nsIDOMNode
|
2015-03-21 16:28:04 +00:00
|
|
|
class Attr final : public nsIAttribute,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsIDOMAttr
|
1999-01-12 08:45:23 +00:00
|
|
|
{
|
2014-06-25 02:09:15 +00:00
|
|
|
virtual ~Attr() {}
|
|
|
|
|
1999-01-12 08:45:23 +00:00
|
|
|
public:
|
2013-04-09 15:29:44 +00:00
|
|
|
Attr(nsDOMAttributeMap* aAttrMap,
|
2014-06-20 02:01:40 +00:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-04-09 15:29:44 +00:00
|
|
|
const nsAString& aValue,
|
|
|
|
bool aNsAware);
|
1999-01-12 08:45:23 +00:00
|
|
|
|
2007-01-04 22:31:26 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2005-12-03 07:42:40 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
// nsIDOMNode interface
|
2012-10-09 12:31:24 +00:00
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
2014-08-05 10:10:00 +00:00
|
|
|
virtual void GetTextContentInternal(nsAString& aTextContent,
|
2015-03-21 16:28:04 +00:00
|
|
|
ErrorResult& aError) override;
|
2012-10-09 12:31:24 +00:00
|
|
|
virtual void SetTextContentInternal(const nsAString& aTextContent,
|
2015-03-21 16:28:04 +00:00
|
|
|
ErrorResult& aError) override;
|
|
|
|
virtual void GetNodeValueInternal(nsAString& aNodeValue) override;
|
2012-10-09 12:31:24 +00:00
|
|
|
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
|
2015-03-21 16:28:04 +00:00
|
|
|
ErrorResult& aError) override;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
|
1999-01-12 08:45:23 +00:00
|
|
|
// nsIDOMAttr interface
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
NS_DECL_NSIDOMATTR
|
2004-01-24 00:46:17 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override;
|
2011-06-24 02:17:58 +00:00
|
|
|
|
2003-01-22 03:25:51 +00:00
|
|
|
// nsIAttribute interface
|
2015-03-21 16:28:04 +00:00
|
|
|
void SetMap(nsDOMAttributeMap *aMap) override;
|
2014-04-10 16:09:50 +00:00
|
|
|
Element* GetElement() const;
|
2015-03-21 16:28:04 +00:00
|
|
|
nsresult SetOwnerDocument(nsIDocument* aDocument) override;
|
2005-06-06 08:51:40 +00:00
|
|
|
|
2006-01-25 20:49:56 +00:00
|
|
|
// nsINode interface
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
|
|
|
virtual uint32_t GetChildCount() const override;
|
|
|
|
virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
|
|
|
|
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const override;
|
|
|
|
virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aNotify) override;
|
|
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
|
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
|
|
|
virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
|
2006-09-05 10:22:54 +00:00
|
|
|
|
2005-08-19 23:40:42 +00:00
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2013-05-06 23:37:47 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
|
|
|
|
nsIAttribute)
|
2007-01-04 22:31:26 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsIDOMNode* AsDOMNode() override { return this; }
|
2013-04-09 15:29:47 +00:00
|
|
|
|
|
|
|
// WebIDL
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-04-09 15:29:47 +00: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 20:04:09 +00:00
|
|
|
Element* GetOwnerElement(ErrorResult& aRv);
|
|
|
|
|
2005-08-19 23:40:42 +00:00
|
|
|
protected:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual Element* GetNameSpaceElement() override
|
2010-04-19 15:40:16 +00:00
|
|
|
{
|
2014-04-10 16:09:50 +00:00
|
|
|
return GetElement();
|
2010-04-19 15:40:16 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool sInitialized;
|
1999-01-12 08:45:23 +00:00
|
|
|
|
|
|
|
private:
|
2012-04-03 07:25:39 +00:00
|
|
|
nsString mValue;
|
1999-01-12 08:45:23 +00:00
|
|
|
};
|
|
|
|
|
2013-04-09 15:29:44 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
1999-01-12 08:45:23 +00:00
|
|
|
|
2013-04-09 15:29:44 +00:00
|
|
|
#endif /* mozilla_dom_Attr_h */
|