2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 "nsIDOM3Attr.h"
|
|
|
|
#include "nsDOMAttributeMap.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2008-07-19 08:11:37 -07:00
|
|
|
#include "nsContentUtils.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-14 00:56:48 -07:00
|
|
|
// object that implements nsIDOMAttr, nsIDOM3Attr, nsIDOMNode
|
2007-12-15 01:45:33 -08:00
|
|
|
class nsDOMAttribute : public nsIAttribute,
|
|
|
|
public nsIDOMAttr,
|
2010-05-27 12:10:33 -07:00
|
|
|
public nsIDOM3Attr,
|
|
|
|
public nsStubMutationObserver
|
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,
|
|
|
|
PRBool aNsAware);
|
2008-07-11 13:42:19 -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
|
|
|
|
|
|
|
|
// nsIDOM3Attr interface
|
|
|
|
NS_DECL_NSIDOM3ATTR
|
|
|
|
|
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
|
|
|
|
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
|
|
|
virtual PRUint32 GetChildCount() const;
|
|
|
|
virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
|
2008-12-03 06:02:03 -08:00
|
|
|
virtual nsIContent * const * GetChildArray(PRUint32* aChildCount) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
|
|
|
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
|
|
|
PRBool aNotify);
|
|
|
|
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
2011-05-25 10:58:23 -07:00
|
|
|
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool 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-05-27 12:10:33 -07:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
virtual nsXPCClassInfo* GetClassInfo();
|
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
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static PRBool sInitialized;
|
|
|
|
|
|
|
|
private:
|
2009-12-28 06:35:06 -08:00
|
|
|
already_AddRefed<nsIAtom> GetNameAtom(nsIContent* aContent);
|
|
|
|
|
2010-05-27 12:10:33 -07:00
|
|
|
void EnsureChildState();
|
2009-01-02 09:00:18 -08:00
|
|
|
|
2010-10-07 03:04:25 -07:00
|
|
|
/**
|
|
|
|
* Really removing the attribute child (unbind and release).
|
|
|
|
*/
|
2010-10-12 06:09:46 -07:00
|
|
|
void doRemoveChild(bool aNotify);
|
2010-10-07 03:04:25 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsString mValue;
|
2008-07-11 13:42:19 -07:00
|
|
|
// XXX For now, there's only a single child - a text element
|
|
|
|
// representing the value. This is strong ref, but we use a raw
|
|
|
|
// pointer so we can implement GetChildArray().
|
|
|
|
nsIContent* mChild;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-30 06:42:11 -07:00
|
|
|
mozilla::dom::Element *GetContentInternal() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mAttrMap ? mAttrMap->GetContent() : nsnull;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* nsDOMAttribute_h___ */
|