mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 664123 - Backout bugs 659053 and 659539 (changesets 9c49f69d8bab-1b11c64ffcdf)
This commit is contained in:
parent
b16a451383
commit
e369dd9f77
@ -43,6 +43,7 @@
|
||||
#include "nsAccessNode.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
|
@ -69,6 +69,7 @@ static fp_except_t oldmask = fpsetmask(~allmask);
|
||||
#include "nsContentList.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIXPCScriptable.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsIScriptRuntime.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
@ -302,10 +303,10 @@ public:
|
||||
static PRBool PositionIsBefore(nsINode* aNode1,
|
||||
nsINode* aNode2)
|
||||
{
|
||||
return (aNode2->CompareDocPosition(aNode1) &
|
||||
(nsIDOMNode::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED)) ==
|
||||
nsIDOMNode::DOCUMENT_POSITION_PRECEDING;
|
||||
return (aNode2->CompareDocumentPosition(aNode1) &
|
||||
(nsIDOM3Node::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED)) ==
|
||||
nsIDOM3Node::DOCUMENT_POSITION_PRECEDING;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -341,6 +342,7 @@ public:
|
||||
* @return The reversed document position flags.
|
||||
*
|
||||
* @see nsIDOMNode
|
||||
* @see nsIDOM3Node
|
||||
*/
|
||||
static PRUint16 ReverseDocumentPosition(PRUint16 aDocumentPosition);
|
||||
|
||||
@ -546,7 +548,6 @@ public:
|
||||
static nsresult GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsNodeInfoManager* aNodeInfoManager,
|
||||
PRUint16 aNodeType,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
|
||||
static void SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
||||
@ -690,9 +691,7 @@ public:
|
||||
nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
|
||||
|
||||
*aResult = niMgr->GetNodeInfo(aName, aNodeInfo->GetPrefixAtom(),
|
||||
aNodeInfo->NamespaceID(),
|
||||
aNodeInfo->NodeType(),
|
||||
aNodeInfo->GetExtraName()).get();
|
||||
aNodeInfo->NamespaceID()).get();
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -928,6 +928,12 @@ public:
|
||||
nsresult LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI) const;
|
||||
|
||||
nsIAtom* LookupPrefix(const nsAString& aNamespaceURI);
|
||||
|
||||
PRBool IsEqual(nsIContent *aOther);
|
||||
|
||||
virtual PRBool IsEqualNode(nsINode* aOther);
|
||||
|
||||
/**
|
||||
* If this content has independent selection, e.g., if this is input field
|
||||
* or textarea, this return TRUE. Otherwise, false.
|
||||
|
@ -436,22 +436,7 @@ public:
|
||||
return IsInDoc() ? GetOwnerDoc() : nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* The values returned by this function are the ones defined for
|
||||
* nsIDOMNode.nodeType
|
||||
*/
|
||||
PRUint16 NodeType() const
|
||||
{
|
||||
return mNodeInfo->NodeType();
|
||||
}
|
||||
const nsString& NodeName() const
|
||||
{
|
||||
return mNodeInfo->NodeName();
|
||||
}
|
||||
const nsString& LocalName() const
|
||||
{
|
||||
return mNodeInfo->LocalName();
|
||||
}
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType) = 0;
|
||||
|
||||
nsINode*
|
||||
InsertBefore(nsINode *aNewChild, nsINode *aRefChild, nsresult *aReturn)
|
||||
@ -984,16 +969,13 @@ public:
|
||||
*/
|
||||
virtual already_AddRefed<nsIURI> GetBaseURI() const = 0;
|
||||
|
||||
nsresult GetDOMBaseURI(nsAString &aURI) const;
|
||||
void GetBaseURI(nsAString &aURI) const;
|
||||
|
||||
// Note! This function must never fail. It only return an nsresult so that
|
||||
// we can use it to implement nsIDOMNode
|
||||
NS_IMETHOD GetTextContent(nsAString &aTextContent)
|
||||
virtual void GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
SetDOMStringToNull(aTextContent);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD SetTextContent(const nsAString& aTextContent)
|
||||
virtual nsresult SetTextContent(const nsAString& aTextContent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1033,13 +1015,9 @@ public:
|
||||
return static_cast<nsIVariant*>(GetProperty(DOM_USER_DATA, key));
|
||||
}
|
||||
|
||||
nsresult GetUserData(const nsAString& aKey, nsIVariant** aResult)
|
||||
{
|
||||
NS_IF_ADDREF(*aResult = GetUserData(aKey));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult GetFeature(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
nsISupports** aReturn);
|
||||
|
||||
/**
|
||||
* Compares the document position of a node to this node.
|
||||
@ -1051,33 +1029,34 @@ public:
|
||||
* DOCUMENT_POSITION_PRECEDING will be set.
|
||||
*
|
||||
* @see nsIDOMNode
|
||||
* @see nsIDOM3Node
|
||||
*/
|
||||
PRUint16 CompareDocPosition(nsINode* aOtherNode);
|
||||
nsresult CompareDocPosition(nsINode* aOtherNode, PRUint16* aReturn)
|
||||
PRUint16 CompareDocumentPosition(nsINode* aOtherNode);
|
||||
nsresult CompareDocumentPosition(nsINode* aOtherNode, PRUint16* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG(aOtherNode);
|
||||
*aReturn = CompareDocPosition(aOtherNode);
|
||||
|
||||
*aResult = CompareDocumentPosition(aOtherNode);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult CompareDocumentPosition(nsIDOMNode* aOther,
|
||||
PRUint16* aReturn);
|
||||
|
||||
nsresult IsSameNode(nsIDOMNode* aOther,
|
||||
PRBool* aReturn);
|
||||
PRBool IsSameNode(nsINode *aOtherNode)
|
||||
{
|
||||
return aOtherNode == this;
|
||||
}
|
||||
|
||||
nsresult LookupPrefix(const nsAString& aNamespaceURI, nsAString& aPrefix);
|
||||
nsresult IsDefaultNamespace(const nsAString& aNamespaceURI, PRBool* aResult)
|
||||
virtual PRBool IsEqualNode(nsINode *aOtherNode) = 0;
|
||||
|
||||
void LookupPrefix(const nsAString& aNamespaceURI, nsAString& aPrefix);
|
||||
PRBool IsDefaultNamespace(const nsAString& aNamespaceURI)
|
||||
{
|
||||
nsAutoString defaultNamespace;
|
||||
LookupNamespaceURI(EmptyString(), defaultNamespace);
|
||||
*aResult = aNamespaceURI.Equals(defaultNamespace);
|
||||
return NS_OK;
|
||||
return aNamespaceURI.Equals(defaultNamespace);
|
||||
}
|
||||
nsresult LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI);
|
||||
|
||||
nsresult IsEqualNode(nsIDOMNode* aOther, PRBool* aReturn);
|
||||
PRBool IsEqualTo(nsINode* aOther);
|
||||
void LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI);
|
||||
|
||||
nsIContent* GetNextSibling() const { return mNextSibling; }
|
||||
nsIContent* GetPreviousSibling() const { return mPreviousSibling; }
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODEINFO_IID)
|
||||
|
||||
nsINodeInfo()
|
||||
: mInner(nsnull, nsnull, kNameSpaceID_None, 0, nsnull),
|
||||
: mInner(nsnull, nsnull, kNameSpaceID_None),
|
||||
mOwnerManager(nsnull)
|
||||
{
|
||||
}
|
||||
@ -121,17 +121,12 @@ public:
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the node's nodeName as defined in DOM Core
|
||||
* As above, but return the qualified name in corrected case as
|
||||
* needed. For example, for HTML elements in HTML documents, this
|
||||
* will return an ASCII-uppercased version of the qualified name.
|
||||
*/
|
||||
const nsString& NodeName() const {
|
||||
return mNodeName;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the node's localName as defined in DOM Core
|
||||
*/
|
||||
const nsString& LocalName() const {
|
||||
return mLocalName;
|
||||
const nsString& QualifiedNameCorrectedCase() const {
|
||||
return mQualifiedNameCorrectedCase;
|
||||
}
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
@ -164,35 +159,30 @@ public:
|
||||
|
||||
/*
|
||||
* Get the namespace URI for a node, if the node has a namespace URI.
|
||||
*
|
||||
* For the HTML element "<body>" in a HTML document this will return a null
|
||||
* string and for the XML element "<html:body>" (assuming that this element,
|
||||
* or one of its ancestors has an
|
||||
* xmlns:html='http://www.w3.org/1999/xhtml' attribute) this will return
|
||||
* the string "http://www.w3.org/1999/xhtml".
|
||||
*/
|
||||
virtual nsresult GetNamespaceURI(nsAString& aNameSpaceURI) const = 0;
|
||||
|
||||
/*
|
||||
* Get the namespace ID for a node if the node has a namespace, if not this
|
||||
* returns kNameSpaceID_None.
|
||||
*
|
||||
* For the HTML element "<body>" in a HTML document this will return
|
||||
* kNameSpaceID_None and for the XML element "<html:body>" (assuming that
|
||||
* this element, or one of its ancestors has an
|
||||
* xmlns:html='http://www.w3.org/1999/xhtml' attribute) this will return
|
||||
* the namespace ID for "http://www.w3.org/1999/xhtml".
|
||||
*/
|
||||
PRInt32 NamespaceID() const
|
||||
{
|
||||
return mInner.mNamespaceID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the nodetype for the node. Returns the values specified in nsIDOMNode
|
||||
* for nsIDOMNode.nodeType
|
||||
*/
|
||||
PRUint16 NodeType() const
|
||||
{
|
||||
return mInner.mNodeType;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the extra name, used by PIs and DocTypes, for the node.
|
||||
*/
|
||||
nsIAtom* GetExtraName() const
|
||||
{
|
||||
return mInner.mExtraName;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get and set the ID attribute atom for this node.
|
||||
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
|
||||
@ -332,28 +322,24 @@ protected:
|
||||
public:
|
||||
nsNodeInfoInner()
|
||||
: mName(nsnull), mPrefix(nsnull), mNamespaceID(kNameSpaceID_Unknown),
|
||||
mNodeType(0), mNameString(nsnull), mExtraName(nsnull)
|
||||
mNameString(nsnull)
|
||||
{
|
||||
}
|
||||
nsNodeInfoInner(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
PRUint16 aNodeType, nsIAtom* aExtraName)
|
||||
nsNodeInfoInner(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID)
|
||||
: mName(aName), mPrefix(aPrefix), mNamespaceID(aNamespaceID),
|
||||
mNodeType(aNodeType), mNameString(nsnull), mExtraName(aExtraName)
|
||||
mNameString(nsnull)
|
||||
{
|
||||
}
|
||||
nsNodeInfoInner(const nsAString& aTmpName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, PRUint16 aNodeType)
|
||||
nsNodeInfoInner(const nsAString& aTmpName, nsIAtom *aPrefix, PRInt32 aNamespaceID)
|
||||
: mName(nsnull), mPrefix(aPrefix), mNamespaceID(aNamespaceID),
|
||||
mNodeType(aNodeType), mNameString(&aTmpName), mExtraName(nsnull)
|
||||
mNameString(&aTmpName)
|
||||
{
|
||||
}
|
||||
|
||||
nsIAtom* mName;
|
||||
nsIAtom* mPrefix;
|
||||
PRInt32 mNamespaceID;
|
||||
PRUint16 mNodeType; // As defined by nsIDOMNode.nodeType
|
||||
const nsAString* mNameString;
|
||||
nsIAtom* mExtraName; // Only used by PIs and DocTypes
|
||||
};
|
||||
|
||||
// nsNodeInfoManager needs to pass mInner to the hash table.
|
||||
@ -372,12 +358,9 @@ protected:
|
||||
// Qualified name
|
||||
nsString mQualifiedName;
|
||||
|
||||
// nodeName for the node.
|
||||
nsString mNodeName;
|
||||
|
||||
// localName for the node. This is either equal to mInner.mName, or a
|
||||
// void string, depending on mInner.mNodeType.
|
||||
nsString mLocalName;
|
||||
// Qualified name in "corrected case"; this will depend on our
|
||||
// document and on mNamespaceID.
|
||||
nsString mQualifiedNameCorrectedCase;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeInfo, NS_INODEINFO_IID)
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE(nsGenericDOMDataNode::)
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
@ -63,12 +63,9 @@ public:
|
||||
// nsIDOMComment
|
||||
// Empty interface
|
||||
|
||||
// nsINode
|
||||
// nsIContent
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
PRBool aCloneText) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, PRInt32 aIndent) const;
|
||||
@ -104,8 +101,6 @@ NS_NewCommentNode(nsIContent** aInstancePtrResult,
|
||||
nsCommentNode::nsCommentNode(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::COMMENT_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsCommentNode::~nsCommentNode()
|
||||
@ -132,6 +127,32 @@ nsCommentNode::IsNodeOfType(PRUint32 aFlags) const
|
||||
return !(aFlags & ~(eCONTENT | eCOMMENT | eDATA_NODE));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName.AssignLiteral("#comment");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::COMMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
nsCommentNode::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const
|
||||
{
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsContentList.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -2088,7 +2089,6 @@ nsresult
|
||||
nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsNodeInfoManager* aNodeInfoManager,
|
||||
PRUint16 aNodeType,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
nsIParserService* parserService = GetParserService();
|
||||
@ -2108,11 +2108,11 @@ nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
||||
nsCOMPtr<nsIAtom> prefix = do_GetAtom(Substring(qName.get(), colon));
|
||||
|
||||
rv = aNodeInfoManager->GetNodeInfo(Substring(colon + 1, end), prefix,
|
||||
nsID, aNodeType, aNodeInfo);
|
||||
nsID, aNodeInfo);
|
||||
}
|
||||
else {
|
||||
rv = aNodeInfoManager->GetNodeInfo(aQualifiedName, nsnull, nsID,
|
||||
aNodeType, aNodeInfo);
|
||||
aNodeInfo);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -72,8 +72,7 @@ nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
|
||||
: nsIAttribute(aAttrMap, aNodeInfo, aNsAware), mValue(aValue), mChild(nsnull)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ATTRIBUTE_NODE,
|
||||
"Wrong nodeType");
|
||||
|
||||
|
||||
// We don't add a reference to our content. It will tell us
|
||||
// to drop our reference when it goes away.
|
||||
@ -141,6 +140,7 @@ NS_INTERFACE_TABLE_HEAD(nsDOMAttribute)
|
||||
nsDOMEventRTTearoff::Create(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
|
||||
nsDOMEventRTTearoff::Create(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMXPathNSResolver,
|
||||
new nsNode3Tearoff(this))
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Attr)
|
||||
@ -193,8 +193,7 @@ nsDOMAttribute::SetOwnerDocument(nsIDocument* aDocument)
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
newNodeInfo = aDocument->NodeInfoManager()->
|
||||
GetNodeInfo(mNodeInfo->NameAtom(), mNodeInfo->GetPrefixAtom(),
|
||||
mNodeInfo->NamespaceID(),
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
mNodeInfo->NamespaceID());
|
||||
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ASSERTION(newNodeInfo, "GetNodeInfo lies");
|
||||
mNodeInfo.swap(newNodeInfo);
|
||||
@ -205,7 +204,7 @@ nsDOMAttribute::SetOwnerDocument(nsIDocument* aDocument)
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetName(nsAString& aName)
|
||||
{
|
||||
aName = NodeName();
|
||||
aName = mNodeInfo->QualifiedName();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -500,81 +499,40 @@ nsDOMAttribute::GetBaseURI() const
|
||||
return parent ? parent->GetBaseURI() : nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetDOMBaseURI(nsAString &aURI)
|
||||
PRBool
|
||||
nsDOMAttribute::IsEqualNode(nsINode* aOther)
|
||||
{
|
||||
return nsINode::GetDOMBaseURI(aURI);
|
||||
if (!aOther || !aOther->IsNodeOfType(eATTRIBUTE))
|
||||
return PR_FALSE;
|
||||
|
||||
nsDOMAttribute *other = static_cast<nsDOMAttribute*>(aOther);
|
||||
|
||||
// Prefix, namespace URI, local name, node name check.
|
||||
if (!mNodeInfo->Equals(other->NodeInfo())) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Value check
|
||||
// Checks not needed: Child nodes, attributes.
|
||||
nsAutoString ourValue, otherValue;
|
||||
GetValue(ourValue);
|
||||
other->GetValue(otherValue);
|
||||
|
||||
return ourValue.Equals(otherValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::CompareDocumentPosition(nsIDOMNode *other,
|
||||
PRUint16 *aResult)
|
||||
{
|
||||
return nsINode::CompareDocumentPosition(other, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsEqualNode(nsIDOMNode* aOther, PRBool* aResult)
|
||||
{
|
||||
return nsINode::IsEqualNode(aOther, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsDOMAttribute::GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
return GetNodeValue(aTextContent);
|
||||
GetNodeValue(aTextContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsDOMAttribute::SetTextContent(const nsAString& aTextContent)
|
||||
{
|
||||
return SetNodeValue(aTextContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsSameNode(nsIDOMNode *other, PRBool *aResult)
|
||||
{
|
||||
*aResult = other == this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::LookupPrefix(const nsAString & namespaceURI,
|
||||
nsAString & aResult)
|
||||
{
|
||||
SetDOMStringToNull(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsDefaultNamespace(const nsAString & namespaceURI,
|
||||
PRBool *aResult)
|
||||
{
|
||||
*aResult = namespaceURI.IsEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::LookupNamespaceURI(const nsAString & prefix,
|
||||
nsAString & aResult)
|
||||
{
|
||||
SetDOMStringToNull(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetUserData(const nsAString & key,
|
||||
nsIVariant *data, nsIDOMUserDataHandler *handler,
|
||||
nsIVariant **aResult)
|
||||
{
|
||||
return nsINode::SetUserData(key, data, handler, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetUserData(const nsAString & key, nsIVariant **aResult)
|
||||
{
|
||||
return nsINode::GetUserData(key, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetIsId(PRBool* aReturn)
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "nsStubMutationObserver.h"
|
||||
|
||||
// Attribute helper class used to wrap up an attribute with a dom
|
||||
// object that implements nsIDOMAttr, nsIDOM3Attr, nsIDOMNode
|
||||
// object that implements nsIDOMAttr, nsIDOM3Attr, nsIDOMNode, nsIDOM3Node
|
||||
class nsDOMAttribute : public nsIAttribute,
|
||||
public nsIDOMAttr,
|
||||
public nsIDOM3Attr,
|
||||
@ -112,6 +112,9 @@ public:
|
||||
}
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
virtual already_AddRefed<nsIURI> GetBaseURI() const;
|
||||
virtual PRBool IsEqualNode(nsINode *aOtherNode);
|
||||
virtual void GetTextContent(nsAString &aTextContent);
|
||||
virtual nsresult SetTextContent(const nsAString& aTextContent);
|
||||
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
|
@ -341,8 +341,7 @@ nsDOMAttributeMap::SetNamedItemInternal(nsIDOMNode *aNode,
|
||||
}
|
||||
|
||||
rv = mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(name, nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::ATTRIBUTE_NODE, getter_AddRefs(ni));
|
||||
GetNodeInfo(name, nsnull, kNameSpaceID_None, getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// value is already empty
|
||||
}
|
||||
@ -408,8 +407,7 @@ nsDOMAttributeMap::GetItemAt(PRUint32 aIndex, nsresult *aResult)
|
||||
// have the wrong owner document.
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(name->LocalName(), name->GetPrefix(), name->NamespaceID(),
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
GetNodeInfo(name->LocalName(), name->GetPrefix(), name->NamespaceID());
|
||||
if (ni) {
|
||||
node = GetAttribute(ni, PR_TRUE);
|
||||
}
|
||||
@ -486,8 +484,7 @@ nsDOMAttributeMap::GetNamedItemNSInternal(const nsAString& aNamespaceURI,
|
||||
nameAtom->Equals(aLocalName)) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(nameAtom, name->GetPrefix(), nameSpaceID,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
GetNodeInfo(nameAtom, name->GetPrefix(), nameSpaceID);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (aRemove) {
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIXPConnect.h"
|
||||
@ -78,14 +79,12 @@ NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
nimgr->SetDocumentPrincipal(aPrincipal);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni =
|
||||
nimgr->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nsnull,
|
||||
kNameSpaceID_None,
|
||||
nsIDOMNode::DOCUMENT_TYPE_NODE,
|
||||
aName);
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = nimgr->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nsnull,
|
||||
kNameSpaceID_None);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aDocType = new nsDOMDocumentType(ni.forget(), aPublicId, aSystemId,
|
||||
*aDocType = new nsDOMDocumentType(ni.forget(), aName, aPublicId, aSystemId,
|
||||
aInternalSubset);
|
||||
NS_ADDREF(*aDocType);
|
||||
|
||||
@ -93,16 +92,16 @@ NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
}
|
||||
|
||||
nsDOMDocumentType::nsDOMDocumentType(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
nsIAtom *aName,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset) :
|
||||
nsDOMDocumentTypeForward(aNodeInfo),
|
||||
nsGenericDOMDataNode(aNodeInfo),
|
||||
mName(aName),
|
||||
mPublicId(aPublicId),
|
||||
mSystemId(aSystemId),
|
||||
mInternalSubset(aInternalSubset)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsDOMDocumentType::~nsDOMDocumentType()
|
||||
@ -141,7 +140,7 @@ nsDOMDocumentType::GetText()
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetName(nsAString& aName)
|
||||
{
|
||||
aName = NodeName();
|
||||
mName->ToString(aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -168,11 +167,40 @@ nsDOMDocumentType::GetInternalSubset(nsAString& aInternalSubset)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
mName->ToString(aNodeName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
SetDOMStringToNull(aNodeValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = nsIDOMNode::DOCUMENT_TYPE_NODE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
nsDOMDocumentType::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
|
||||
return new nsDOMDocumentType(ni.forget(), mPublicId, mSystemId,
|
||||
return new nsDOMDocumentType(ni.forget(), mName, mPublicId, mSystemId,
|
||||
mInternalSubset);
|
||||
}
|
||||
|
||||
@ -198,9 +226,7 @@ nsDOMDocumentType::BindToTree(nsIDocument *aDocument, nsIContent *aParent,
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
newNodeInfo = nimgr->GetNodeInfo(mNodeInfo->NameAtom(),
|
||||
mNodeInfo->GetPrefixAtom(),
|
||||
mNodeInfo->NamespaceID(),
|
||||
nsIDOMNode::DOCUMENT_TYPE_NODE,
|
||||
mNodeInfo->GetExtraName());
|
||||
mNodeInfo->NamespaceID());
|
||||
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mNodeInfo.swap(newNodeInfo);
|
||||
|
@ -53,23 +53,12 @@
|
||||
// data. This is done simply for convenience and should be changed if
|
||||
// this restricts what should be done for character data.
|
||||
|
||||
class nsDOMDocumentTypeForward : public nsGenericDOMDataNode,
|
||||
public nsIDOMDocumentType
|
||||
{
|
||||
public:
|
||||
nsDOMDocumentTypeForward(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE(nsGenericDOMDataNode::)
|
||||
};
|
||||
|
||||
class nsDOMDocumentType : public nsDOMDocumentTypeForward
|
||||
class nsDOMDocumentType : public nsGenericDOMDataNode,
|
||||
public nsIDOMDocumentType
|
||||
{
|
||||
public:
|
||||
nsDOMDocumentType(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
nsIAtom *aName,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset);
|
||||
@ -80,36 +69,21 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
// Forwarded by base class
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMDocumentType
|
||||
NS_DECL_NSIDOMDOCUMENTTYPE
|
||||
|
||||
NS_IMETHODIMP GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
SetDOMStringToNull(aNodeValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsINode
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
// nsIContent overrides
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
virtual const nsTextFragment* GetText();
|
||||
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
|
||||
nsIContent *aBindingParent,
|
||||
PRBool aCompileEventHandlers);
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
PRBool aCloneText) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
protected:
|
||||
nsCOMPtr<nsIAtom> mName;
|
||||
nsString mPublicId;
|
||||
nsString mSystemId;
|
||||
nsString mInternalSubset;
|
||||
|
@ -1702,6 +1702,7 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
|
||||
NS_OFFSET_AND_INTERFACE_TABLE_END
|
||||
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDocument)
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMXPathNSResolver,
|
||||
new nsNode3Tearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNodeSelector,
|
||||
@ -1997,8 +1998,6 @@ nsDocument::Init()
|
||||
|
||||
mNodeInfo = mNodeInfoManager->GetDocumentNodeInfo();
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
|
||||
NS_ASSERTION(GetOwnerDoc() == this, "Our nodeinfo is busted!");
|
||||
|
||||
@ -3384,18 +3383,6 @@ nsDocument::IsNodeOfType(PRUint32 aFlags) const
|
||||
return !(aFlags & ~eDOCUMENT);
|
||||
}
|
||||
|
||||
PRUint16
|
||||
nsDocument::NodeType()
|
||||
{
|
||||
return (PRUint16)nsIDOMNode::DOCUMENT_NODE;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::NodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName.AssignLiteral("#document");
|
||||
}
|
||||
|
||||
Element*
|
||||
nsDocument::GetRootElementInternal() const
|
||||
{
|
||||
@ -4386,7 +4373,6 @@ nsDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
nsresult rv = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI,
|
||||
aQualifiedName,
|
||||
mNodeInfoManager,
|
||||
nsIDOMNode::ELEMENT_NODE,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -4519,7 +4505,6 @@ nsDocument::CreateAttribute(const nsAString& aName,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
rv = mNodeInfoManager->GetNodeInfo(aName, nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::ATTRIBUTE_NODE,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -4541,7 +4526,6 @@ nsDocument::CreateAttributeNS(const nsAString & aNamespaceURI,
|
||||
nsresult rv = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI,
|
||||
aQualifiedName,
|
||||
mNodeInfoManager,
|
||||
nsIDOMNode::ATTRIBUTE_NODE,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -5204,8 +5188,7 @@ nsDocument::SetTitle(const nsAString& aTitle)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> titleInfo;
|
||||
titleInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::title, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
if (!titleInfo)
|
||||
return NS_OK;
|
||||
title = NS_NewHTMLTitleElement(titleInfo.forget());
|
||||
@ -5782,81 +5765,35 @@ nsDocument::IsSupported(const nsAString& aFeature, const nsAString& aVersion,
|
||||
aFeature, aVersion, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetDOMBaseURI(nsAString &aURI)
|
||||
{
|
||||
return nsIDocument::GetDOMBaseURI(aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsDocument::GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
SetDOMStringToNull(aTextContent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::IsEqualNode(nsIDOMNode* aOther, PRBool* aResult)
|
||||
PRBool
|
||||
nsDocument::IsEqualNode(nsINode* aOther)
|
||||
{
|
||||
return nsINode::IsEqualNode(aOther, aResult);
|
||||
}
|
||||
if (!aOther || !aOther->IsNodeOfType(eDOCUMENT))
|
||||
return PR_FALSE;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CompareDocumentPosition(nsIDOMNode *other,
|
||||
PRUint16 *aResult)
|
||||
{
|
||||
return nsINode::CompareDocumentPosition(other, aResult);
|
||||
}
|
||||
// Child nodes check.
|
||||
PRUint32 childCount = GetChildCount();
|
||||
if (childCount != aOther->GetChildCount()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::SetTextContent(const nsAString & aTextContent)
|
||||
{
|
||||
return nsINode::SetTextContent(aTextContent);
|
||||
}
|
||||
for (PRUint32 i = 0; i < childCount; i++) {
|
||||
if (!GetChildAt(i)->IsEqual(aOther->GetChildAt(i))) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::IsSameNode(nsIDOMNode *other, PRBool *aResult)
|
||||
{
|
||||
*aResult = other == this;
|
||||
return NS_OK;
|
||||
}
|
||||
/* Checks not needed: Prefix, namespace URI, local name, node name,
|
||||
node value, attributes.
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::LookupPrefix(const nsAString & namespaceURI, nsAString & aResult)
|
||||
{
|
||||
SetDOMStringToNull(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::IsDefaultNamespace(const nsAString & namespaceURI,
|
||||
PRBool *aResult)
|
||||
{
|
||||
*aResult = namespaceURI.IsEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::LookupNamespaceURI(const nsAString & prefix,
|
||||
nsAString & aResult)
|
||||
{
|
||||
SetDOMStringToNull(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::SetUserData(const nsAString & key,
|
||||
nsIVariant *data, nsIDOMUserDataHandler *handler,
|
||||
nsIVariant **aResult)
|
||||
{
|
||||
return nsINode::SetUserData(key, data, handler, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetUserData(const nsAString & key,
|
||||
nsIVariant **aResult)
|
||||
{
|
||||
return nsINode::GetUserData(key, aResult);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -6935,7 +6872,6 @@ nsDocument::CreateElem(const nsAString& aName, nsIAtom *aPrefix, PRInt32 aNamesp
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
mNodeInfoManager->GetNodeInfo(aName, aPrefix, aNamespaceID,
|
||||
nsIDOMNode::ELEMENT_NODE,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMNodeSelector.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIParser.h"
|
||||
@ -718,8 +719,6 @@ public:
|
||||
|
||||
// nsINode
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
virtual PRUint16 NodeType();
|
||||
virtual void NodeName(nsAString& aNodeName);
|
||||
virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
|
||||
virtual nsIContent * const * GetChildArray(PRUint32* aChildCount) const;
|
||||
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
||||
@ -747,6 +746,8 @@ public:
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
virtual PRBool IsEqualNode(nsINode* aOther);
|
||||
virtual void GetTextContent(nsAString &aTextContent);
|
||||
|
||||
// nsIRadioGroupContainer
|
||||
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
|
||||
|
@ -377,7 +377,9 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (node->NodeType()) {
|
||||
PRUint16 type;
|
||||
node->GetNodeType(&type);
|
||||
switch (type) {
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
{
|
||||
mSerializer->AppendText(static_cast<nsIContent*>(node),
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIDOMUserDataHandler.h"
|
||||
@ -58,19 +59,71 @@ class nsDocumentFragment : public nsGenericElement,
|
||||
public nsIDOMDocumentFragment
|
||||
{
|
||||
public:
|
||||
nsDocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual ~nsDocumentFragment();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// interface nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE(nsGenericElement::)
|
||||
|
||||
// interface nsIDOMDocumentFragment
|
||||
// NS_DECL_NSIDOCUMENTFRAGMENT Empty
|
||||
|
||||
nsDocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
virtual ~nsDocumentFragment()
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName)
|
||||
{ return nsGenericElement::GetNodeName(aNodeName); }
|
||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue)
|
||||
{ return nsGenericElement::GetNodeValue(aNodeValue); }
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue)
|
||||
{ return nsGenericElement::SetNodeValue(aNodeValue); }
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode)
|
||||
{ return nsGenericElement::GetParentNode(aParentNode); }
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{ return nsGenericElement::GetChildNodes(aChildNodes); }
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{ return nsGenericElement::GetFirstChild(aFirstChild); }
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild)
|
||||
{ return nsGenericElement::GetLastChild(aLastChild); }
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{ return nsGenericElement::GetPreviousSibling(aPreviousSibling); }
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{ return nsGenericElement::GetNextSibling(aNextSibling); }
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{ return nsGenericElement::GetOwnerDocument(aOwnerDocument); }
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::InsertBefore(aNewChild, aRefChild, aReturn); }
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::ReplaceChild(aNewChild, aOldChild, aReturn); }
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::RemoveChild(aOldChild, aReturn); }
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::AppendChild(aNewChild, aReturn); }
|
||||
NS_IMETHOD HasChildNodes(PRBool* aReturn)
|
||||
{ return nsGenericElement::HasChildNodes(aReturn); }
|
||||
NS_IMETHOD HasAttributes(PRBool* aReturn)
|
||||
{ return nsGenericElement::HasAttributes(aReturn); }
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::CloneNode(aDeep, aReturn); }
|
||||
NS_IMETHOD GetPrefix(nsAString& aPrefix)
|
||||
{ return nsGenericElement::GetPrefix(aPrefix); }
|
||||
NS_IMETHOD SetPrefix(const nsAString& aPrefix);
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI)
|
||||
{ return nsGenericElement::GetNamespaceURI(aNamespaceURI); }
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName)
|
||||
{
|
||||
SetDOMStringToNull(aLocalName);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD Normalize()
|
||||
{ return nsGenericElement::Normalize(); }
|
||||
NS_IMETHOD IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn)
|
||||
{ return nsGenericElement::IsSupported(aFeature, aVersion, aReturn); }
|
||||
|
||||
// nsIContent
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
@ -118,8 +171,7 @@ NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentFragmentNodeName,
|
||||
nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
|
||||
nsnull, kNameSpaceID_None);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsDocumentFragment *it = new nsDocumentFragment(nodeInfo.forget());
|
||||
@ -138,6 +190,10 @@ nsDocumentFragment::nsDocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
ClearIsElement();
|
||||
}
|
||||
|
||||
nsDocumentFragment::~nsDocumentFragment()
|
||||
{
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDocumentFragment::IsNodeOfType(PRUint32 aFlags) const
|
||||
{
|
||||
@ -169,4 +225,17 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericElement)
|
||||
NS_IMPL_ADDREF_INHERITED(nsDocumentFragment, nsGenericElement)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDocumentFragment, nsGenericElement)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::DOCUMENT_FRAGMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::SetPrefix(const nsAString& aPrefix)
|
||||
{
|
||||
return NS_ERROR_DOM_NAMESPACE_ERR;
|
||||
}
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(nsDocumentFragment)
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsMutationEvent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
@ -72,13 +73,6 @@ namespace css = mozilla::css;
|
||||
nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsIContent(aNodeInfo)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE ||
|
||||
mNodeInfo->NodeType() == nsIDOMNode::CDATA_SECTION_NODE ||
|
||||
mNodeInfo->NodeType() == nsIDOMNode::COMMENT_NODE ||
|
||||
mNodeInfo->NodeType() ==
|
||||
nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
|
||||
mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode::~nsGenericDOMDataNode()
|
||||
@ -135,6 +129,7 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
|
||||
nsDOMEventRTTearoff::Create(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
|
||||
new nsNodeSupportsWeakRefTearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMXPathNSResolver,
|
||||
new nsNode3Tearoff(this))
|
||||
// nsNodeSH::PreCreate() depends on the identity pointer being the
|
||||
@ -178,6 +173,14 @@ nsGenericDOMDataNode::GetPrefix(nsAString& aPrefix)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::GetLocalName(nsAString& aLocalName)
|
||||
{
|
||||
SetDOMStringToNull(aLocalName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::Normalize()
|
||||
{
|
||||
|
@ -89,16 +89,6 @@ public:
|
||||
virtual ~nsGenericDOMDataNode();
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName = NodeName();
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = NodeType();
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetNodeValue(nsAString& aNodeValue);
|
||||
nsresult SetNodeValue(const nsAString& aNodeValue);
|
||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
@ -138,20 +128,12 @@ public:
|
||||
return InsertBefore(aNewChild, nsnull, aReturn);
|
||||
}
|
||||
nsresult GetNamespaceURI(nsAString& aNamespaceURI);
|
||||
nsresult GetLocalName(nsAString& aLocalName)
|
||||
{
|
||||
aLocalName = LocalName();
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetLocalName(nsAString& aLocalName);
|
||||
nsresult GetPrefix(nsAString& aPrefix);
|
||||
nsresult Normalize();
|
||||
nsresult IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn);
|
||||
nsresult CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsNodeUtils::CloneNodeImpl(this, aDeep, PR_TRUE, aReturn);
|
||||
}
|
||||
|
||||
// Implementation for nsIDOMCharacterData
|
||||
nsresult GetData(nsAString& aData) const;
|
||||
@ -188,13 +170,15 @@ public:
|
||||
{
|
||||
return nsContentUtils::GetContextForEventHandlers(this, aRv);
|
||||
}
|
||||
NS_IMETHOD GetTextContent(nsAString &aTextContent)
|
||||
virtual void GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
nsresult rv = GetNodeValue(aTextContent);
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
GetNodeValue(aTextContent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetNodeValue() failed?");
|
||||
return rv;
|
||||
}
|
||||
NS_IMETHOD SetTextContent(const nsAString& aTextContent)
|
||||
virtual nsresult SetTextContent(const nsAString& aTextContent)
|
||||
{
|
||||
// Batch possible DOMSubtreeModified events.
|
||||
mozAutoSubtreeModified subtree(GetOwnerDoc(), nsnull);
|
||||
@ -383,4 +367,89 @@ private:
|
||||
already_AddRefed<nsIAtom> GetCurrentValueAtom();
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to
|
||||
* nsGenericDOMDataNode
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
* nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
* PRBool aCloneText) const;
|
||||
*/
|
||||
#define NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA \
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName); \
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName) { \
|
||||
return nsGenericDOMDataNode::GetLocalName(aLocalName); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue); \
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue); \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType); \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return nsGenericDOMDataNode::GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return nsGenericDOMDataNode::GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
|
||||
return nsGenericDOMDataNode::HasChildNodes(aHasChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasAttributes(PRBool* aHasAttributes) { \
|
||||
return nsGenericDOMDataNode::HasAttributes(aHasAttributes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return nsGenericDOMDataNode::GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return nsGenericDOMDataNode::GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return nsGenericDOMDataNode::GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return nsGenericDOMDataNode::GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return nsGenericDOMDataNode::GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::InsertBefore(aNewChild, aRefChild, \
|
||||
aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::AppendChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::ReplaceChild(aNewChild, aOldChild, \
|
||||
aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return nsGenericDOMDataNode::GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) { \
|
||||
return nsGenericDOMDataNode::GetNamespaceURI(aNamespaceURI); \
|
||||
} \
|
||||
NS_IMETHOD GetPrefix(nsAString& aPrefix) { \
|
||||
return nsGenericDOMDataNode::GetPrefix(aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD Normalize() { \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHOD IsSupported(const nsAString& aFeature, \
|
||||
const nsAString& aVersion, \
|
||||
PRBool* aReturn) { \
|
||||
return nsGenericDOMDataNode::IsSupported(aFeature, aVersion, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn) { \
|
||||
return nsNodeUtils::CloneNodeImpl(this, aDeep, PR_TRUE, aReturn); \
|
||||
} \
|
||||
virtual nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo, \
|
||||
PRBool aCloneText) const;
|
||||
|
||||
#endif /* nsGenericDOMDataNode_h___ */
|
||||
|
@ -112,6 +112,7 @@
|
||||
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIDOMNSFeatureFactory.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsIDOMUserDataHandler.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
@ -573,8 +574,8 @@ nsINode::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::GetDOMBaseURI(nsAString &aURI) const
|
||||
void
|
||||
nsINode::GetBaseURI(nsAString &aURI) const
|
||||
{
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
|
||||
@ -584,49 +585,19 @@ nsINode::GetDOMBaseURI(nsAString &aURI) const
|
||||
}
|
||||
|
||||
CopyUTF8toUTF16(spec, aURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsINode::LookupPrefix(const nsAString& aNamespaceURI, nsAString& aPrefix)
|
||||
{
|
||||
Element *element = GetNameSpaceElement();
|
||||
if (element) {
|
||||
// XXX Waiting for DOM spec to list error codes.
|
||||
|
||||
// Trace up the content parent chain looking for the namespace
|
||||
// declaration that defines the aNamespaceURI namespace. Once found,
|
||||
// return the prefix (i.e. the attribute localName).
|
||||
for (nsIContent* content = element; content;
|
||||
content = content->GetParent()) {
|
||||
PRUint32 attrCount = content->GetAttrCount();
|
||||
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
const nsAttrName* name = content->GetAttrNameAt(i);
|
||||
|
||||
if (name->NamespaceEquals(kNameSpaceID_XMLNS) &&
|
||||
content->AttrValueIs(kNameSpaceID_XMLNS, name->LocalName(),
|
||||
aNamespaceURI, eCaseMatters)) {
|
||||
// If the localName is "xmlns", the prefix we output should be
|
||||
// null.
|
||||
nsIAtom *localName = name->LocalName();
|
||||
|
||||
if (localName != nsGkAtoms::xmlns) {
|
||||
localName->ToString(aPrefix);
|
||||
}
|
||||
else {
|
||||
SetDOMStringToNull(aPrefix);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
nsIAtom *prefix = element ? element->LookupPrefix(aNamespaceURI) : nsnull;
|
||||
if (prefix) {
|
||||
prefix->ToString(aPrefix);
|
||||
}
|
||||
else {
|
||||
SetDOMStringToNull(aPrefix);
|
||||
}
|
||||
|
||||
SetDOMStringToNull(aPrefix);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
@ -689,7 +660,7 @@ nsINode::SetUserData(const nsAString &aKey, nsIVariant *aData,
|
||||
}
|
||||
|
||||
PRUint16
|
||||
nsINode::CompareDocPosition(nsINode* aOtherNode)
|
||||
nsINode::CompareDocumentPosition(nsINode* aOtherNode)
|
||||
{
|
||||
NS_PRECONDITION(aOtherNode, "don't pass null");
|
||||
|
||||
@ -726,16 +697,16 @@ nsINode::CompareDocPosition(nsINode* aOtherNode)
|
||||
if (attrName->Equals(attr1->NodeInfo())) {
|
||||
NS_ASSERTION(!attrName->Equals(attr2->NodeInfo()),
|
||||
"Different attrs at same position");
|
||||
return nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
|
||||
nsIDOMNode::DOCUMENT_POSITION_PRECEDING;
|
||||
return nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_PRECEDING;
|
||||
}
|
||||
if (attrName->Equals(attr2->NodeInfo())) {
|
||||
return nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
|
||||
nsIDOMNode::DOCUMENT_POSITION_FOLLOWING;
|
||||
return nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING;
|
||||
}
|
||||
}
|
||||
NS_NOTREACHED("neither attribute in the element");
|
||||
return nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED;
|
||||
return nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED;
|
||||
}
|
||||
|
||||
if (elem) {
|
||||
@ -766,12 +737,12 @@ nsINode::CompareDocPosition(nsINode* aOtherNode)
|
||||
nsINode* top2 = parents2.ElementAt(--pos2);
|
||||
if (top1 != top2) {
|
||||
return top1 < top2 ?
|
||||
(nsIDOMNode::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED |
|
||||
nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC) :
|
||||
(nsIDOMNode::DOCUMENT_POSITION_FOLLOWING |
|
||||
nsIDOMNode::DOCUMENT_POSITION_DISCONNECTED |
|
||||
nsIDOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
|
||||
(nsIDOM3Node::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC) :
|
||||
(nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
|
||||
}
|
||||
|
||||
// Find where the parent chain differs and check indices in the parent.
|
||||
@ -785,8 +756,8 @@ nsINode::CompareDocPosition(nsINode* aOtherNode)
|
||||
// IndexOf will return -1 for the attribute making the attribute be
|
||||
// considered before any child.
|
||||
return parent->IndexOf(child1) < parent->IndexOf(child2) ?
|
||||
static_cast<PRUint16>(nsIDOMNode::DOCUMENT_POSITION_PRECEDING) :
|
||||
static_cast<PRUint16>(nsIDOMNode::DOCUMENT_POSITION_FOLLOWING);
|
||||
static_cast<PRUint16>(nsIDOM3Node::DOCUMENT_POSITION_PRECEDING) :
|
||||
static_cast<PRUint16>(nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING);
|
||||
}
|
||||
parent = child1;
|
||||
}
|
||||
@ -795,191 +766,13 @@ nsINode::CompareDocPosition(nsINode* aOtherNode)
|
||||
// between the chains. That must mean that one node is an ancestor of the
|
||||
// other. The one with the shortest chain must be the ancestor.
|
||||
return pos1 < pos2 ?
|
||||
(nsIDOMNode::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOMNode::DOCUMENT_POSITION_CONTAINS) :
|
||||
(nsIDOMNode::DOCUMENT_POSITION_FOLLOWING |
|
||||
nsIDOMNode::DOCUMENT_POSITION_CONTAINED_BY);
|
||||
(nsIDOM3Node::DOCUMENT_POSITION_PRECEDING |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_CONTAINS) :
|
||||
(nsIDOM3Node::DOCUMENT_POSITION_FOLLOWING |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsINode::IsEqualTo(nsINode* aOther)
|
||||
{
|
||||
if (!aOther) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString string1, string2;
|
||||
|
||||
nsINode* node1 = this;
|
||||
nsINode* node2 = aOther;
|
||||
do {
|
||||
PRUint16 nodeType = node1->NodeType();
|
||||
if (nodeType != node2->NodeType()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (!node1->mNodeInfo->Equals(node2->mNodeInfo)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
switch(nodeType) {
|
||||
case nsIDOMNode::ELEMENT_NODE:
|
||||
{
|
||||
// Both are elements (we checked that their nodeinfos are equal). Do the
|
||||
// check on attributes.
|
||||
Element* element1 = node1->AsElement();
|
||||
Element* element2 = node2->AsElement();
|
||||
PRUint32 attrCount = element1->GetAttrCount();
|
||||
if (attrCount != element2->GetAttrCount()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Iterate over attributes.
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
const nsAttrName* attrName = element1->GetAttrNameAt(i);
|
||||
#ifdef DEBUG
|
||||
PRBool hasAttr =
|
||||
#endif
|
||||
element1->GetAttr(attrName->NamespaceID(), attrName->LocalName(),
|
||||
string1);
|
||||
NS_ASSERTION(hasAttr, "Why don't we have an attr?");
|
||||
|
||||
if (!element2->AttrValueIs(attrName->NamespaceID(),
|
||||
attrName->LocalName(),
|
||||
string1,
|
||||
eCaseMatters)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
case nsIDOMNode::COMMENT_NODE:
|
||||
case nsIDOMNode::CDATA_SECTION_NODE:
|
||||
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
|
||||
{
|
||||
string1.Truncate();
|
||||
static_cast<nsIContent*>(node1)->AppendTextTo(string1);
|
||||
string2.Truncate();
|
||||
static_cast<nsIContent*>(node2)->AppendTextTo(string2);
|
||||
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (nodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) {
|
||||
nsCOMPtr<nsIDOMNode> domNode1 = do_QueryInterface(node1);
|
||||
nsCOMPtr<nsIDOMNode> domNode2 = do_QueryInterface(node2);
|
||||
domNode1->GetNodeName(string1);
|
||||
domNode2->GetNodeName(string2);
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case nsIDOMNode::DOCUMENT_NODE:
|
||||
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
|
||||
break;
|
||||
case nsIDOMNode::ATTRIBUTE_NODE:
|
||||
{
|
||||
NS_ASSERTION(node1 == this && node2 == aOther,
|
||||
"Did we come upon an attribute node while walking a "
|
||||
"subtree?");
|
||||
nsCOMPtr<nsIDOMNode> domNode1 = do_QueryInterface(node1);
|
||||
nsCOMPtr<nsIDOMNode> domNode2 = do_QueryInterface(node2);
|
||||
domNode1->GetNodeValue(string1);
|
||||
domNode2->GetNodeValue(string2);
|
||||
|
||||
// Returning here as to not bother walking subtree. And there is no
|
||||
// risk that we're half way through walking some other subtree since
|
||||
// attribute nodes doesn't appear in subtrees.
|
||||
return string1.Equals(string2);
|
||||
}
|
||||
case nsIDOMNode::DOCUMENT_TYPE_NODE:
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocumentType> docType1 = do_QueryInterface(this);
|
||||
nsCOMPtr<nsIDOMDocumentType> docType2 = do_QueryInterface(aOther);
|
||||
|
||||
NS_ASSERTION(docType1 && docType2, "Why don't we have a document type node?");
|
||||
|
||||
// Node name
|
||||
docType1->GetNodeName(string1);
|
||||
docType2->GetNodeName(string2);
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Public ID
|
||||
docType1->GetPublicId(string1);
|
||||
docType2->GetPublicId(string2);
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// System ID
|
||||
docType1->GetSystemId(string1);
|
||||
docType2->GetSystemId(string2);
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Internal subset
|
||||
docType1->GetInternalSubset(string1);
|
||||
docType2->GetInternalSubset(string2);
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(PR_FALSE, "Unknown node type");
|
||||
}
|
||||
|
||||
nsINode* nextNode = node1->GetFirstChild();
|
||||
if (nextNode) {
|
||||
node1 = nextNode;
|
||||
node2 = node2->GetFirstChild();
|
||||
}
|
||||
else {
|
||||
if (node2->GetFirstChild()) {
|
||||
// node2 has a firstChild, but node1 doesn't
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Find next sibling, possibly walking parent chain.
|
||||
while (1) {
|
||||
if (node1 == this) {
|
||||
NS_ASSERTION(node2 == aOther, "Should have reached the start node "
|
||||
"for both trees at the same time");
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nextNode = node1->GetNextSibling();
|
||||
if (nextNode) {
|
||||
node1 = nextNode;
|
||||
node2 = node2->GetNextSibling();
|
||||
break;
|
||||
}
|
||||
|
||||
if (node2->GetNextSibling()) {
|
||||
// node2 has a nextSibling, but node1 doesn't
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
node1 = node1->GetNodeParent();
|
||||
node2 = node2->GetNodeParent();
|
||||
NS_ASSERTION(node1 && node2, "no parent while walking subtree");
|
||||
}
|
||||
}
|
||||
} while(node2);
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsINode::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI)
|
||||
{
|
||||
@ -988,8 +781,6 @@ nsINode::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
aNamespaceURI))) {
|
||||
SetDOMStringToNull(aNamespaceURI);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1348,17 +1139,249 @@ nsChildContentList::IndexOf(nsIContent* aContent)
|
||||
NS_IMPL_CYCLE_COLLECTION_1(nsNode3Tearoff, mNode)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsNode3Tearoff)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXPathNSResolver)
|
||||
NS_INTERFACE_MAP_END_AGGREGATED(mNode)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsNode3Tearoff)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsNode3Tearoff)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::GetBaseURI(nsAString& aURI)
|
||||
{
|
||||
mNode->GetBaseURI(aURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
mNode->GetTextContent(aTextContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::SetTextContent(const nsAString &aTextContent)
|
||||
{
|
||||
return mNode->SetTextContent(aTextContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::CompareDocumentPosition(nsIDOMNode* aOther,
|
||||
PRUint16* aReturn)
|
||||
{
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
|
||||
return mNode->CompareDocumentPosition(other, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::IsSameNode(nsIDOMNode* aOther,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
*aReturn = mNode->IsSameNode(other);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsIContent::IsEqual(nsIContent* aOther)
|
||||
{
|
||||
// We use nsIContent instead of nsINode for the attributes of elements.
|
||||
|
||||
NS_PRECONDITION(aOther, "Who called IsEqual?");
|
||||
|
||||
nsAutoString string1, string2;
|
||||
|
||||
// Prefix, namespace URI, local name, node name check.
|
||||
if (!NodeInfo()->Equals(aOther->NodeInfo())) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (Tag() == nsGkAtoms::documentTypeNodeName) {
|
||||
nsCOMPtr<nsIDOMDocumentType> docType1 = do_QueryInterface(this);
|
||||
nsCOMPtr<nsIDOMDocumentType> docType2 = do_QueryInterface(aOther);
|
||||
|
||||
NS_ASSERTION(docType1 && docType2, "Why don't we have a document type node?");
|
||||
|
||||
// Public ID
|
||||
docType1->GetPublicId(string1);
|
||||
docType2->GetPublicId(string2);
|
||||
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// System ID
|
||||
docType1->GetSystemId(string1);
|
||||
docType2->GetSystemId(string2);
|
||||
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Internal subset
|
||||
docType1->GetInternalSubset(string1);
|
||||
docType2->GetInternalSubset(string2);
|
||||
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsElement()) {
|
||||
// Both are elements (we checked that their nodeinfos are equal). Do the
|
||||
// check on attributes.
|
||||
Element* element2 = aOther->AsElement();
|
||||
PRUint32 attrCount = GetAttrCount();
|
||||
if (attrCount != element2->GetAttrCount()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Iterate over attributes.
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
const nsAttrName* attrName1 = GetAttrNameAt(i);
|
||||
#ifdef DEBUG
|
||||
PRBool hasAttr =
|
||||
#endif
|
||||
GetAttr(attrName1->NamespaceID(), attrName1->LocalName(), string1);
|
||||
NS_ASSERTION(hasAttr, "Why don't we have an attr?");
|
||||
|
||||
if (!element2->AttrValueIs(attrName1->NamespaceID(),
|
||||
attrName1->LocalName(),
|
||||
string1,
|
||||
eCaseMatters)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Node value check.
|
||||
nsCOMPtr<nsIDOMNode> domNode1 = do_QueryInterface(this);
|
||||
nsCOMPtr<nsIDOMNode> domNode2 = do_QueryInterface(aOther);
|
||||
NS_ASSERTION(domNode1 && domNode2, "How'd we get nsIContent without nsIDOMNode?");
|
||||
domNode1->GetNodeValue(string1);
|
||||
domNode2->GetNodeValue(string2);
|
||||
if (!string1.Equals(string2)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Child nodes count.
|
||||
PRUint32 childCount = GetChildCount();
|
||||
if (childCount != aOther->GetChildCount()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Iterate over child nodes.
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
if (!GetChildAt(i)->IsEqual(aOther->GetChildAt(i))) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsIContent::IsEqualNode(nsINode* aOther)
|
||||
{
|
||||
if (!aOther || !aOther->IsNodeOfType(eCONTENT))
|
||||
return PR_FALSE;
|
||||
|
||||
return IsEqual(static_cast<nsIContent*>(aOther));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::IsEqualNode(nsIDOMNode* aOther, PRBool* aReturn)
|
||||
{
|
||||
// Since we implement nsINode, aOther must as well.
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
|
||||
*aReturn = other && mNode->IsEqualNode(other);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::GetFeature(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
nsISupports** aReturn)
|
||||
{
|
||||
return mNode->GetFeature(aFeature, aVersion, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::SetUserData(const nsAString& aKey,
|
||||
nsIVariant* aData,
|
||||
nsIDOMUserDataHandler* aHandler,
|
||||
nsIVariant** aResult)
|
||||
{
|
||||
return mNode->SetUserData(aKey, aData, aHandler, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::GetUserData(const nsAString& aKey,
|
||||
nsIVariant** aResult)
|
||||
{
|
||||
NS_IF_ADDREF(*aResult = mNode->GetUserData(aKey));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
nsIContent::LookupPrefix(const nsAString& aNamespaceURI)
|
||||
{
|
||||
// XXX Waiting for DOM spec to list error codes.
|
||||
|
||||
// Trace up the content parent chain looking for the namespace
|
||||
// declaration that defines the aNamespaceURI namespace. Once found,
|
||||
// return the prefix (i.e. the attribute localName).
|
||||
for (nsIContent* content = this; content;
|
||||
content = content->GetParent()) {
|
||||
PRUint32 attrCount = content->GetAttrCount();
|
||||
|
||||
for (PRUint32 i = 0; i < attrCount; ++i) {
|
||||
const nsAttrName* name = content->GetAttrNameAt(i);
|
||||
|
||||
if (name->NamespaceEquals(kNameSpaceID_XMLNS) &&
|
||||
content->AttrValueIs(kNameSpaceID_XMLNS, name->LocalName(),
|
||||
aNamespaceURI, eCaseMatters)) {
|
||||
// If the localName is "xmlns", the prefix we output should be
|
||||
// null.
|
||||
nsIAtom *localName = name->LocalName();
|
||||
|
||||
return localName == nsGkAtoms::xmlns ? nsnull : localName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::LookupPrefix(const nsAString& aNamespaceURI,
|
||||
nsAString& aPrefix)
|
||||
{
|
||||
mNode->LookupPrefix(aNamespaceURI, aPrefix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI)
|
||||
{
|
||||
return mNode->LookupNamespaceURI(aNamespacePrefix, aNamespaceURI);
|
||||
mNode->LookupNamespaceURI(aNamespacePrefix, aNamespaceURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNode3Tearoff::IsDefaultNamespace(const nsAString& aNamespaceURI,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
*aReturn = mNode->IsDefaultNamespace(aNamespaceURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
@ -2223,13 +2246,6 @@ nsGenericElement::nsDOMSlots::~nsDOMSlots()
|
||||
nsGenericElement::nsGenericElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: Element(aNodeInfo)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::ELEMENT_NODE ||
|
||||
(mNodeInfo->NodeType() ==
|
||||
nsIDOMNode::DOCUMENT_FRAGMENT_NODE &&
|
||||
mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
|
||||
kNameSpaceID_None)),
|
||||
"Bad NodeType in aNodeInfo");
|
||||
|
||||
// Set the default scriptID to JS - but skip SetScriptTypeID as it
|
||||
// does extra work we know isn't necessary here...
|
||||
SetFlags((nsIProgrammingLanguage::JAVASCRIPT << NODE_SCRIPT_TYPE_OFFSET));
|
||||
@ -2245,14 +2261,14 @@ nsGenericElement::~nsGenericElement()
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName = NodeName();
|
||||
aNodeName = mNodeInfo->QualifiedNameCorrectedCase();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::GetLocalName(nsAString& aLocalName)
|
||||
{
|
||||
aLocalName = LocalName();
|
||||
mNodeInfo->GetName(aLocalName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2275,7 +2291,7 @@ nsGenericElement::SetNodeValue(const nsAString& aNodeValue)
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = NodeType();
|
||||
*aNodeType = (PRUint16)nsIDOMNode::ELEMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2292,6 +2308,26 @@ nsGenericElement::GetPrefix(nsAString& aPrefix)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static already_AddRefed<nsIDOMNSFeatureFactory>
|
||||
GetDOMFeatureFactory(const nsAString& aFeature, const nsAString& aVersion)
|
||||
{
|
||||
nsIDOMNSFeatureFactory *factory = nsnull;
|
||||
nsCOMPtr<nsICategoryManager> categoryManager =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
||||
if (categoryManager) {
|
||||
nsCAutoString featureCategory(NS_DOMNS_FEATURE_PREFIX);
|
||||
AppendUTF16toUTF8(aFeature, featureCategory);
|
||||
nsXPIDLCString contractID;
|
||||
nsresult rv = categoryManager->GetCategoryEntry(featureCategory.get(),
|
||||
NS_ConvertUTF16toUTF8(aVersion).get(),
|
||||
getter_Copies(contractID));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
CallGetService(contractID.get(), &factory); // addrefs
|
||||
}
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::InternalIsSupported(nsISupports* aObject,
|
||||
const nsAString& aFeature,
|
||||
@ -2354,6 +2390,29 @@ nsGenericElement::InternalIsSupported(nsISupports* aObject,
|
||||
}
|
||||
}
|
||||
#endif /* MOZ_SMIL */
|
||||
else {
|
||||
nsCOMPtr<nsIDOMNSFeatureFactory> factory =
|
||||
GetDOMFeatureFactory(aFeature, aVersion);
|
||||
|
||||
if (factory) {
|
||||
factory->HasFeature(aObject, aFeature, aVersion, aReturn);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::GetFeature(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
nsISupports** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
nsCOMPtr<nsIDOMNSFeatureFactory> factory =
|
||||
GetDOMFeatureFactory(aFeature, aVersion);
|
||||
|
||||
if (factory) {
|
||||
factory->GetFeature(this, aFeature, aVersion, aReturn);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2379,15 +2438,14 @@ nsGenericElement::HasAttributes(PRBool* aReturn)
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
if (!IsElement()) {
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aAttributes);
|
||||
nsDOMSlots *slots = DOMSlots();
|
||||
|
||||
if (!slots->mAttributeMap) {
|
||||
slots->mAttributeMap = new nsDOMAttributeMap(this);
|
||||
if (!slots->mAttributeMap) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (!slots->mAttributeMap->Init()) {
|
||||
slots->mAttributeMap = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -2410,7 +2468,7 @@ nsGenericElement::HasChildNodes(PRBool* aReturn)
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::GetTagName(nsAString& aTagName)
|
||||
{
|
||||
aTagName = NodeName();
|
||||
aTagName = mNodeInfo->QualifiedNameCorrectedCase();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2591,7 +2649,6 @@ nsGenericElement::SetAttributeNS(const nsAString& aNamespaceURI,
|
||||
nsresult rv =
|
||||
nsContentUtils::GetNodeInfoFromQName(aNamespaceURI, aQualifiedName,
|
||||
mNodeInfo->NodeInfoManager(),
|
||||
nsIDOMNode::ATTRIBUTE_NODE,
|
||||
getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -2764,56 +2821,69 @@ nsGenericElement::Normalize()
|
||||
for (index = 0; (index < count) && (NS_OK == result); index++) {
|
||||
nsIContent *child = GetChildAt(index);
|
||||
|
||||
switch (child->NodeType()) {
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(child);
|
||||
if (node) {
|
||||
PRUint16 nodeType;
|
||||
node->GetNodeType(&nodeType);
|
||||
|
||||
// ensure that if the text node is empty, it is removed
|
||||
if (0 == child->TextLength()) {
|
||||
if (hasRemoveListeners) {
|
||||
nsContentUtils::MaybeFireNodeRemoved(child, this, doc);
|
||||
}
|
||||
result = RemoveChildAt(index, PR_TRUE);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
switch (nodeType) {
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
|
||||
count--;
|
||||
index--;
|
||||
break;
|
||||
}
|
||||
|
||||
if (index+1 < count) {
|
||||
// Get the sibling. If it's also a text node, then
|
||||
// remove it from the tree and join the two text
|
||||
// nodes.
|
||||
nsCOMPtr<nsIContent> sibling = GetChildAt(index + 1);
|
||||
|
||||
if (sibling->NodeType() == nsIDOMNode::TEXT_NODE) {
|
||||
// ensure that if the text node is empty, it is removed
|
||||
if (0 == child->TextLength()) {
|
||||
if (hasRemoveListeners) {
|
||||
nsContentUtils::MaybeFireNodeRemoved(sibling, this, doc);
|
||||
nsContentUtils::MaybeFireNodeRemoved(child, this, doc);
|
||||
}
|
||||
result = RemoveChildAt(index+1, PR_TRUE);
|
||||
result = RemoveChildAt(index, PR_TRUE);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = JoinTextNodes(child, sibling);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
count--;
|
||||
index--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
if (index+1 < count) {
|
||||
// Get the sibling. If it's also a text node, then
|
||||
// remove it from the tree and join the two text
|
||||
// nodes.
|
||||
nsCOMPtr<nsIContent> sibling = GetChildAt(index + 1);
|
||||
|
||||
case nsIDOMNode::ELEMENT_NODE:
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(child);
|
||||
nsCOMPtr<nsIDOMNode> siblingNode = do_QueryInterface(sibling);
|
||||
|
||||
if (element) {
|
||||
result = element->Normalize();
|
||||
}
|
||||
break;
|
||||
if (siblingNode) {
|
||||
PRUint16 siblingNodeType;
|
||||
siblingNode->GetNodeType(&siblingNodeType);
|
||||
|
||||
if (siblingNodeType == nsIDOMNode::TEXT_NODE) {
|
||||
if (hasRemoveListeners) {
|
||||
nsContentUtils::MaybeFireNodeRemoved(sibling, this, doc);
|
||||
}
|
||||
result = RemoveChildAt(index+1, PR_TRUE);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = JoinTextNodes(child, sibling);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
count--;
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMNode::ELEMENT_NODE:
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(child);
|
||||
|
||||
if (element) {
|
||||
result = element->Normalize();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3455,9 +3525,8 @@ nsGenericElement::GetExistingAttrNameFromQName(const nsAString& aStr) const
|
||||
|
||||
nsINodeInfo* nodeInfo;
|
||||
if (name->IsAtom()) {
|
||||
nodeInfo = mNodeInfo->NodeInfoManager()->
|
||||
GetNodeInfo(name->Atom(), nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::ATTRIBUTE_NODE).get();
|
||||
nodeInfo = mNodeInfo->NodeInfoManager()->GetNodeInfo(name->Atom(), nsnull,
|
||||
kNameSpaceID_None).get();
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(nodeInfo = name->NodeInfo());
|
||||
@ -3594,11 +3663,18 @@ nsINode::doInsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
if (!HasSameOwnerDoc(aKid)) {
|
||||
nsCOMPtr<nsIDOMNode> kid = do_QueryInterface(aKid, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint16 nodeType = 0;
|
||||
rv = kid->GetNodeType(&nodeType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// DocumentType nodes are the only nodes that can have a null
|
||||
// ownerDocument according to the DOM spec, and we need to allow
|
||||
// inserting them w/o calling AdoptNode().
|
||||
if (aKid->NodeType() != nsIDOMNode::DOCUMENT_TYPE_NODE ||
|
||||
aKid->GetOwnerDoc()) {
|
||||
|
||||
if (nodeType != nsIDOMNode::DOCUMENT_TYPE_NODE || aKid->GetOwnerDoc()) {
|
||||
rv = AdoptNodeIntoOwnerDoc(this, aKid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
@ -3812,8 +3888,9 @@ nsGenericElement::SaveSubtreeState()
|
||||
// inserting it's the content before which we're inserting. In the
|
||||
// latter case it may be null.
|
||||
static
|
||||
PRBool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
||||
PRBool aIsReplace, nsIContent* aRefContent)
|
||||
PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
|
||||
nsINode* aParent, PRBool aIsReplace,
|
||||
nsIContent* aRefContent)
|
||||
{
|
||||
NS_PRECONDITION(aNewChild, "Must have new child");
|
||||
NS_PRECONDITION(!aIsReplace || aRefContent,
|
||||
@ -3823,13 +3900,21 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
||||
aParent->IsElement(),
|
||||
"Nodes that are not documents, document fragments or "
|
||||
"elements can't be parents!");
|
||||
#ifdef DEBUG
|
||||
PRUint16 debugNodeType = 0;
|
||||
nsCOMPtr<nsIDOMNode> debugNode(do_QueryInterface(aNewChild));
|
||||
nsresult debugRv = debugNode->GetNodeType(&debugNodeType);
|
||||
|
||||
NS_PRECONDITION(NS_SUCCEEDED(debugRv) && debugNodeType == aNewNodeType,
|
||||
"Bogus node type passed");
|
||||
#endif
|
||||
|
||||
if (aParent && nsContentUtils::ContentIsDescendantOf(aParent, aNewChild)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// The allowed child nodes differ for documents and elements
|
||||
switch (aNewChild->NodeType()) {
|
||||
switch (aNewNodeType) {
|
||||
case nsIDOMNode::COMMENT_NODE :
|
||||
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE :
|
||||
// OK in both cases
|
||||
@ -3945,7 +4030,10 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
|
||||
}
|
||||
// If we can put this content at the the right place, we might be ok;
|
||||
// if not, we bail out.
|
||||
if (!IsAllowedAsChild(childContent, aParent, aIsReplace,
|
||||
nsCOMPtr<nsIDOMNode> childNode(do_QueryInterface(childContent));
|
||||
PRUint16 type;
|
||||
childNode->GetNodeType(&type);
|
||||
if (!IsAllowedAsChild(childContent, type, aParent, aIsReplace,
|
||||
aRefContent)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
@ -3999,7 +4087,9 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
|
||||
PRUint16 nodeType = aNewChild->NodeType();
|
||||
PRUint16 nodeType = 0;
|
||||
nsresult res = aNewChild->GetNodeType(&nodeType);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// Before we do anything else, fire all DOMNodeRemoved mutation events
|
||||
// We do this up front as to avoid having to deal with script running
|
||||
@ -4065,12 +4155,10 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
|
||||
}
|
||||
|
||||
// Make sure that the inserted node is allowed as a child of its new parent.
|
||||
if (!IsAllowedAsChild(newContent, this, aReplace, refContent)) {
|
||||
if (!IsAllowedAsChild(newContent, nodeType, this, aReplace, refContent)) {
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
|
||||
nsresult res;
|
||||
|
||||
// If we're replacing
|
||||
if (aReplace) {
|
||||
refContent = GetChildAt(insPos + 1);
|
||||
@ -4194,34 +4282,7 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::CompareDocumentPosition(nsIDOMNode* aOther, PRUint16* aReturn)
|
||||
{
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
if (!other) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aReturn = CompareDocPosition(other);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::IsEqualNode(nsIDOMNode* aOther, PRBool* aReturn)
|
||||
{
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
*aReturn = IsEqualTo(other);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::IsSameNode(nsIDOMNode* aOther, PRBool* aReturn)
|
||||
{
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
*aReturn = other == this;
|
||||
return NS_OK;
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -4402,6 +4463,7 @@ NS_INTERFACE_MAP_BEGIN(nsGenericElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget,
|
||||
nsDOMEventRTTearoff::Create(this))
|
||||
@ -4665,8 +4727,7 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
|
||||
else {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mNodeInfo->NodeInfoManager()->GetNodeInfo(aName, aPrefix,
|
||||
aNamespaceID,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
aNamespaceID);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = mAttrsAndChildren.SetAndTakeAttr(ni, aParsedValue);
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMNSEventTarget.h"
|
||||
#include "nsIDOMNSElement.h"
|
||||
#include "nsILinkHandler.h"
|
||||
@ -80,6 +81,7 @@ class nsIDOMCSSStyleDeclaration;
|
||||
class nsIURI;
|
||||
class nsINodeInfo;
|
||||
class nsIControllers;
|
||||
class nsIDOMNSFeatureFactory;
|
||||
class nsIEventListenerManager;
|
||||
class nsIScrollableFrame;
|
||||
class nsContentList;
|
||||
@ -129,14 +131,14 @@ private:
|
||||
/**
|
||||
* A tearoff class for nsGenericElement to implement additional interfaces
|
||||
*/
|
||||
class nsNode3Tearoff : public nsIDOMXPathNSResolver
|
||||
class nsNode3Tearoff : public nsIDOM3Node, public nsIDOMXPathNSResolver
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(nsNode3Tearoff)
|
||||
NS_DECL_NSIDOM3NODE
|
||||
|
||||
NS_DECL_NSIDOMXPATHNSRESOLVER
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsNode3Tearoff, nsIDOM3Node)
|
||||
|
||||
nsNode3Tearoff(nsINode *aNode) : mNode(aNode)
|
||||
{
|
||||
@ -343,12 +345,11 @@ public:
|
||||
{
|
||||
return nsContentUtils::GetContextForEventHandlers(this, aRv);
|
||||
}
|
||||
NS_IMETHOD GetTextContent(nsAString &aTextContent)
|
||||
virtual void GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
nsContentUtils::GetNodeTextContent(this, PR_TRUE, aTextContent);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD SetTextContent(const nsAString& aTextContent)
|
||||
virtual nsresult SetTextContent(const nsAString& aTextContent)
|
||||
{
|
||||
return nsContentUtils::SetNodeTextContent(this, aTextContent, PR_FALSE);
|
||||
}
|
||||
|
@ -1089,7 +1089,6 @@ GK_ATOM(headerCSP, "x-content-security-policy")
|
||||
GK_ATOM(headerCSPReportOnly, "x-content-security-policy-report-only")
|
||||
GK_ATOM(headerXFO, "x-frame-options")
|
||||
GK_ATOM(xml, "xml")
|
||||
GK_ATOM(xml_stylesheet, "xml-stylesheet")
|
||||
GK_ATOM(xmlns, "xmlns")
|
||||
GK_ATOM(xmp, "xmp")
|
||||
GK_ATOM(xulcontentsgenerated, "xulcontentsgenerated")
|
||||
|
@ -69,7 +69,6 @@ nsFixedSizeAllocator* nsNodeInfo::sNodeInfoPool = nsnull;
|
||||
// static
|
||||
nsNodeInfo*
|
||||
nsNodeInfo::Create(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
PRUint16 aNodeType, nsIAtom *aExtraName,
|
||||
nsNodeInfoManager *aOwnerManager)
|
||||
{
|
||||
if (!sNodeInfoPool) {
|
||||
@ -89,8 +88,7 @@ nsNodeInfo::Create(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
// Create a new one
|
||||
void* place = sNodeInfoPool->Alloc(sizeof(nsNodeInfo));
|
||||
return place ?
|
||||
new (place) nsNodeInfo(aName, aPrefix, aNamespaceID, aNodeType, aExtraName,
|
||||
aOwnerManager) :
|
||||
new (place) nsNodeInfo(aName, aPrefix, aNamespaceID, aOwnerManager) :
|
||||
nsnull;
|
||||
}
|
||||
|
||||
@ -101,66 +99,44 @@ nsNodeInfo::~nsNodeInfo()
|
||||
|
||||
NS_RELEASE(mInner.mName);
|
||||
NS_IF_RELEASE(mInner.mPrefix);
|
||||
NS_IF_RELEASE(mInner.mExtraName);
|
||||
}
|
||||
|
||||
|
||||
nsNodeInfo::nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
PRUint16 aNodeType, nsIAtom* aExtraName,
|
||||
nsNodeInfoManager *aOwnerManager)
|
||||
{
|
||||
CHECK_VALID_NODEINFO(aNodeType, aName, aNamespaceID, aExtraName);
|
||||
NS_ABORT_IF_FALSE(aOwnerManager, "Invalid aOwnerManager");
|
||||
NS_ABORT_IF_FALSE(aName, "Must have a name");
|
||||
NS_ABORT_IF_FALSE(aOwnerManager, "Must have an owner manager");
|
||||
|
||||
mInner.mName = aName;
|
||||
NS_ADDREF(mInner.mName);
|
||||
|
||||
mInner.mPrefix = aPrefix;
|
||||
NS_IF_ADDREF(mInner.mPrefix);
|
||||
|
||||
// Initialize mInner
|
||||
NS_ADDREF(mInner.mName = aName);
|
||||
NS_IF_ADDREF(mInner.mPrefix = aPrefix);
|
||||
mInner.mNamespaceID = aNamespaceID;
|
||||
mInner.mNodeType = aNodeType;
|
||||
NS_ADDREF(mOwnerManager = aOwnerManager);
|
||||
NS_IF_ADDREF(mInner.mExtraName = aExtraName);
|
||||
|
||||
mOwnerManager = aOwnerManager;
|
||||
NS_ADDREF(mOwnerManager);
|
||||
|
||||
// Now compute our cached members.
|
||||
|
||||
// Qualified name. If we have no prefix, use ToString on
|
||||
// mInner.mName so that we get to share its buffer.
|
||||
if (aPrefix) {
|
||||
mQualifiedName = nsDependentAtomString(mInner.mPrefix) +
|
||||
NS_LITERAL_STRING(":") +
|
||||
nsDependentAtomString(mInner.mName);
|
||||
aPrefix->ToString(mQualifiedName);
|
||||
mQualifiedName.Append(PRUnichar(':'));
|
||||
mQualifiedName.Append(nsDependentAtomString(mInner.mName));
|
||||
} else {
|
||||
mInner.mName->ToString(mQualifiedName);
|
||||
}
|
||||
|
||||
switch (aNodeType) {
|
||||
case nsIDOMNode::ELEMENT_NODE:
|
||||
case nsIDOMNode::ATTRIBUTE_NODE:
|
||||
// Correct the case for HTML
|
||||
if (aNodeType == nsIDOMNode::ELEMENT_NODE &&
|
||||
aNamespaceID == kNameSpaceID_XHTML && GetDocument() &&
|
||||
GetDocument()->IsHTML()) {
|
||||
nsContentUtils::ASCIIToUpper(mQualifiedName, mNodeName);
|
||||
} else {
|
||||
mNodeName = mQualifiedName;
|
||||
}
|
||||
mInner.mName->ToString(mLocalName);
|
||||
break;
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
case nsIDOMNode::CDATA_SECTION_NODE:
|
||||
case nsIDOMNode::COMMENT_NODE:
|
||||
case nsIDOMNode::DOCUMENT_NODE:
|
||||
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
|
||||
mInner.mName->ToString(mNodeName);
|
||||
SetDOMStringToNull(mLocalName);
|
||||
break;
|
||||
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
|
||||
case nsIDOMNode::DOCUMENT_TYPE_NODE:
|
||||
mInner.mExtraName->ToString(mNodeName);
|
||||
SetDOMStringToNull(mLocalName);
|
||||
break;
|
||||
default:
|
||||
NS_ABORT_IF_FALSE(aNodeType == PR_UINT16_MAX,
|
||||
"Unknown node type");
|
||||
// Qualified name in corrected case
|
||||
if (aNamespaceID == kNameSpaceID_XHTML && GetDocument() &&
|
||||
GetDocument()->IsHTML()) {
|
||||
nsContentUtils::ASCIIToUpper(mQualifiedName, mQualifiedNameCorrectedCase);
|
||||
} else {
|
||||
mQualifiedNameCorrectedCase = mQualifiedName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,14 +69,12 @@ public:
|
||||
* aName and aOwnerManager may not be null.
|
||||
*/
|
||||
static nsNodeInfo *Create(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, PRUint16 aNodeType,
|
||||
nsIAtom *aExtraName,
|
||||
PRInt32 aNamespaceID,
|
||||
nsNodeInfoManager *aOwnerManager);
|
||||
private:
|
||||
nsNodeInfo(); // Unimplemented
|
||||
nsNodeInfo(const nsNodeInfo& aOther); // Unimplemented
|
||||
nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
PRUint16 aNodeType, nsIAtom *aExtraName,
|
||||
nsNodeInfoManager *aOwnerManager);
|
||||
protected:
|
||||
virtual ~nsNodeInfo();
|
||||
@ -98,42 +96,4 @@ private:
|
||||
void LastRelease();
|
||||
};
|
||||
|
||||
#define CHECK_VALID_NODEINFO(_nodeType, _name, _namespaceID, _extraName) \
|
||||
NS_ABORT_IF_FALSE(_nodeType == nsIDOMNode::ELEMENT_NODE || \
|
||||
_nodeType == nsIDOMNode::ATTRIBUTE_NODE || \
|
||||
_nodeType == nsIDOMNode::TEXT_NODE || \
|
||||
_nodeType == nsIDOMNode::CDATA_SECTION_NODE || \
|
||||
_nodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE || \
|
||||
_nodeType == nsIDOMNode::COMMENT_NODE || \
|
||||
_nodeType == nsIDOMNode::DOCUMENT_NODE || \
|
||||
_nodeType == nsIDOMNode::DOCUMENT_TYPE_NODE || \
|
||||
_nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE || \
|
||||
_nodeType == PR_UINT16_MAX, \
|
||||
"Invalid nodeType"); \
|
||||
NS_ABORT_IF_FALSE((_nodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE || \
|
||||
_nodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) == \
|
||||
(_extraName != nsnull), \
|
||||
"Supply aExtraName for and only for PIs and doctypes"); \
|
||||
NS_ABORT_IF_FALSE(_nodeType == nsIDOMNode::ELEMENT_NODE || \
|
||||
_nodeType == nsIDOMNode::ATTRIBUTE_NODE || \
|
||||
_nodeType == PR_UINT16_MAX || \
|
||||
aNamespaceID == kNameSpaceID_None, \
|
||||
"Only attributes and elements can be in a namespace"); \
|
||||
NS_ABORT_IF_FALSE(_name && _name != nsGkAtoms::_empty, "Invalid localName");\
|
||||
NS_ABORT_IF_FALSE(((_nodeType == nsIDOMNode::TEXT_NODE) == \
|
||||
(_name == nsGkAtoms::textTagName)) && \
|
||||
((_nodeType == nsIDOMNode::CDATA_SECTION_NODE) == \
|
||||
(_name == nsGkAtoms::cdataTagName)) && \
|
||||
((_nodeType == nsIDOMNode::COMMENT_NODE) == \
|
||||
(_name == nsGkAtoms::commentTagName)) && \
|
||||
((_nodeType == nsIDOMNode::DOCUMENT_NODE) == \
|
||||
(_name == nsGkAtoms::documentNodeName)) && \
|
||||
((_nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) == \
|
||||
(_name == nsGkAtoms::documentFragmentNodeName)) && \
|
||||
((_nodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) == \
|
||||
(_name == nsGkAtoms::documentTypeNodeName)) && \
|
||||
((_nodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) ==\
|
||||
(_name == nsGkAtoms::processingInstructionTagName)), \
|
||||
"Wrong localName for nodeType");
|
||||
|
||||
#endif /* nsNodeInfo_h___ */
|
||||
|
@ -91,9 +91,7 @@ nsNodeInfoManager::NodeInfoInnerKeyCompare(const void *key1, const void *key2)
|
||||
reinterpret_cast<const nsINodeInfo::nsNodeInfoInner *>(key2);
|
||||
|
||||
if (node1->mPrefix != node2->mPrefix ||
|
||||
node1->mNamespaceID != node2->mNamespaceID ||
|
||||
node1->mNodeType != node2->mNodeType ||
|
||||
node1->mExtraName != node2->mExtraName) {
|
||||
node1->mNamespaceID != node2->mNamespaceID) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -207,13 +205,13 @@ nsNodeInfoManager::DropDocumentReference()
|
||||
|
||||
already_AddRefed<nsINodeInfo>
|
||||
nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, PRUint16 aNodeType,
|
||||
nsIAtom* aExtraName /* = nsnull */)
|
||||
PRInt32 aNamespaceID)
|
||||
{
|
||||
CHECK_VALID_NODEINFO(aNodeType, aName, aNamespaceID, aExtraName);
|
||||
NS_ENSURE_TRUE(aName, nsnull);
|
||||
NS_ASSERTION(!aName->Equals(EmptyString()),
|
||||
"Don't pass an empty string to GetNodeInfo, fix caller.");
|
||||
|
||||
nsINodeInfo::nsNodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType,
|
||||
aExtraName);
|
||||
nsINodeInfo::nsNodeInfoInner tmpKey(aName, aPrefix, aNamespaceID);
|
||||
|
||||
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
|
||||
|
||||
@ -226,8 +224,7 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
}
|
||||
|
||||
nsRefPtr<nsNodeInfo> newNodeInfo =
|
||||
nsNodeInfo::Create(aName, aPrefix, aNamespaceID, aNodeType, aExtraName,
|
||||
this);
|
||||
nsNodeInfo::Create(aName, aPrefix, aNamespaceID, this);
|
||||
NS_ENSURE_TRUE(newNodeInfo, nsnull);
|
||||
|
||||
PLHashEntry *he;
|
||||
@ -245,17 +242,12 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
|
||||
nsresult
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, PRUint16 aNodeType,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aName);
|
||||
CHECK_VALID_NODEINFO(aNodeType, nameAtom, aNamespaceID, nsnull);
|
||||
}
|
||||
#endif
|
||||
NS_ASSERTION(!aName.IsEmpty(),
|
||||
"Don't pass an empty string to GetNodeInfo, fix caller.");
|
||||
|
||||
nsINodeInfo::nsNodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType);
|
||||
nsINodeInfo::nsNodeInfoInner tmpKey(aName, aPrefix, aNamespaceID);
|
||||
|
||||
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
|
||||
|
||||
@ -272,8 +264,7 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsRefPtr<nsNodeInfo> newNodeInfo =
|
||||
nsNodeInfo::Create(nameAtom, aPrefix, aNamespaceID, aNodeType, nsnull,
|
||||
this);
|
||||
nsNodeInfo::Create(nameAtom, aPrefix, aNamespaceID, this);
|
||||
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PLHashEntry *he;
|
||||
@ -289,9 +280,11 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
nsresult
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
PRUint16 aNodeType,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRInt32 nsid = kNameSpaceID_None;
|
||||
|
||||
if (!aNamespaceURI.IsEmpty()) {
|
||||
@ -300,16 +293,15 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return GetNodeInfo(aName, aPrefix, nsid, aNodeType, aNodeInfo);
|
||||
*aNodeInfo = GetNodeInfo(nameAtom, aPrefix, nsid).get();
|
||||
return *aNodeInfo ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
already_AddRefed<nsINodeInfo>
|
||||
nsNodeInfoManager::GetTextNodeInfo()
|
||||
{
|
||||
if (!mTextNodeInfo) {
|
||||
mTextNodeInfo = GetNodeInfo(nsGkAtoms::textTagName, nsnull,
|
||||
kNameSpaceID_None,
|
||||
nsIDOMNode::TEXT_NODE, nsnull).get();
|
||||
mTextNodeInfo = GetNodeInfo(nsGkAtoms::textTagName, nsnull, kNameSpaceID_None).get();
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(mTextNodeInfo);
|
||||
@ -322,9 +314,7 @@ already_AddRefed<nsINodeInfo>
|
||||
nsNodeInfoManager::GetCommentNodeInfo()
|
||||
{
|
||||
if (!mCommentNodeInfo) {
|
||||
mCommentNodeInfo = GetNodeInfo(nsGkAtoms::commentTagName, nsnull,
|
||||
kNameSpaceID_None,
|
||||
nsIDOMNode::COMMENT_NODE, nsnull).get();
|
||||
mCommentNodeInfo = GetNodeInfo(nsGkAtoms::commentTagName, nsnull, kNameSpaceID_None).get();
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(mCommentNodeInfo);
|
||||
@ -337,9 +327,7 @@ already_AddRefed<nsINodeInfo>
|
||||
nsNodeInfoManager::GetDocumentNodeInfo()
|
||||
{
|
||||
if (!mDocumentNodeInfo) {
|
||||
mDocumentNodeInfo = GetNodeInfo(nsGkAtoms::documentNodeName, nsnull,
|
||||
kNameSpaceID_None,
|
||||
nsIDOMNode::DOCUMENT_NODE, nsnull).get();
|
||||
mDocumentNodeInfo = GetNodeInfo(nsGkAtoms::documentNodeName, nsnull, kNameSpaceID_None).get();
|
||||
}
|
||||
else {
|
||||
NS_ADDREF(mDocumentNodeInfo);
|
||||
|
@ -85,14 +85,11 @@ public:
|
||||
* Methods for creating nodeinfo's from atoms and/or strings.
|
||||
*/
|
||||
already_AddRefed<nsINodeInfo> GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID,
|
||||
PRUint16 aNodeType,
|
||||
nsIAtom* aExtraName = nsnull);
|
||||
PRInt32 aNamespaceID);
|
||||
nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, PRUint16 aNodeType,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo);
|
||||
nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
const nsAString& aNamespaceURI, PRUint16 aNodeType,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
|
||||
/**
|
||||
|
@ -502,9 +502,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
|
||||
|
||||
newNodeInfo = nodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(),
|
||||
nodeInfo->GetPrefixAtom(),
|
||||
nodeInfo->NamespaceID(),
|
||||
nodeInfo->NodeType(),
|
||||
nodeInfo->GetExtraName());
|
||||
nodeInfo->NamespaceID());
|
||||
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nodeInfo = newNodeInfo;
|
||||
|
@ -143,8 +143,6 @@ NS_NewTextNode(nsIContent** aInstancePtrResult,
|
||||
nsTextNode::nsTextNode(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsTextNode::~nsTextNode()
|
||||
@ -164,6 +162,32 @@ NS_INTERFACE_TABLE_HEAD(nsTextNode)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Text)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName.AssignLiteral("#text");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextNode::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::TEXT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsTextNode::IsNodeOfType(PRUint32 aFlags) const
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE(nsGenericDOMDataNode::)
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
@ -71,12 +71,9 @@ public:
|
||||
// nsIDOMText
|
||||
NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::)
|
||||
|
||||
// nsINode
|
||||
// nsIContent
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
PRBool aCloneText) const;
|
||||
|
||||
nsresult BindToAttribute(nsIAttribute* aAttr);
|
||||
nsresult UnbindFromAttribute();
|
||||
|
||||
|
@ -80,14 +80,43 @@ nsresult nsTraversal::TestNode(nsINode* aNode, PRInt16* _filtered)
|
||||
|
||||
*_filtered = nsIDOMNodeFilter::FILTER_SKIP;
|
||||
|
||||
PRUint16 nodeType = aNode->NodeType();
|
||||
PRUint16 nodeType = 0;
|
||||
// Check the most common cases
|
||||
if (aNode->IsElement()) {
|
||||
nodeType = nsIDOMNode::ELEMENT_NODE;
|
||||
}
|
||||
else if (aNode->IsNodeOfType(nsINode::eCONTENT)) {
|
||||
nsIAtom* tag = static_cast<nsIContent*>(aNode)->Tag();
|
||||
if (tag == nsGkAtoms::textTagName) {
|
||||
nodeType = nsIDOMNode::TEXT_NODE;
|
||||
}
|
||||
else if (tag == nsGkAtoms::cdataTagName) {
|
||||
nodeType = nsIDOMNode::CDATA_SECTION_NODE;
|
||||
}
|
||||
else if (tag == nsGkAtoms::commentTagName) {
|
||||
nodeType = nsIDOMNode::COMMENT_NODE;
|
||||
}
|
||||
else if (tag == nsGkAtoms::processingInstructionTagName) {
|
||||
nodeType = nsIDOMNode::PROCESSING_INSTRUCTION_NODE;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
if (!nodeType) {
|
||||
domNode = do_QueryInterface(aNode);
|
||||
rv = domNode->GetNodeType(&nodeType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (nodeType <= 12 && !((1 << (nodeType-1)) & mWhatToShow)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mFilter) {
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aNode);
|
||||
if (!domNode) {
|
||||
domNode = do_QueryInterface(aNode);
|
||||
}
|
||||
|
||||
mInAcceptNode = PR_TRUE;
|
||||
rv = mFilter->AcceptNode(domNode, _filtered);
|
||||
mInAcceptNode = PR_FALSE;
|
||||
|
@ -53,7 +53,7 @@ function testComment(aText, aShouldSucceed)
|
||||
checkTypes(comment, "comment", types);
|
||||
|
||||
var interfaces = [ "nsIDOMComment", "nsIDOMCharacterData", "nsIDOMNode",
|
||||
"nsIDOMEventTarget" ];
|
||||
"nsIDOM3Node", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(comment, "comment", interfaces);
|
||||
|
||||
testCharacterData(comment, aText);
|
||||
|
@ -77,7 +77,7 @@ function testComment(aText, aShouldSucceed)
|
||||
checkTypes(comment, "comment", types);
|
||||
|
||||
var interfaces = [ "nsIDOMComment", "nsIDOMCharacterData", "nsIDOMNode",
|
||||
"nsIDOMEventTarget" ];
|
||||
"nsIDOM3Node", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(comment, "comment", interfaces);
|
||||
|
||||
testCharacterData(comment, aText);
|
||||
@ -105,7 +105,7 @@ function testCDATASection(aText, aShouldSucceed)
|
||||
checkTypes(cdataSection, "CDATA section", types);
|
||||
|
||||
var interfaces = [ "nsIDOMCDATASection", "nsIDOMCharacterData",
|
||||
"nsIDOMNode", "nsIDOMEventTarget" ];
|
||||
"nsIDOMNode", "nsIDOM3Node", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(cdataSection, "CDATA section", interfaces);
|
||||
|
||||
testCharacterData(cdataSection, aText);
|
||||
@ -136,7 +136,7 @@ function testPI(aTarget, aData, aShouldSucceed, aReason)
|
||||
checkTypes(pi, "processing instruction", types);
|
||||
|
||||
var interfaces = [ "nsIDOMProcessingInstruction", "nsIDOMNode",
|
||||
"nsIDOMEventTarget" ];
|
||||
"nsIDOM3Node", "nsIDOMEventTarget" ];
|
||||
checkInterfaces(pi, "processing instruction", interfaces);
|
||||
|
||||
is(pi.target, aTarget, "Check target");
|
||||
|
@ -84,8 +84,7 @@ NS_NewHTMLAudioElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
NS_ENSURE_TRUE(doc, nsnull);
|
||||
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::audio, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, nsnull);
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,7 @@ NS_NewHTMLImageElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
NS_ENSURE_TRUE(doc, nsnull);
|
||||
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::img, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, nsnull);
|
||||
}
|
||||
|
||||
|
@ -107,8 +107,7 @@ NS_NewHTMLOptionElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
NS_ENSURE_TRUE(doc, nsnull);
|
||||
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::option, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, nsnull);
|
||||
}
|
||||
|
||||
|
@ -1562,8 +1562,7 @@ nsTextEditorState::CreateRootNode()
|
||||
// Now create a DIV and add it to the anonymous content child list.
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::div, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = NS_NewHTMLElement(getter_AddRefs(mRootNode), nodeInfo.forget(),
|
||||
@ -1640,8 +1639,7 @@ be called if @placeholder is the empty string when trimmed from line breaks");
|
||||
// and add it to the anonymous content child list
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = pNodeInfoManager->GetNodeInfo(nsGkAtoms::div, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = NS_NewHTMLElement(getter_AddRefs(mPlaceholderDiv), nodeInfo.forget(),
|
||||
|
@ -32,7 +32,8 @@ function HTML_TAG(aTagName, aImplClass) {
|
||||
allTags.push(aTagName);
|
||||
classInfos[aTagName] = aImplClass;
|
||||
interfaces[aTagName] =
|
||||
[ "nsIDOMNSElement",
|
||||
[ "nsIDOM3Node",
|
||||
"nsIDOMNSElement",
|
||||
"nsIDOMEventTarget",
|
||||
"nsIDOMNSEventTarget",
|
||||
"nsIDOMNSHTMLElement",
|
||||
|
@ -651,8 +651,7 @@ ImageDocument::CreateSyntheticDocument()
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::img, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mImageContent = NS_NewHTMLImageElement(nodeInfo.forget());
|
||||
|
@ -237,8 +237,7 @@ MediaDocument::CreateSyntheticDocument()
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> root = NS_NewHTMLHtmlElement(nodeInfo.forget());
|
||||
@ -251,8 +250,7 @@ MediaDocument::CreateSyntheticDocument()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Create a <head> so our title has somewhere to live
|
||||
@ -264,8 +262,7 @@ MediaDocument::CreateSyntheticDocument()
|
||||
root->AppendChildTo(head, PR_FALSE);
|
||||
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::body, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> body = NS_NewHTMLBodyElement(nodeInfo.forget());
|
||||
|
@ -298,8 +298,7 @@ PluginDocument::CreateSyntheticPluginDocument()
|
||||
// make plugin content
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::embed, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
rv = NS_NewHTMLElement(getter_AddRefs(mPluginContent), nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
|
@ -112,8 +112,7 @@ VideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
|
||||
// make content
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::video, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE);
|
||||
|
||||
nsRefPtr<nsHTMLMediaElement> element =
|
||||
|
@ -534,8 +534,7 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||
nsAutoString lower;
|
||||
nsContentUtils::ASCIIToLower(aNode.GetText(), lower);
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_XHTML);
|
||||
}
|
||||
else if (mNodeInfoCache[aNodeType]) {
|
||||
nodeInfo = mNodeInfoCache[aNodeType];
|
||||
@ -548,8 +547,7 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||
nsIAtom *name = parserService->HTMLIdToAtomTag(aNodeType);
|
||||
NS_ASSERTION(name, "What? Reverse mapping of id to string broken!!!");
|
||||
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_XHTML);
|
||||
NS_IF_ADDREF(mNodeInfoCache[aNodeType] = nodeInfo);
|
||||
}
|
||||
|
||||
@ -1604,8 +1602,7 @@ HTMLContentSink::Init(nsIDocument* aDoc,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Make root part
|
||||
@ -1621,8 +1618,7 @@ HTMLContentSink::Init(nsIDocument* aDoc,
|
||||
|
||||
// Make head part
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head,
|
||||
nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nsnull, kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mHead = NS_NewHTMLHeadElement(nodeInfo.forget());
|
||||
@ -2599,9 +2595,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
|
||||
// Create content object
|
||||
nsCOMPtr<nsIContent> element;
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::link, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::link, nsnull, kNameSpaceID_XHTML);
|
||||
|
||||
result = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
|
@ -367,8 +367,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name,
|
||||
nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
else if (mNodeInfoCache[nodeType]) {
|
||||
@ -384,8 +383,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
|
||||
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name,
|
||||
nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
|
||||
@ -463,8 +461,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
|
||||
nsContentUtils::ASCIIToLower(aNode.GetText(), lower);
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(lower);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
else if (mNodeInfoCache[nodeType]) {
|
||||
@ -475,8 +472,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
|
||||
NS_ASSERTION(name, "This should not happen!");
|
||||
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
|
||||
}
|
||||
@ -948,7 +944,13 @@ nsHTMLParanoidFragmentSink::NameFromNode(const nsIParserNode& aNode,
|
||||
|
||||
*aResult = nsnull;
|
||||
if (type == eHTMLTag_userdefined) {
|
||||
*aResult = NS_NewAtom(aNode.GetText());
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
rv =
|
||||
mNodeInfoManager->GetNodeInfo(aNode.GetText(), nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_IF_ADDREF(*aResult = nodeInfo->NameAtom());
|
||||
} else {
|
||||
rv = NameFromType(type, aResult);
|
||||
}
|
||||
|
@ -1364,8 +1364,7 @@ nsSVGElement::AddMappedSVGValue(nsIAtom* aName, nsISupports* aValue,
|
||||
else {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mNodeInfo->NodeInfoManager()->GetNodeInfo(aName, nsnull,
|
||||
aNamespaceID,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
aNamespaceID);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = mMappedAttributes.SetAndTakeAttr(ni, attrVal);
|
||||
|
@ -339,9 +339,7 @@ nsSVGUseElement::CreateAnonymousContent()
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::svg, nsnull,
|
||||
kNameSpaceID_SVG,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::svg, nsnull, kNameSpaceID_SVG);
|
||||
if (!nodeInfo)
|
||||
return nsnull;
|
||||
|
||||
|
@ -50,6 +50,7 @@ const nsIDOMSerializer = I.nsIDOMSerializer;
|
||||
const nsIDOMDocument = I.nsIDOMDocument;
|
||||
const nsIDOMElement = I.nsIDOMElement;
|
||||
const nsIDOMNode = I.nsIDOMNode;
|
||||
const nsIDOM3Node = I.nsIDOM3Node;
|
||||
const nsIDOMCharacterData = I.nsIDOMCharacterData;
|
||||
const nsIDOMAttr = I.nsIDOMAttr;
|
||||
const nsIDOMNodeList = I.nsIDOMNodeList;
|
||||
|
@ -404,6 +404,7 @@ function test_isEqualNode_null()
|
||||
// UTILITY FUNCTIONS
|
||||
|
||||
function n(node) { return node ? node.QueryInterface(nsIDOMNode) : null; }
|
||||
function n3(node) { return node ? node.QueryInterface(nsIDOM3Node) : null; }
|
||||
function el(node) { return node ? node.QueryInterface(nsIDOMElement) : null; }
|
||||
function at(node) { return node ? node.QueryInterface(nsIDOMAttr) : null; }
|
||||
|
||||
@ -433,6 +434,9 @@ function equality_check_kids(parentId, areEqual)
|
||||
|
||||
function check_eq_nodes(n1, n2)
|
||||
{
|
||||
n1 = n3(n1);
|
||||
n2 = n3(n2);
|
||||
|
||||
if (n1 && !n1.isEqualNode(n2))
|
||||
do_throw(n1 + " should be equal to " + n2);
|
||||
if (n2 && !n2.isEqualNode(n1))
|
||||
@ -443,6 +447,9 @@ function check_eq_nodes(n1, n2)
|
||||
|
||||
function check_neq_nodes(n1, n2)
|
||||
{
|
||||
n1 = n3(n1);
|
||||
n2 = n3(n2);
|
||||
|
||||
if (n1 && n1.isEqualNode(n2))
|
||||
do_throw(n1 + " should not be equal to " + n2);
|
||||
if (n2 && n2.isEqualNode(n1))
|
||||
|
@ -66,6 +66,7 @@ function isWhitespace(aNode) {
|
||||
*/
|
||||
function getFragment(aNode) {
|
||||
var frag = aNode.ownerDocument.createDocumentFragment();
|
||||
do_check_true(frag instanceof C_i.nsIDOM3Node);
|
||||
for (var i = 0; i < aNode.childNodes.length; i++) {
|
||||
frag.appendChild(aNode.childNodes.item(i).cloneNode(true));
|
||||
}
|
||||
@ -279,7 +280,7 @@ function run_extract_test() {
|
||||
them.
|
||||
|
||||
After the range's extraction or deletion is done, we use
|
||||
nsIDOMNode.isEqualNode() between the altered source fragment and the
|
||||
nsIDOM3Node.isEqualNode() between the altered source fragment and the
|
||||
result fragment. We also run isEqualNode() between the extracted
|
||||
fragment and the fragment from the baseExtract node. If they are not
|
||||
equal, we have failed a test.
|
||||
@ -320,6 +321,8 @@ function run_extract_test() {
|
||||
var foundStart = false;
|
||||
var foundEnd = false;
|
||||
do {
|
||||
do_check_true(walker.currentNode instanceof C_i.nsIDOM3Node);
|
||||
|
||||
if (walker.currentNode.isSameNode(startContainer)) {
|
||||
foundStart = true;
|
||||
}
|
||||
@ -354,6 +357,8 @@ function run_extract_test() {
|
||||
foundStart = false;
|
||||
foundEnd = false;
|
||||
do {
|
||||
do_check_true(walker.currentNode instanceof C_i.nsIDOM3Node);
|
||||
|
||||
if (walker.currentNode.isSameNode(startContainer)) {
|
||||
foundStart = true;
|
||||
}
|
||||
|
@ -954,8 +954,7 @@ nsXBLContentSink::AddAttributesToXULPrototype(const PRUnichar **aAtts,
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
ni = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID);
|
||||
attrs[i].mName.SetTo(ni);
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsSyncLoadService.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsContentErrors.h"
|
||||
@ -950,36 +951,42 @@ nsXBLService::GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
|
||||
nsAutoString nameSpace;
|
||||
|
||||
if (!prefix.IsEmpty()) {
|
||||
child->LookupNamespaceURI(prefix, nameSpace);
|
||||
nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(prefix);
|
||||
|
||||
if (!nameSpace.IsEmpty()) {
|
||||
if (!hasDisplay) {
|
||||
// We extend some widget/frame. We don't really have a
|
||||
// base binding.
|
||||
protoBinding->SetHasBasePrototype(PR_FALSE);
|
||||
//child->UnsetAttr(kNameSpaceID_None, nsGkAtoms::extends, PR_FALSE);
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(child));
|
||||
|
||||
if (node) {
|
||||
node->LookupNamespaceURI(prefix, nameSpace);
|
||||
|
||||
if (!nameSpace.IsEmpty()) {
|
||||
if (!hasDisplay) {
|
||||
// We extend some widget/frame. We don't really have a
|
||||
// base binding.
|
||||
protoBinding->SetHasBasePrototype(PR_FALSE);
|
||||
//child->UnsetAttr(kNameSpaceID_None, nsGkAtoms::extends, PR_FALSE);
|
||||
}
|
||||
|
||||
PRInt32 nameSpaceID =
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceID(nameSpace);
|
||||
|
||||
nsCOMPtr<nsIAtom> tagName = do_GetAtom(display);
|
||||
// Check the white list
|
||||
if (!CheckTagNameWhiteList(nameSpaceID, tagName)) {
|
||||
const PRUnichar* params[] = { display.get() };
|
||||
nsContentUtils::ReportToConsole(nsContentUtils::eXBL_PROPERTIES,
|
||||
"InvalidExtendsBinding",
|
||||
params, NS_ARRAY_LENGTH(params),
|
||||
nsnull,
|
||||
EmptyString(), 0, 0,
|
||||
nsIScriptError::errorFlag,
|
||||
"XBL", doc);
|
||||
NS_ASSERTION(!IsChromeOrResourceURI(aURI),
|
||||
"Invalid extends value");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
protoBinding->SetBaseTag(nameSpaceID, tagName);
|
||||
}
|
||||
|
||||
PRInt32 nameSpaceID =
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceID(nameSpace);
|
||||
|
||||
nsCOMPtr<nsIAtom> tagName = do_GetAtom(display);
|
||||
// Check the white list
|
||||
if (!CheckTagNameWhiteList(nameSpaceID, tagName)) {
|
||||
const PRUnichar* params[] = { display.get() };
|
||||
nsContentUtils::ReportToConsole(nsContentUtils::eXBL_PROPERTIES,
|
||||
"InvalidExtendsBinding",
|
||||
params, NS_ARRAY_LENGTH(params),
|
||||
nsnull,
|
||||
EmptyString(), 0, 0,
|
||||
nsIScriptError::errorFlag,
|
||||
"XBL", doc);
|
||||
NS_ASSERTION(!IsChromeOrResourceURI(aURI),
|
||||
"Invalid extends value");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
protoBinding->SetBaseTag(nameSpaceID, tagName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE(nsGenericDOMDataNode::)
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
@ -64,12 +64,9 @@ public:
|
||||
// nsIDOMCDATASection
|
||||
// Empty interface
|
||||
|
||||
// nsINode
|
||||
// nsIContent
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
PRBool aCloneText) const;
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, PRInt32 aIndent) const;
|
||||
@ -87,8 +84,7 @@ NS_NewXMLCDATASection(nsIContent** aInstancePtrResult,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::cdataTagName,
|
||||
nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::CDATA_SECTION_NODE);
|
||||
nsnull, kNameSpaceID_None);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsXMLCDATASection *instance = new nsXMLCDATASection(ni.forget());
|
||||
@ -104,8 +100,6 @@ NS_NewXMLCDATASection(nsIContent** aInstancePtrResult,
|
||||
nsXMLCDATASection::nsXMLCDATASection(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::CDATA_SECTION_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
}
|
||||
|
||||
nsXMLCDATASection::~nsXMLCDATASection()
|
||||
@ -132,6 +126,32 @@ nsXMLCDATASection::IsNodeOfType(PRUint32 aFlags) const
|
||||
return !(aFlags & ~(eCONTENT | eTEXT | eDATA_NODE));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLCDATASection::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName.AssignLiteral("#cdata-section");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLCDATASection::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLCDATASection::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLCDATASection::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::CDATA_SECTION_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
nsXMLCDATASection::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const
|
||||
{
|
||||
|
@ -50,10 +50,7 @@ NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
{
|
||||
NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager");
|
||||
|
||||
nsCOMPtr<nsIAtom> target = do_GetAtom(aTarget);
|
||||
NS_ENSURE_TRUE(target, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (target == nsGkAtoms::xml_stylesheet) {
|
||||
if (aTarget.EqualsLiteral("xml-stylesheet")) {
|
||||
return NS_NewXMLStylesheetProcessingInstruction(aInstancePtrResult,
|
||||
aNodeInfoManager, aData);
|
||||
}
|
||||
@ -62,13 +59,11 @@ NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::processingInstructionTagName,
|
||||
nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
target);
|
||||
nsnull, kNameSpaceID_None);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsXMLProcessingInstruction *instance =
|
||||
new nsXMLProcessingInstruction(ni.forget(), aData);
|
||||
new nsXMLProcessingInstruction(ni.forget(), aTarget, aData);
|
||||
if (!instance) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -79,13 +74,11 @@ NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
}
|
||||
|
||||
nsXMLProcessingInstruction::nsXMLProcessingInstruction(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
const nsAString& aTarget,
|
||||
const nsAString& aData)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo),
|
||||
mTarget(aTarget)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
|
||||
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
"Bad NodeType in aNodeInfo");
|
||||
|
||||
SetTextInternal(0, mText.GetLength(),
|
||||
aData.BeginReading(), aData.Length(),
|
||||
PR_FALSE); // Don't notify (bug 420429).
|
||||
@ -117,7 +110,7 @@ NS_IMPL_RELEASE_INHERITED(nsXMLProcessingInstruction, nsGenericDOMDataNode)
|
||||
NS_IMETHODIMP
|
||||
nsXMLProcessingInstruction::GetTarget(nsAString& aTarget)
|
||||
{
|
||||
aTarget = NodeName();
|
||||
aTarget.Assign(mTarget);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -149,6 +142,32 @@ nsXMLProcessingInstruction::IsNodeOfType(PRUint32 aFlags) const
|
||||
return !(aFlags & ~(eCONTENT | ePROCESSING_INSTRUCTION | eDATA_NODE));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLProcessingInstruction::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName.Assign(mTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLProcessingInstruction::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLProcessingInstruction::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLProcessingInstruction::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::PROCESSING_INSTRUCTION_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
nsXMLProcessingInstruction::CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
PRBool aCloneText) const
|
||||
@ -156,7 +175,7 @@ nsXMLProcessingInstruction::CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
nsAutoString data;
|
||||
nsGenericDOMDataNode::GetData(data);
|
||||
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
|
||||
return new nsXMLProcessingInstruction(ni.forget(), data);
|
||||
return new nsXMLProcessingInstruction(ni.forget(), mTarget, data);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -170,7 +189,7 @@ nsXMLProcessingInstruction::List(FILE* out, PRInt32 aIndent) const
|
||||
|
||||
nsAutoString tmp;
|
||||
ToCString(tmp, 0, mText.GetLength());
|
||||
tmp.Insert(nsDependentAtomString(NodeInfo()->GetExtraName()).get(), 0);
|
||||
tmp.Insert(mTarget.get(), 0);
|
||||
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
||||
|
||||
fputs(">\n", out);
|
||||
|
@ -50,6 +50,7 @@ class nsXMLProcessingInstruction : public nsGenericDOMDataNode,
|
||||
{
|
||||
public:
|
||||
nsXMLProcessingInstruction(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
const nsAString& aTarget,
|
||||
const nsAString& aData);
|
||||
virtual ~nsXMLProcessingInstruction();
|
||||
|
||||
@ -57,17 +58,14 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_FORWARD_NSIDOMNODE(nsGenericDOMDataNode::)
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMProcessingInstruction
|
||||
NS_DECL_NSIDOMPROCESSINGINSTRUCTION
|
||||
|
||||
// nsINode
|
||||
// nsIContent
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
|
||||
PRBool aCloneText) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, PRInt32 aIndent) const;
|
||||
virtual void DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
|
||||
@ -86,6 +84,8 @@ protected:
|
||||
* aAttribute. Empty if the attribute isn't present.
|
||||
*/
|
||||
PRBool GetAttrValue(nsIAtom *aName, nsAString& aValue);
|
||||
|
||||
nsString mTarget;
|
||||
};
|
||||
|
||||
#endif //nsIXMLProcessingInstruction_h___
|
||||
|
@ -105,7 +105,8 @@ NS_IMPL_RELEASE_INHERITED(nsXMLStylesheetPI, nsXMLProcessingInstruction)
|
||||
|
||||
nsXMLStylesheetPI::nsXMLStylesheetPI(already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
const nsAString& aData)
|
||||
: nsXMLProcessingInstruction(aNodeInfo, aData)
|
||||
: nsXMLProcessingInstruction(aNodeInfo, NS_LITERAL_STRING("xml-stylesheet"),
|
||||
aData)
|
||||
{
|
||||
}
|
||||
|
||||
@ -265,9 +266,7 @@ NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::processingInstructionTagName,
|
||||
nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
nsGkAtoms::xml_stylesheet);
|
||||
nsnull, kNameSpaceID_None);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsXMLStylesheetPI *instance = new nsXMLStylesheetPI(ni.forget(), aData);
|
||||
|
@ -1012,8 +1012,7 @@ nsXMLContentSink::HandleStartElement(const PRUnichar *aName,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
result = CreateElement(aAtts, aAttsCount, nodeInfo, aLineNumber,
|
||||
|
@ -641,6 +641,7 @@ nsXHTMLParanoidFragmentSink::AddAttributes(const PRUnichar** aAtts,
|
||||
nsTArray<const PRUnichar *> allowedAttrs;
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> prefix, localName;
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
||||
if (!mNullPrincipal) {
|
||||
mNullPrincipal = do_CreateInstance(NS_NULLPRINCIPAL_CONTRACTID, &rv);
|
||||
@ -650,8 +651,10 @@ nsXHTMLParanoidFragmentSink::AddAttributes(const PRUnichar** aAtts,
|
||||
while (*aAtts) {
|
||||
nsContentUtils::SplitExpatName(aAtts[0], getter_AddRefs(prefix),
|
||||
getter_AddRefs(localName), &nameSpaceID);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
// check the attributes we allow that contain URIs
|
||||
if (IsAttrURI(localName)) {
|
||||
if (IsAttrURI(nodeInfo->NameAtom())) {
|
||||
if (!aAtts[1])
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (!baseURI)
|
||||
@ -693,16 +696,21 @@ nsXHTMLParanoidFragmentSink::HandleStartElement(const PRUnichar *aName,
|
||||
if (nameSpaceID != kNameSpaceID_XHTML)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// bounce it if it's not on the whitelist or we're inside
|
||||
// <script> or <style>
|
||||
nsCOMPtr<nsIAtom> name = nodeInfo->NameAtom();
|
||||
if (mSkipLevel != 0 ||
|
||||
localName == nsGkAtoms::script ||
|
||||
localName == nsGkAtoms::style) {
|
||||
name == nsGkAtoms::script ||
|
||||
name == nsGkAtoms::style) {
|
||||
++mSkipLevel; // track this so we don't spew script text
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!sAllowedTags || !sAllowedTags->GetEntry(localName))
|
||||
if (!sAllowedTags || !sAllowedTags->GetEntry(name))
|
||||
return NS_OK;
|
||||
|
||||
// It's an allowed element, so let's scrub the attributes
|
||||
@ -710,10 +718,14 @@ nsXHTMLParanoidFragmentSink::HandleStartElement(const PRUnichar *aName,
|
||||
for (PRUint32 i = 0; i < aAttsCount; i += 2) {
|
||||
nsContentUtils::SplitExpatName(aAtts[i], getter_AddRefs(prefix),
|
||||
getter_AddRefs(localName), &nameSpaceID);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
name = nodeInfo->NameAtom();
|
||||
// Add if it's xmlns, xml: or on the HTML whitelist
|
||||
if (nameSpaceID == kNameSpaceID_XMLNS ||
|
||||
nameSpaceID == kNameSpaceID_XML ||
|
||||
(sAllowedAttributes && sAllowedAttributes->GetEntry(localName))) {
|
||||
(sAllowedAttributes && sAllowedAttributes->GetEntry(name))) {
|
||||
allowedAttrs.AppendElement(aAtts[i]);
|
||||
allowedAttrs.AppendElement(aAtts[i + 1]);
|
||||
}
|
||||
@ -740,12 +752,17 @@ nsXHTMLParanoidFragmentSink::HandleEndElement(const PRUnichar *aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIAtom> name = nodeInfo->NameAtom();
|
||||
if (mSkipLevel != 0) {
|
||||
--mSkipLevel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!sAllowedTags || !sAllowedTags->GetEntry(localName)) {
|
||||
if (!sAllowedTags || !sAllowedTags->GetEntry(name)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,10 @@ nsXPathExpression::EvaluateWithContext(nsIDOMNode *aContextNode,
|
||||
}
|
||||
}
|
||||
|
||||
PRUint16 nodeType = context->NodeType();
|
||||
nsresult rv;
|
||||
PRUint16 nodeType;
|
||||
rv = aContextNode->GetNodeType(&nodeType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (nodeType == nsIDOMNode::TEXT_NODE ||
|
||||
nodeType == nsIDOMNode::CDATA_SECTION_NODE) {
|
||||
@ -144,7 +147,7 @@ nsXPathExpression::EvaluateWithContext(nsIDOMNode *aContextNode,
|
||||
EvalContextImpl eContext(*contextNode, aContextPosition, aContextSize,
|
||||
mRecycler);
|
||||
nsRefPtr<txAExprResult> exprResult;
|
||||
nsresult rv = mExpression->evaluate(&eContext, getter_AddRefs(exprResult));
|
||||
rv = mExpression->evaluate(&eContext, getter_AddRefs(exprResult));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint16 resultType = aType;
|
||||
|
@ -55,8 +55,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXPathNSResolver)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
nsXPathNSResolver::nsXPathNSResolver(nsIDOMNode* aNode)
|
||||
: mNode(aNode)
|
||||
{
|
||||
mNode = do_QueryInterface(aNode);
|
||||
NS_ASSERTION(mNode, "Need a node to resolve namespaces.");
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include "nsIDOMXPathNSResolver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
@ -60,7 +61,7 @@ public:
|
||||
NS_DECL_NSIDOMXPATHNSRESOLVER
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMNode> mNode;
|
||||
nsCOMPtr<nsIDOM3Node> mNode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "txXPathTreeWalker.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIAttribute.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
@ -467,11 +468,16 @@ txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
|
||||
}
|
||||
|
||||
if (aNode.isContent()) {
|
||||
// Elements and PIs have a name
|
||||
if (aNode.mNode->IsElement() ||
|
||||
aNode.mNode->NodeType() ==
|
||||
nsIDOMNode::PROCESSING_INSTRUCTION_NODE) {
|
||||
aName = aNode.Content()->NodeName();
|
||||
if (aNode.mNode->IsElement()) {
|
||||
aName = aNode.Content()->NodeInfo()->QualifiedNameCorrectedCase();
|
||||
return;
|
||||
}
|
||||
|
||||
if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
|
||||
// PIs don't have a nodeinfo but do have a name
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode);
|
||||
node->GetNodeName(aName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -481,6 +487,11 @@ txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
|
||||
}
|
||||
|
||||
aNode.Content()->GetAttrNameAt(aNode.mIndex)->GetQualifiedName(aName);
|
||||
|
||||
// Check for html
|
||||
if (aNode.Content()->IsHTML()) {
|
||||
ToUpperCase(aName);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -514,7 +525,11 @@ txXPathNodeUtils::getNodeType(const txXPathNode& aNode)
|
||||
}
|
||||
|
||||
if (aNode.isContent()) {
|
||||
return aNode.mNode->NodeType();
|
||||
PRUint16 type;
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode);
|
||||
node->GetNodeType(&type);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
return txXPathNodeType::ATTRIBUTE_NODE;
|
||||
@ -612,7 +627,13 @@ txXPathNodeUtils::getXSLTId(const txXPathNode& aNode,
|
||||
void
|
||||
txXPathNodeUtils::getBaseURI(const txXPathNode& aNode, nsAString& aURI)
|
||||
{
|
||||
aNode.mNode->GetDOMBaseURI(aURI);
|
||||
nsCOMPtr<nsIDOM3Node> node = do_QueryInterface(aNode.mNode);
|
||||
if (node) {
|
||||
node->GetBaseURI(aURI);
|
||||
}
|
||||
else {
|
||||
aURI.Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -285,8 +285,7 @@ txMozillaTextOutput::createXHTMLElement(nsIAtom* aName,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mDocument->NodeInfoManager()->
|
||||
GetNodeInfo(aName, nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
GetNodeInfo(aName, nsnull, kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_NewHTMLElement(aResult, ni.forget(), NOT_FROM_PARSER);
|
||||
|
@ -561,8 +561,7 @@ txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix,
|
||||
|
||||
// Create the element
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
ni = mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_NewElement(getter_AddRefs(mOpenedElement), aNsID, ni.forget(),
|
||||
@ -969,8 +968,7 @@ txMozillaXMLOutput::createHTMLElement(nsIAtom* aName,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mNodeInfoManager->GetNodeInfo(aName, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_NewHTMLElement(aResult, ni.forget(), mCreatingNewDocument ?
|
||||
|
@ -536,9 +536,7 @@ nsXTFElementWrapper::GetExistingAttrNameFromQName(const nsAString& aStr) const
|
||||
if (!nodeInfo) {
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aStr);
|
||||
if (HandledByInner(nameAtom))
|
||||
nodeInfo = mNodeInfo->NodeInfoManager()->
|
||||
GetNodeInfo(nameAtom, nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::ATTRIBUTE_NODE).get();
|
||||
nodeInfo = mNodeInfo->NodeInfoManager()->GetNodeInfo(nameAtom, nsnull, kNameSpaceID_None).get();
|
||||
}
|
||||
|
||||
return nodeInfo;
|
||||
|
@ -329,9 +329,9 @@ nsXULElement::Create(nsXULPrototypeElement* aPrototype,
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
if (aDocument) {
|
||||
nsINodeInfo* ni = aPrototype->mNodeInfo;
|
||||
nodeInfo = aDocument->NodeInfoManager()->
|
||||
GetNodeInfo(ni->NameAtom(), ni->GetPrefixAtom(), ni->NamespaceID(),
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = aDocument->NodeInfoManager()->GetNodeInfo(ni->NameAtom(),
|
||||
ni->GetPrefixAtom(),
|
||||
ni->NamespaceID());
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
else {
|
||||
@ -2652,8 +2652,7 @@ nsXULPrototypeElement::Serialize(nsIObjectOutputStream* aStream,
|
||||
if (mAttributes[i].mName.IsAtom()) {
|
||||
ni = mNodeInfo->NodeInfoManager()->
|
||||
GetNodeInfo(mAttributes[i].mName.Atom(), nsnull,
|
||||
kNameSpaceID_None,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
kNameSpaceID_None);
|
||||
NS_ASSERTION(ni, "the nodeinfo should already exist");
|
||||
}
|
||||
else {
|
||||
|
@ -465,8 +465,7 @@ XULContentSinkImpl::NormalizeAttributeString(const PRUnichar *aExpatName,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mNodeInfoManager->GetNodeInfo(localName, prefix,
|
||||
nameSpaceID,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
nameSpaceID);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
aName.SetTo(ni);
|
||||
@ -519,8 +518,7 @@ XULContentSinkImpl::HandleStartElement(const PRUnichar *aName,
|
||||
getter_AddRefs(localName), &nameSpaceID);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(localName, prefix, nameSpaceID);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -3704,8 +3704,7 @@ nsXULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
newNodeInfo = mNodeInfoManager->GetNodeInfo(aPrototype->mNodeInfo->NameAtom(),
|
||||
aPrototype->mNodeInfo->GetPrefixAtom(),
|
||||
aPrototype->mNodeInfo->NamespaceID(),
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
aPrototype->mNodeInfo->NamespaceID());
|
||||
if (!newNodeInfo) return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
PRInt32 ns = newNodeInfo->NamespaceID();
|
||||
|
@ -317,11 +317,7 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream)
|
||||
rv |= aStream->ReadString(localName);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
// Using PR_UINT16_MAX here as we don't know which nodeinfos will be
|
||||
// used for attributes and which for elements. And that doesn't really
|
||||
// matter.
|
||||
rv |= mNodeInfoManager->GetNodeInfo(localName, prefix, namespaceURI,
|
||||
PR_UINT16_MAX,
|
||||
getter_AddRefs(nodeInfo));
|
||||
if (!nodeInfos.AppendObject(nodeInfo))
|
||||
rv |= NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -373,8 +369,7 @@ GetNodeInfos(nsXULPrototypeElement* aPrototype,
|
||||
nsAttrName* name = &aPrototype->mAttributes[i].mName;
|
||||
if (name->IsAtom()) {
|
||||
ni = aPrototype->mNodeInfo->NodeInfoManager()->
|
||||
GetNodeInfo(name->Atom(), nsnull, kNameSpaceID_None,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
GetNodeInfo(name->Atom(), nsnull, kNameSpaceID_None);
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
else {
|
||||
|
@ -1401,8 +1401,7 @@ nsXULContentBuilder::CreateElement(PRInt32 aNameSpaceID,
|
||||
nsCOMPtr<nsIContent> result;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(aTag, nsnull, aNameSpaceID,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(aTag, nsnull, aNameSpaceID);
|
||||
|
||||
rv = NS_NewElement(getter_AddRefs(result), aNameSpaceID, nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
|
@ -128,6 +128,7 @@
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIDOMDOMException.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOM3Attr.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
@ -2314,6 +2315,7 @@ nsDOMClassInfo::RegisterExternalClasses()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentXBL) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
|
||||
@ -2323,6 +2325,7 @@ nsDOMClassInfo::RegisterExternalClasses()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
|
||||
@ -2477,6 +2480,7 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentType)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(DOMImplementation, nsIDOMDOMImplementation)
|
||||
@ -2498,6 +2502,7 @@ nsDOMClassInfo::Init()
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(DocumentFragment, nsIDOMDocumentFragment)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentFragment)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
@ -2508,11 +2513,13 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Attr, nsIDOMAttr)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAttr)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Attr)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
@ -2522,24 +2529,28 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMText)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Comment, nsIDOMComment)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMComment)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CDATASection, nsIDOMCDATASection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCDATASection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(ProcessingInstruction, nsIDOMProcessingInstruction)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(NodeList, nsIDOMNodeList)
|
||||
@ -3047,6 +3058,7 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
@ -3089,6 +3101,7 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeWindow, nsIDOMWindow)
|
||||
@ -3161,6 +3174,7 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGElement) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
|
||||
#define DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES \
|
||||
@ -4118,6 +4132,7 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
@ -6289,6 +6304,14 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
||||
rv = DefineInterfaceConstants(cx, class_obj, primary_iid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Special case for |Node|, which needs constants from Node3
|
||||
// too for forwards compatibility.
|
||||
if (primary_iid->Equals(NS_GET_IID(nsIDOMNode))) {
|
||||
rv = DefineInterfaceConstants(cx, class_obj,
|
||||
&NS_GET_IID(nsIDOM3Node));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Special case for |Event|, Event needs constants from NSEvent
|
||||
// too for backwards compatibility.
|
||||
if (primary_iid->Equals(NS_GET_IID(nsIDOMEvent))) {
|
||||
|
@ -1731,7 +1731,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
|
||||
mFocusedContent = aContent;
|
||||
|
||||
nsIContent* focusedNode = aWindow->GetFocusedNode();
|
||||
PRBool isRefocus = focusedNode && focusedNode->IsEqualTo(aContent);
|
||||
PRBool isRefocus = focusedNode && focusedNode->IsEqual(aContent);
|
||||
|
||||
aWindow->SetFocusedNode(aContent, focusMethod);
|
||||
|
||||
@ -2180,9 +2180,13 @@ nsFocusManager::GetSelectionLocation(nsIDocument* aDocument,
|
||||
// logical frame's primary node - so for this case we need to
|
||||
// change caretContent to that node.
|
||||
|
||||
if (startContent->NodeType() == nsIDOMNode::TEXT_NODE) {
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(startContent));
|
||||
PRUint16 nodeType;
|
||||
domNode->GetNodeType(&nodeType);
|
||||
|
||||
if (nodeType == nsIDOMNode::TEXT_NODE) {
|
||||
nsAutoString nodeValue;
|
||||
startContent->AppendTextTo(nodeValue);
|
||||
domNode->GetNodeValue(nodeValue);
|
||||
|
||||
PRBool isFormControl =
|
||||
startContent->IsNodeOfType(nsINode::eHTML_FORM_CONTROL);
|
||||
|
@ -79,6 +79,7 @@ XPIDLSRCS = \
|
||||
nsIDOMJSWindow.idl \
|
||||
nsIDOMModalContentWindow.idl \
|
||||
nsIDOMChromeWindow.idl \
|
||||
nsIDOMNSFeatureFactory.idl \
|
||||
nsIDOMClientRect.idl \
|
||||
nsIDOMClientRectList.idl \
|
||||
nsIFocusManager.idl \
|
||||
|
64
dom/interfaces/base/nsIDOMNSFeatureFactory.idl
Normal file
64
dom/interfaces/base/nsIDOMNSFeatureFactory.idl
Normal file
@ -0,0 +1,64 @@
|
||||
/* -*- 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Olli Pettay.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Olli Pettay <Olli.Pettay@helsinki.fi> (original author)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(dc5ba787-b648-4b01-a8e7-b293ffb044ef)]
|
||||
interface nsIDOMNSFeatureFactory : nsISupports
|
||||
{
|
||||
/**
|
||||
* @param object: usually either nsIDOMNode or nsIDOMDOMImplementation
|
||||
* @param feature: the name of the feature
|
||||
* @param version: the version of the feature
|
||||
*/
|
||||
boolean hasFeature(in nsISupports object,
|
||||
in DOMString feature,
|
||||
in DOMString version);
|
||||
/**
|
||||
* @param object: usually either nsIDOMNode or nsIDOMDOMImplementation
|
||||
* @param feature: the name of the feature
|
||||
* @param version: the version of the feature
|
||||
*/
|
||||
nsISupports getFeature(in nsISupports object,
|
||||
in DOMString feature,
|
||||
in DOMString version);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_DOMNS_FEATURE_PREFIX "MozillaDOMFeature-"
|
||||
%}
|
@ -64,6 +64,7 @@ SDK_XPIDLSRCS = \
|
||||
nsIDOMText.idl \
|
||||
$(NULL)
|
||||
XPIDLSRCS = \
|
||||
nsIDOM3Node.idl \
|
||||
nsIDOM3Attr.idl \
|
||||
nsIDOMDOMStringList.idl \
|
||||
nsIDOMNameList.idl \
|
||||
|
87
dom/interfaces/core/nsIDOM3Node.idl
Normal file
87
dom/interfaces/core/nsIDOM3Node.idl
Normal file
@ -0,0 +1,87 @@
|
||||
/* -*- Mode: IDL; 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@netscape.com> (original author)
|
||||
* Christopher A. Aillon <christopher@aillon.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIVariant;
|
||||
interface nsIDOMUserDataHandler;
|
||||
|
||||
|
||||
[scriptable, uuid(29fb2a18-1dd2-11b2-8dd9-a6fd5d5ad12f)]
|
||||
interface nsIDOM3Node : nsISupports
|
||||
{
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString baseURI;
|
||||
|
||||
// DocumentPosition
|
||||
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
|
||||
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
|
||||
const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
|
||||
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
|
||||
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
|
||||
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
unsigned short compareDocumentPosition(in nsIDOMNode other)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
attribute DOMString textContent;
|
||||
// raises(DOMException) on setting
|
||||
// raises(DOMException) on retrieval
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isSameNode(in nsIDOMNode other);
|
||||
// Introduced in DOM Level 3:
|
||||
DOMString lookupPrefix(in DOMString namespaceURI);
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isDefaultNamespace(in DOMString namespaceURI);
|
||||
// Introduced in DOM Level 3:
|
||||
DOMString lookupNamespaceURI(in DOMString prefix);
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isEqualNode(in nsIDOMNode arg);
|
||||
// Introduced in DOM Level 3:
|
||||
nsISupports getFeature(in DOMString feature,
|
||||
in DOMString version);
|
||||
// Introduced in DOM Level 3:
|
||||
nsIVariant setUserData(in DOMString key,
|
||||
in nsIVariant data,
|
||||
in nsIDOMUserDataHandler handler);
|
||||
// Introduced in DOM Level 3:
|
||||
nsIVariant getUserData(in DOMString key);
|
||||
};
|
@ -40,9 +40,6 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIVariant;
|
||||
interface nsIDOMUserDataHandler;
|
||||
|
||||
/**
|
||||
* The nsIDOMNode interface is the primary datatype for the entire
|
||||
* Document Object Model.
|
||||
@ -52,7 +49,7 @@ interface nsIDOMUserDataHandler;
|
||||
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(29a95243-c73e-454c-a996-272f6727b03c)]
|
||||
[scriptable, uuid(817dc774-2ad2-4111-9042-1787df86c015)]
|
||||
interface nsIDOMNode : nsISupports
|
||||
{
|
||||
const unsigned short ELEMENT_NODE = 1;
|
||||
@ -108,42 +105,4 @@ interface nsIDOMNode : nsISupports
|
||||
readonly attribute DOMString localName;
|
||||
// Introduced in DOM Level 2:
|
||||
boolean hasAttributes();
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
// This uses a binaryname to avoid warnings due to name collision with
|
||||
// nsINode::GetBaseURI
|
||||
[binaryname(DOMBaseURI)] readonly attribute DOMString baseURI;
|
||||
|
||||
// DocumentPosition
|
||||
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
|
||||
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
|
||||
const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
|
||||
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
|
||||
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
|
||||
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
unsigned short compareDocumentPosition(in nsIDOMNode other)
|
||||
raises(DOMException);
|
||||
// Introduced in DOM Level 3:
|
||||
attribute DOMString textContent;
|
||||
// raises(DOMException) on setting
|
||||
// raises(DOMException) on retrieval
|
||||
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isSameNode(in nsIDOMNode other);
|
||||
// Introduced in DOM Level 3:
|
||||
DOMString lookupPrefix(in DOMString namespaceURI);
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isDefaultNamespace(in DOMString namespaceURI);
|
||||
// Introduced in DOM Level 3:
|
||||
DOMString lookupNamespaceURI(in DOMString prefix);
|
||||
// Introduced in DOM Level 3:
|
||||
boolean isEqualNode(in nsIDOMNode arg);
|
||||
// Introduced in DOM Level 3:
|
||||
nsIVariant setUserData(in DOMString key,
|
||||
in nsIVariant data,
|
||||
in nsIDOMUserDataHandler handler);
|
||||
// Introduced in DOM Level 3:
|
||||
nsIVariant getUserData(in DOMString key);
|
||||
};
|
||||
|
@ -78,6 +78,7 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
#include "nsFrameSelection.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
@ -3985,14 +3985,31 @@ void
|
||||
nsTextServicesDocument::PrintContentNode(nsIContent *aContent)
|
||||
{
|
||||
nsString tmpStr, str;
|
||||
nsresult result;
|
||||
|
||||
aContent->Tag()->ToString(tmpStr);
|
||||
printf("%s", NS_LossyConvertUTF16toASCII(tmpStr).get());
|
||||
|
||||
if (nsIDOMNode::TEXT_NODE == aContent->NodeType())
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aContent);
|
||||
|
||||
if (node)
|
||||
{
|
||||
aContent->AppendTextTo(str);
|
||||
printf(": \"%s\"", NS_LossyConvertUTF16toASCII(str).get());
|
||||
PRUint16 type;
|
||||
|
||||
result = node->GetNodeType(&type);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return;
|
||||
|
||||
if (nsIDOMNode::TEXT_NODE == type)
|
||||
{
|
||||
result = node->GetNodeValue(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return;
|
||||
|
||||
printf(": \"%s\"", NS_LossyConvertUTF16toASCII(str).get());
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMNSHTMLElement.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMDocumentRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMNSRange.h"
|
||||
@ -616,27 +617,29 @@ HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_innerHTML(BSTR __RPC_FAR *p)
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_innerText(BSTR v)
|
||||
{
|
||||
if (!mDOMNode)
|
||||
nsCOMPtr<nsIDOM3Node> node = do_QueryInterface(mDOMNode);
|
||||
if (!node)
|
||||
{
|
||||
return E_UNEXPECTED;
|
||||
}
|
||||
|
||||
USES_CONVERSION;
|
||||
nsAutoString innerText(OLE2W(v));
|
||||
mDOMNode->SetTextContent(innerText);
|
||||
node->SetTextContent(innerText);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_innerText(BSTR __RPC_FAR *p)
|
||||
{
|
||||
if (!mDOMNode)
|
||||
nsCOMPtr<nsIDOM3Node> node = do_QueryInterface(mDOMNode);
|
||||
if (!node)
|
||||
{
|
||||
return E_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsAutoString innerText;
|
||||
mDOMNode->GetTextContent(innerText);
|
||||
node->GetTextContent(innerText);
|
||||
|
||||
USES_CONVERSION;
|
||||
*p = SysAllocString(W2COLE(innerText.get()));
|
||||
|
@ -1168,7 +1168,8 @@ DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
|
||||
childNodes->Item(i, getter_AddRefs(childNode));
|
||||
nsCOMPtr<nsIDOMSVGTitleElement> titleElement(do_QueryInterface(childNode));
|
||||
if (titleElement) {
|
||||
titleElement->GetTextContent(outText);
|
||||
nsCOMPtr<nsIDOM3Node> titleContent(do_QueryInterface(titleElement));
|
||||
titleContent->GetTextContent(outText);
|
||||
if ( outText.Length() )
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
|
@ -83,6 +83,7 @@
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsIWebPageDescriptor.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
|
||||
#include "nsIDOMNodeFilter.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
@ -3353,7 +3354,8 @@ nsWebBrowserPersist::CloneNodeWithFixedUpAttributes(
|
||||
nsAutoString valueStr;
|
||||
nodeAsTextArea->GetValue(valueStr);
|
||||
|
||||
(*aNodeOut)->SetTextContent(valueStr);
|
||||
nsCOMPtr<nsIDOM3Node> out = do_QueryInterface(*aNodeOut);
|
||||
out->SetTextContent(valueStr);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -46,10 +46,10 @@ printStatus (summary);
|
||||
|
||||
if (typeof HTMLElement != 'undefined')
|
||||
{
|
||||
expect = /Exception/;
|
||||
expect = /Exception... "Illegal operation on WrappedNative prototype object"/;
|
||||
try
|
||||
{
|
||||
print(HTMLElement.prototype.nodeName);
|
||||
print(HTMLElement.prototype.nodeName );
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
|
@ -135,11 +135,33 @@ members = [
|
||||
'nsIDOMElement.getAttributeNS',
|
||||
'nsIDOMNamedNodeMap.item',
|
||||
'nsIDOMNamedNodeMap.length',
|
||||
'nsIDOMNode.*',
|
||||
'nsIDOMNode.appendChild',
|
||||
'nsIDOMNode.nextSibling',
|
||||
'nsIDOMNode.cloneNode',
|
||||
'nsIDOMNode.firstChild',
|
||||
'nsIDOMNode.prefix',
|
||||
'nsIDOMNode.nodeValue',
|
||||
'nsIDOMNode.childNodes',
|
||||
'nsIDOMNode.normalize',
|
||||
'nsIDOMNode.nodeName',
|
||||
'nsIDOMNode.namespaceURI',
|
||||
'nsIDOMNode.hasChildNodes',
|
||||
'nsIDOMNode.previousSibling',
|
||||
'nsIDOMNode.nodeType',
|
||||
'nsIDOMNode.insertBefore',
|
||||
'nsIDOMNode.replaceChild',
|
||||
'nsIDOMNode.localName',
|
||||
'nsIDOMNode.lastChild',
|
||||
'nsIDOMNode.ownerDocument',
|
||||
'nsIDOMNode.parentNode',
|
||||
'nsIDOMNode.removeChild',
|
||||
'nsIDOMNode.hasAttributes',
|
||||
'nsIDOMNode.attributes',
|
||||
'nsIDOMNodeList.*',
|
||||
'nsIDOMNodeSelector.querySelector',
|
||||
'nsIDOMNodeSelector.querySelectorAll',
|
||||
'nsIDOMText.splitText',
|
||||
'nsIDOM3Node.*',
|
||||
'nsIDOMDOMImplementation.*',
|
||||
'nsIDOMDOMStringList.*',
|
||||
'nsIDOMDOMTokenList.*',
|
||||
@ -616,17 +638,6 @@ customMethodCalls = {
|
||||
},
|
||||
'nsIDOMNode_GetNodeType': {
|
||||
'thisType': 'nsINode',
|
||||
'code': 'PRUint16 result = self->NodeType();',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_GetNodeName': {
|
||||
'thisType': 'nsINode',
|
||||
'code': 'nsString result = self->NodeName();',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_GetLocalName': {
|
||||
'thisType': 'nsINode',
|
||||
'code': 'nsString result = self->LocalName();',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNodeList_Item': {
|
||||
@ -780,47 +791,49 @@ customMethodCalls = {
|
||||
' rv = nsGenericElement::doQuerySelectorAll(self, '
|
||||
'arg0, getter_AddRefs(result));'
|
||||
},
|
||||
'nsIDOMNode_GetBaseURI': {
|
||||
'nsIDOM3Node_': {
|
||||
'thisType': 'nsINode'
|
||||
},
|
||||
'nsIDOM3Node_GetBaseURI': {
|
||||
'thisType': 'nsINode',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_CompareDocumentPosition': {
|
||||
'nsIDOM3Node_CompareDocumentPosition': {
|
||||
'thisType': 'nsINode',
|
||||
'arg0Type': 'nsINode',
|
||||
'code': ' PRUint16 result;\n'
|
||||
' rv = self->CompareDocPosition(arg0, &result);',
|
||||
'canFail': True
|
||||
'arg0Type': 'nsINode'
|
||||
},
|
||||
'nsIDOMNode_GetTextContent': {
|
||||
'nsIDOM3Node_GetTextContent': {
|
||||
'thisType': 'nsINode',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOM3Node_IsSameNode': {
|
||||
'thisType': 'nsINode',
|
||||
'arg0Type': 'nsINode',
|
||||
'code': ' PRBool result = self == arg0;',
|
||||
'code': ' PRBool result = self->IsSameNode(arg0);',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_LookupPrefix': {
|
||||
'nsIDOM3Node_LookupPrefix': {
|
||||
'thisType': 'nsINode',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_IsDefaultNamespace': {
|
||||
'nsIDOM3Node_IsDefaultNamespace': {
|
||||
'thisType': 'nsINode',
|
||||
'code': ' PRBool result = self->IsDefaultNamespace(arg0);',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOM3Node_LookupNamespaceURI': {
|
||||
'thisType': 'nsINode',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_LookupNamespaceURI': {
|
||||
'thisType': 'nsINode',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_IsEqualNode': {
|
||||
'nsIDOM3Node_IsEqualNode': {
|
||||
'thisType': 'nsINode',
|
||||
'arg0Type': 'nsINode',
|
||||
'code': ' PRBool result = self->IsEqualTo(arg0);',
|
||||
'code': ' PRBool result = self->IsEqualNode(arg0);',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNode_GetUserData': {
|
||||
'nsIDOM3Node_GetUserData': {
|
||||
'thisType': 'nsINode',
|
||||
'code': ' nsIVariant *result = self->GetUserData(arg0);',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMNSHTMLElement_': {
|
||||
@ -866,11 +879,6 @@ customMethodCalls = {
|
||||
'nsIDOMElement_': {
|
||||
'thisType': 'nsGenericElement'
|
||||
},
|
||||
'nsIDOMElement_GetTagName': {
|
||||
'thisType': 'nsINode',
|
||||
'code': 'nsString result = self->NodeName();',
|
||||
'canFail': False
|
||||
},
|
||||
'nsIDOMDocument_CreateElement': {
|
||||
'thisType': 'nsDocument',
|
||||
'code': ' nsCOMPtr<nsIContent> result;\n'
|
||||
|
@ -1535,9 +1535,8 @@ nsCSSFrameConstructor::CreateGeneratedContent(nsFrameConstructorState& aState,
|
||||
// XXX Check if it's an image type we can handle...
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mDocument->NodeInfoManager()->
|
||||
GetNodeInfo(nsGkAtoms::mozgeneratedcontentimage, nsnull,
|
||||
kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = mDocument->NodeInfoManager()->GetNodeInfo(nsGkAtoms::mozgeneratedcontentimage, nsnull,
|
||||
kNameSpaceID_XHTML);
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
NS_NewGenConImageContent(getter_AddRefs(content), nodeInfo.forget(),
|
||||
@ -1713,8 +1712,7 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat
|
||||
nsIAtom* elemName = aPseudoElement == nsCSSPseudoElements::ePseudo_before ?
|
||||
nsGkAtoms::mozgeneratedcontentbefore : nsGkAtoms::mozgeneratedcontentafter;
|
||||
nodeInfo = mDocument->NodeInfoManager()->GetNodeInfo(elemName, nsnull,
|
||||
kNameSpaceID_None,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_None);
|
||||
nsCOMPtr<nsIContent> container;
|
||||
nsresult rv = NS_NewXMLElement(getter_AddRefs(container), nodeInfo.forget());
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -96,6 +96,7 @@
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsRange.h"
|
||||
@ -4402,9 +4403,18 @@ nsresult PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocationStrin
|
||||
if (!anchorText.IsEmpty()) {
|
||||
// Resolve the full URI using baseURI property
|
||||
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
|
||||
nsCOMPtr<nsIURI> baseURI = node->GetBaseURI();
|
||||
nsAutoString base;
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(aNode,&rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
node->GetBaseURI(base);
|
||||
|
||||
nsCOMPtr<nsIIOService>
|
||||
ios(do_GetService("@mozilla.org/network/io-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
rv = ios->NewURI(NS_ConvertUTF16toUTF8(base),nsnull,nsnull,getter_AddRefs(baseURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString spec;
|
||||
rv = baseURI->Resolve(NS_ConvertUTF16toUTF8(anchorText),spec);
|
||||
|
@ -378,20 +378,17 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup,
|
||||
nsCOMPtr<nsINodeInfo> htmlNodeInfo;
|
||||
|
||||
// generate an html html element
|
||||
htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML);
|
||||
nsCOMPtr<nsIContent> htmlElement =
|
||||
NS_NewHTMLHtmlElement(htmlNodeInfo.forget());
|
||||
|
||||
// generate an html head element
|
||||
htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::head, 0, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::head, 0, kNameSpaceID_XHTML);
|
||||
nsCOMPtr<nsIContent> headElement =
|
||||
NS_NewHTMLHeadElement(htmlNodeInfo.forget());
|
||||
|
||||
// generate an html body elemment
|
||||
htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::body, 0, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::body, 0, kNameSpaceID_XHTML);
|
||||
nsCOMPtr<nsIContent> bodyElement =
|
||||
NS_NewHTMLBodyElement(htmlNodeInfo.forget());
|
||||
|
||||
|
@ -1029,8 +1029,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = nimgr->GetNodeInfo(nsGkAtoms::button, nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nodeInfo = nimgr->GetNodeInfo(nsGkAtoms::button, nsnull, kNameSpaceID_XHTML);
|
||||
|
||||
// create button which drops the list down
|
||||
NS_NewHTMLElement(getter_AddRefs(mButtonContent), nodeInfo.forget(),
|
||||
|
@ -237,8 +237,7 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
|
||||
// Create the text content
|
||||
NS_NewHTMLElement(getter_AddRefs(mTextContent), nodeInfo.forget(),
|
||||
@ -292,8 +291,7 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
|
||||
// Create the browse button
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_NewHTMLElement(getter_AddRefs(mBrowse), nodeInfo.forget(),
|
||||
dom::NOT_FROM_PARSER);
|
||||
if (!mBrowse)
|
||||
@ -319,8 +317,7 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
if (mode != 0) {
|
||||
mCaptureMouseListener->mMode = mode;
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_NewHTMLElement(getter_AddRefs(mCapture), nodeInfo.forget(),
|
||||
dom::NOT_FROM_PARSER);
|
||||
if (!mCapture)
|
||||
|
@ -195,8 +195,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
|
||||
// Create an hr
|
||||
nsCOMPtr<nsINodeInfo> hrInfo;
|
||||
hrInfo = nimgr->GetNodeInfo(nsGkAtoms::hr, nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
hrInfo = nimgr->GetNodeInfo(nsGkAtoms::hr, nsnull, kNameSpaceID_XHTML);
|
||||
|
||||
NS_NewHTMLElement(getter_AddRefs(mPreHr), hrInfo.forget(),
|
||||
dom::NOT_FROM_PARSER);
|
||||
@ -215,8 +214,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
|
||||
// Create text input field
|
||||
nsCOMPtr<nsINodeInfo> inputInfo;
|
||||
inputInfo = nimgr->GetNodeInfo(nsGkAtoms::input, nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
inputInfo = nimgr->GetNodeInfo(nsGkAtoms::input, nsnull, kNameSpaceID_XHTML);
|
||||
|
||||
NS_NewHTMLElement(getter_AddRefs(mInputContent), inputInfo.forget(),
|
||||
dom::NOT_FROM_PARSER);
|
||||
@ -234,8 +232,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
mInputContent->AddEventListenerByIID(mListener, NS_GET_IID(nsIDOMKeyListener));
|
||||
|
||||
// Create an hr
|
||||
hrInfo = nimgr->GetNodeInfo(nsGkAtoms::hr, nsnull, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
hrInfo = nimgr->GetNodeInfo(nsGkAtoms::hr, nsnull, kNameSpaceID_XHTML);
|
||||
NS_NewHTMLElement(getter_AddRefs(mPostHr), hrInfo.forget(),
|
||||
dom::NOT_FROM_PARSER);
|
||||
if (!mPostHr || !aElements.AppendElement(mPostHr))
|
||||
|
@ -90,8 +90,7 @@ nsProgressFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::div, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Create the div.
|
||||
|
@ -2437,8 +2437,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(
|
||||
presContext->Document()->NodeInfoManager();
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::scrollbar, nsnull,
|
||||
kNameSpaceID_XUL,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XUL);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (canHaveHorizontal) {
|
||||
@ -2466,8 +2465,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(
|
||||
if (isResizable) {
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::resizer, nsnull,
|
||||
kNameSpaceID_XUL,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XUL);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_TrustedNewXULElement(getter_AddRefs(mResizerContent), nodeInfo.forget());
|
||||
@ -2512,8 +2510,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(
|
||||
|
||||
if (canHaveHorizontal && canHaveVertical) {
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::scrollcorner, nsnull,
|
||||
kNameSpaceID_XUL,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XUL);
|
||||
NS_TrustedNewXULElement(getter_AddRefs(mScrollCornerContent), nodeInfo.forget());
|
||||
if (!aElements.AppendElement(mScrollCornerContent))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -100,8 +100,7 @@ nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
// before we load, or on a subsequent load.
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::img,
|
||||
nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
Element* element = NS_NewHTMLImageElement(nodeInfo.forget());
|
||||
mPosterImage = element;
|
||||
@ -135,8 +134,7 @@ nsVideoFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
// actual controls.
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::videocontrols,
|
||||
nsnull,
|
||||
kNameSpaceID_XUL,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XUL);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_TrustedNewXULElement(getter_AddRefs(mVideoControls), nodeInfo.forget());
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMCSSStyleSheet.h"
|
||||
#include "nsIDOMCSSRuleList.h"
|
||||
@ -112,14 +113,16 @@ inCSSValueSearch::SearchSync()
|
||||
{
|
||||
InitSearch();
|
||||
|
||||
if (!mDocument) {
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
nsCOMPtr<nsIDOM3Node> dom3Node = do_QueryInterface(mDocument);
|
||||
if (dom3Node) {
|
||||
nsAutoString uri;
|
||||
dom3Node->GetBaseURI(uri);
|
||||
NS_NewURI(getter_AddRefs(baseURL), uri);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIDocument> idoc = do_QueryInterface(mDocument);
|
||||
if (idoc) {
|
||||
baseURI = idoc->GetBaseURI();
|
||||
if (!mDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMStyleSheetList> sheets;
|
||||
@ -133,7 +136,7 @@ inCSSValueSearch::SearchSync()
|
||||
sheets->Item(i, getter_AddRefs(sheet));
|
||||
nsCOMPtr<nsIDOMCSSStyleSheet> cssSheet = do_QueryInterface(sheet);
|
||||
if (cssSheet)
|
||||
SearchStyleSheet(cssSheet, baseURI);
|
||||
SearchStyleSheet(cssSheet, baseURL);
|
||||
}
|
||||
|
||||
// XXX would be nice to search inline style as well.
|
||||
|
@ -74,6 +74,7 @@
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
|
@ -122,8 +122,7 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
// create the top-secret popupgroup node. shhhhh!
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::popupgroup,
|
||||
nsnull, kNameSpaceID_XUL,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
nsnull, kNameSpaceID_XUL);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = NS_NewXULElement(getter_AddRefs(mPopupgroupContent),
|
||||
@ -135,8 +134,7 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
|
||||
// create the top-secret default tooltip node. shhhhh!
|
||||
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::tooltip, nsnull,
|
||||
kNameSpaceID_XUL,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XUL);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = NS_NewXULElement(getter_AddRefs(mTooltipContent), nodeInfo.forget());
|
||||
|
@ -149,7 +149,7 @@ function hiddenDataCheck(bytes, uri, path)
|
||||
.getElementsByTagName("h1");
|
||||
do_check_eq(header.length, 1);
|
||||
|
||||
do_check_eq(header.item(0).QueryInterface(Ci.nsIDOMNode).textContent, path);
|
||||
do_check_eq(header.item(0).QueryInterface(Ci.nsIDOM3Node).textContent, path);
|
||||
|
||||
// files
|
||||
var lst = body.getElementsByTagName("ol");
|
||||
@ -171,7 +171,7 @@ function hiddenDataCheck(bytes, uri, path)
|
||||
var link = items.item(i)
|
||||
.childNodes
|
||||
.item(0)
|
||||
.QueryInterface(Ci.nsIDOMNode)
|
||||
.QueryInterface(Ci.nsIDOM3Node)
|
||||
.QueryInterface(Ci.nsIDOMElement);
|
||||
var f = dirEntries[i];
|
||||
|
||||
@ -233,7 +233,7 @@ function dataCheck(bytes, uri, path, dirEntries)
|
||||
.getElementsByTagName("h1");
|
||||
do_check_eq(header.length, 1);
|
||||
|
||||
do_check_eq(header.item(0).QueryInterface(Ci.nsIDOMNode).textContent, path);
|
||||
do_check_eq(header.item(0).QueryInterface(Ci.nsIDOM3Node).textContent, path);
|
||||
|
||||
// files
|
||||
var lst = body.getElementsByTagName("ol");
|
||||
@ -251,7 +251,7 @@ function dataCheck(bytes, uri, path, dirEntries)
|
||||
var link = items.item(i)
|
||||
.childNodes
|
||||
.item(0)
|
||||
.QueryInterface(Ci.nsIDOMNode)
|
||||
.QueryInterface(Ci.nsIDOM3Node)
|
||||
.QueryInterface(Ci.nsIDOMElement);
|
||||
var f = dirEntries[i];
|
||||
|
||||
|
@ -377,8 +377,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> newContent;
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo = aBuilder->GetNodeInfoManager()->
|
||||
GetNodeInfo(name, nsnull, ns, nsIDOMNode::ELEMENT_NODE);
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo = aBuilder->GetNodeInfoManager()->GetNodeInfo(name, nsnull, ns);
|
||||
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
|
||||
NS_NewElement(getter_AddRefs(newContent),
|
||||
ns, nodeInfo.forget(),
|
||||
@ -419,8 +418,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
nsCOMPtr<nsINodeInfo> optionNodeInfo =
|
||||
aBuilder->GetNodeInfoManager()->GetNodeInfo(nsHtml5Atoms::option,
|
||||
nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
kNameSpaceID_XHTML);
|
||||
|
||||
for (PRUint32 i = 0; i < theContent.Length(); ++i) {
|
||||
nsCOMPtr<nsIContent> optionElt;
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -216,8 +217,12 @@ RemovePrefForDriverVersion()
|
||||
static bool
|
||||
BlacklistNodeToTextValue(nsIDOMNode *aBlacklistNode, nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsIDOM3Node> dom3 = do_QueryInterface(aBlacklistNode);
|
||||
if (!dom3)
|
||||
return false;
|
||||
|
||||
nsAutoString value;
|
||||
if (NS_FAILED(aBlacklistNode->GetTextContent(value)))
|
||||
if (NS_FAILED(dom3->GetTextContent(value)))
|
||||
return false;
|
||||
|
||||
value.Trim(" \t\r\n");
|
||||
|
Loading…
Reference in New Issue
Block a user