mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Fix for bug 16603 (DOM doesn't throw INVALID_CHARACTER_ERR for arguments with invalid characters). r=sicking, sr=jst.
This commit is contained in:
parent
005ca32e12
commit
713c734ef8
@ -52,6 +52,8 @@ class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDocShell;
|
||||
class nsINameSpaceManager;
|
||||
class nsINodeInfo;
|
||||
class nsINodeInfoManager;
|
||||
class nsIScriptSecurityManager;
|
||||
class nsIThreadJSContextStack;
|
||||
class nsIParserService;
|
||||
@ -276,6 +278,14 @@ public:
|
||||
static PRBool BelongsInForm(nsIDOMHTMLFormElement *aForm,
|
||||
nsIContent *aContent);
|
||||
|
||||
static nsresult CheckQName(const nsAString& aQualifiedName,
|
||||
PRBool aNamespaceAware = PR_TRUE);
|
||||
|
||||
static nsresult GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsINodeInfoManager* aNodeInfoManager,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
|
||||
private:
|
||||
static nsresult GetDocumentAndPrincipal(nsIDOMNode* aNode,
|
||||
nsIDocument** aDocument,
|
||||
|
@ -119,9 +119,8 @@ public:
|
||||
virtual nsresult GetNodeInfo(const nsAString& aQualifiedName,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo) = 0;
|
||||
|
||||
virtual nsresult GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID,
|
||||
virtual nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo) = 0;
|
||||
|
||||
/*
|
||||
|
@ -1588,6 +1588,54 @@ nsContentUtils::BelongsInForm(nsIDOMHTMLFormElement *aForm,
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::CheckQName(const nsAString& aQualifiedName,
|
||||
PRBool aNamespaceAware)
|
||||
{
|
||||
nsIParserService *parserService = GetParserServiceWeakRef();
|
||||
NS_ENSURE_TRUE(parserService, NS_ERROR_FAILURE);
|
||||
|
||||
const PRUnichar *colon;
|
||||
return parserService->IsValidQName(PromiseFlatString(aQualifiedName),
|
||||
aNamespaceAware, &colon) ?
|
||||
NS_OK : NS_ERROR_DOM_INVALID_CHARACTER_ERR;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsINodeInfoManager* aNodeInfoManager,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
nsIParserService* parserService = GetParserServiceWeakRef();
|
||||
NS_ENSURE_TRUE(parserService, NS_ERROR_FAILURE);
|
||||
|
||||
const nsAFlatString& qName = PromiseFlatString(aQualifiedName);
|
||||
const PRUnichar* colon;
|
||||
if (!parserService->IsValidQName(qName, PR_TRUE, &colon)) {
|
||||
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
if (colon) {
|
||||
const PRUnichar* end;
|
||||
qName.EndReading(end);
|
||||
|
||||
nsCOMPtr<nsIAtom> prefix = do_GetAtom(Substring(colon + 1, end));
|
||||
|
||||
rv = aNodeInfoManager->GetNodeInfo(Substring(qName.get(), colon), prefix,
|
||||
aNamespaceURI, aNodeInfo);
|
||||
}
|
||||
else {
|
||||
rv = aNodeInfoManager->GetNodeInfo(aQualifiedName, nsnull, aNamespaceURI,
|
||||
aNodeInfo);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsCxPusher::Push(nsISupports *aCurrentTarget)
|
||||
{
|
||||
|
@ -338,7 +338,10 @@ nsDOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
|
||||
const nsAString& aSystemId,
|
||||
nsIDOMDocumentType** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = nsContentUtils::CheckQName(aQualifiedName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aQualifiedName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -353,10 +356,14 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIDOMDocument** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
if (!aQualifiedName.IsEmpty()) {
|
||||
rv = nsContentUtils::CheckQName(aQualifiedName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aDoctype) {
|
||||
nsCOMPtr<nsIDOMDocument> owner;
|
||||
aDoctype->GetOwnerDocument(getter_AddRefs(owner));
|
||||
@ -365,8 +372,8 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName,
|
||||
aDoctype, mBaseURI);
|
||||
rv = NS_NewDOMDocument(aReturn, aNamespaceURI, aQualifiedName, aDoctype,
|
||||
mBaseURI);
|
||||
|
||||
nsIDocShell *docShell = nsContentUtils::GetDocShellFromCaller();
|
||||
if (docShell) {
|
||||
@ -2097,17 +2104,40 @@ NS_IMETHODIMP
|
||||
nsDocument::CreateElement(const nsAString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = nsContentUtils::CheckQName(aTagName, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ConvertUTF16toUTF8 tmp(aTagName);
|
||||
if (!IsCaseSensitive()) {
|
||||
ToLowerCase(tmp);
|
||||
}
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
rv = mNodeInfoManager->GetNodeInfo(name, nsnull, GetDefaultNamespaceID(),
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateElementNS(const nsAString & namespaceURI,
|
||||
const nsAString & qualifiedName,
|
||||
nsIDOMElement **_retval)
|
||||
nsDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
// Should be implemented by subclass
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI,
|
||||
aQualifiedName,
|
||||
mNodeInfoManager,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -2169,15 +2199,18 @@ NS_IMETHODIMP
|
||||
nsDocument::CreateAttribute(const nsAString& aName,
|
||||
nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult rv = nsContentUtils::CheckQName(aName, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString value;
|
||||
nsDOMAttribute* attribute;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv = mNodeInfoManager->GetNodeInfo(aName, nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
rv = mNodeInfoManager->GetNodeInfo(aName, nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
attribute = new nsDOMAttribute(nsnull, nodeInfo, value);
|
||||
@ -2195,8 +2228,10 @@ nsDocument::CreateAttributeNS(const nsAString & aNamespaceURI,
|
||||
*aResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv = mNodeInfoManager->GetNodeInfo(aQualifiedName, aNamespaceURI,
|
||||
getter_AddRefs(nodeInfo));
|
||||
nsresult rv = nsContentUtils::GetNodeInfoFromQName(aNamespaceURI,
|
||||
aQualifiedName,
|
||||
mNodeInfoManager,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString value;
|
||||
|
@ -514,6 +514,11 @@ protected:
|
||||
|
||||
nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult);
|
||||
|
||||
virtual PRInt32 GetDefaultNamespaceID() const
|
||||
{
|
||||
return kNameSpaceID_None;
|
||||
};
|
||||
|
||||
nsDocument();
|
||||
virtual ~nsDocument();
|
||||
|
||||
|
@ -98,7 +98,6 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
// baseURI
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
|
||||
#ifdef DEBUG_waterson
|
||||
@ -1262,6 +1261,9 @@ nsGenericElement::SetAttribute(const nsAString& aName,
|
||||
const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);
|
||||
|
||||
if (!name) {
|
||||
nsresult rv = nsContentUtils::CheckQName(aName, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
@ -1405,9 +1407,10 @@ nsGenericElement::SetAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
nsresult rv = mNodeInfo->NodeInfoManager()->GetNodeInfo(aQualifiedName,
|
||||
aNamespaceURI,
|
||||
getter_AddRefs(ni));
|
||||
nsresult rv =
|
||||
nsContentUtils::GetNodeInfoFromQName(aNamespaceURI, aQualifiedName,
|
||||
mNodeInfo->NodeInfoManager(),
|
||||
getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SetAttr(ni->NamespaceID(), ni->NameAtom(), ni->GetPrefixAtom(),
|
||||
|
@ -201,8 +201,9 @@ nsresult
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
return nsNodeInfoManager::GetNodeInfo(NS_ConvertUTF16toUTF8(aName),
|
||||
aPrefix, aNamespaceID, aNodeInfo);
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
|
||||
return nsNodeInfoManager::GetNodeInfo(name, aPrefix, aNamespaceID,
|
||||
aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -240,26 +241,31 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName,
|
||||
PRInt32 nsid = kNameSpaceID_None;
|
||||
|
||||
if (!aNamespaceURI.IsEmpty()) {
|
||||
nsresult rv = nsContentUtils::GetNSManagerWeakRef()->RegisterNameSpace(aNamespaceURI, nsid);
|
||||
nsresult rv = nsContentUtils::GetNSManagerWeakRef()->
|
||||
RegisterNameSpace(aNamespaceURI, nsid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return nsNodeInfoManager::GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo);
|
||||
return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNodeInfoManager::GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo)
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aName);
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
PRInt32 nsid = kNameSpaceID_None;
|
||||
if (!aNamespaceURI.IsEmpty()) {
|
||||
nsresult rv = nsContentUtils::GetNSManagerWeakRef()->
|
||||
RegisterNameSpace(aNamespaceURI, nsid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return GetNodeInfo(name, aPrefix, aNamespaceID, aNodeInfo);
|
||||
return GetNodeInfo(nameAtom, aPrefix, nsid, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsNodeInfoManager::GetDocumentPrincipal(nsIPrincipal** aPrincipal)
|
||||
{
|
||||
|
@ -63,9 +63,9 @@ public:
|
||||
virtual nsresult GetNodeInfo(const nsAString& aQualifiedName,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
|
||||
virtual nsresult GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo);
|
||||
virtual nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
|
||||
virtual nsresult GetDocumentPrincipal(nsIPrincipal** aPrincipal);
|
||||
virtual nsresult SetDocumentPrincipal(nsIPrincipal* aPrincipal);
|
||||
|
@ -348,6 +348,9 @@ nsGenericHTMLElement::SetAttribute(const nsAString& aName,
|
||||
const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);
|
||||
|
||||
if (!name) {
|
||||
nsresult rv = nsContentUtils::CheckQName(aName, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom;
|
||||
if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
|
||||
nsAutoString lower;
|
||||
|
@ -882,7 +882,8 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||
NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
|
||||
ToLowerCase(tmp);
|
||||
|
||||
rv = mNodeInfoManager->GetNodeInfo(tmp, nsnull, kNameSpaceID_None,
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
|
||||
rv = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
} else {
|
||||
nsCOMPtr<nsIDTD> dtd;
|
||||
|
@ -121,9 +121,7 @@
|
||||
#include "nsICharsetResolver.h"
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
#include "nsIXMLContent.h" //for createelementNS
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIWyciwygChannel.h"
|
||||
|
||||
@ -1382,21 +1380,6 @@ nsHTMLDocument::IsCaseSensitive()
|
||||
return IsXHTML();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv = mNodeInfoManager->GetNodeInfo(aQualifiedName,
|
||||
aNamespaceURI,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return nsDocument::CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsIDOMDocument interface implementation
|
||||
//
|
||||
@ -1404,27 +1387,15 @@ NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateElement(const nsAString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
NS_ENSURE_TRUE(!aTagName.IsEmpty(), NS_ERROR_DOM_INVALID_CHARACTER_ERR);
|
||||
return nsDocument::CreateElement(aTagName, aReturn);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
||||
NS_ConvertUTF16toUTF8 tmp(aTagName);
|
||||
|
||||
if (!IsXHTML()) {
|
||||
ToLowerCase(tmp);
|
||||
}
|
||||
|
||||
nsresult rv = mNodeInfoManager->GetNodeInfo(tmp, nsnull, mDefaultNamespaceID,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> content;
|
||||
rv = NS_CreateHTMLElement(getter_AddRefs(content), nodeInfo, IsXHTML());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
content->SetContentID(mNextContentID++);
|
||||
return CallQueryInterface(content, aReturn);
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
return nsDocument::CreateElementNS(aNamespaceURI, aQualifiedName, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1509,165 +1480,6 @@ nsHTMLDocument::GetElementsByTagName(const nsAString& aTagname,
|
||||
return nsDocument::GetElementsByTagName(tmp, aReturn);
|
||||
}
|
||||
|
||||
//
|
||||
// nsIDOMNode interface implementation
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
return nsDocument::GetChildNodes(aChildNodes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
return nsDocument::GetFirstChild(aFirstChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
return nsDocument::GetLastChild(aLastChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::InsertBefore(nsIDOMNode* aNewChild,
|
||||
nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::InsertBefore(aNewChild, aRefChild, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::ReplaceChild(nsIDOMNode* aNewChild,
|
||||
nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::ReplaceChild(aNewChild, aOldChild, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::RemoveChild(aOldChild, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::AppendChild(aNewChild, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::HasChildNodes(PRBool* aReturn)
|
||||
{
|
||||
return nsDocument::HasChildNodes(aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::HasAttributes(PRBool* aReturn)
|
||||
{
|
||||
return nsDocument::HasAttributes(aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
return nsDocument::GetNodeName(aNodeName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
return nsDocument::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return nsDocument::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
return nsDocument::GetNodeType(aNodeType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNamespaceURI(nsAString& aNamespaceURI)
|
||||
{
|
||||
return nsDocument::GetNamespaceURI(aNamespaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetPrefix(nsAString& aPrefix)
|
||||
{
|
||||
return nsDocument::GetPrefix(aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::SetPrefix(const nsAString& aPrefix)
|
||||
{
|
||||
return nsDocument::SetPrefix(aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetLocalName(nsAString& aLocalName)
|
||||
{
|
||||
return nsDocument::GetLocalName(aLocalName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
return nsDocument::GetParentNode(aParentNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
return nsDocument::GetPreviousSibling(aPreviousSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
return nsDocument::GetNextSibling(aNextSibling);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
return nsDocument::GetAttributes(aAttributes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
return nsDocument::GetOwnerDocument(aOwnerDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::CloneNode(aDeep, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::Normalize()
|
||||
{
|
||||
return nsDocument::Normalize();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
return nsDocument::IsSupported(aFeature, aVersion, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetBaseURI(nsAString &aURI)
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
NS_IMETHOD SetXmlVersion(const nsAString& aXmlVersion);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_NSIDOMNODE
|
||||
NS_FORWARD_NSIDOMNODE(nsDocument::)
|
||||
|
||||
// nsIDOM3Node interface
|
||||
NS_IMETHOD GetBaseURI(nsAString& aBaseURI);
|
||||
@ -253,6 +253,11 @@ protected:
|
||||
nsresult CreateAndAddWyciwygChannel(void);
|
||||
nsresult RemoveWyciwygChannel(void);
|
||||
|
||||
PRInt32 GetDefaultNamespaceID() const
|
||||
{
|
||||
return mDefaultNamespaceID;
|
||||
};
|
||||
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
|
||||
nsCompatibility mCompatMode;
|
||||
|
@ -92,13 +92,13 @@
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIScriptGlobalObjectOwner.h"
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
// XXX The XML world depends on the html atoms
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
||||
static const char kLoadAsData[] = "loadAsData";
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
|
||||
|
||||
|
||||
@ -754,12 +754,6 @@ nsXMLDocument::InternalGetNumberOfStyleSheets() const
|
||||
}
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)
|
||||
{
|
||||
return nsDocument::GetDoctype(aDocumentType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateCDATASection(const nsAString& aData,
|
||||
nsIDOMCDATASection** aReturn)
|
||||
@ -800,12 +794,13 @@ nsXMLDocument::CreateProcessingInstruction(const nsAString& aTarget,
|
||||
const nsAString& aData,
|
||||
nsIDOMProcessingInstruction** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = nsContentUtils::CheckQName(aTarget, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsresult rv = NS_NewXMLProcessingInstruction(getter_AddRefs(content),
|
||||
aTarget, aData);
|
||||
rv = NS_NewXMLProcessingInstruction(getter_AddRefs(content), aTarget, aData);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
@ -813,24 +808,6 @@ nsXMLDocument::CreateProcessingInstruction(const nsAString& aTarget,
|
||||
return CallQueryInterface(content, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElement(const nsAString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
NS_ENSURE_TRUE(!aTagName.IsEmpty(), NS_ERROR_DOM_INVALID_CHARACTER_ERR);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv;
|
||||
|
||||
rv = mNodeInfoManager->GetNodeInfo(aTagName, nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return nsDocument::CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
@ -900,52 +877,6 @@ nsXMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
return CallQueryInterface(newDoc, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::ImportNode(nsIDOMNode* aImportedNode,
|
||||
PRBool aDeep,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsDocument::ImportNode(aImportedNode, aDeep, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMAttr** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv = mNodeInfoManager->GetNodeInfo(aQualifiedName, aNamespaceURI,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString value;
|
||||
nsDOMAttribute* attribute = new nsDOMAttribute(nsnull, nodeInfo, value);
|
||||
NS_ENSURE_TRUE(attribute, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return CallQueryInterface(attribute, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
rv = mNodeInfoManager->GetNodeInfo(aQualifiedName, aNamespaceURI,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return nsDocument::CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
// Id attribute matching function used by nsXMLDocument and
|
||||
// nsHTMLDocument.
|
||||
nsIContent *
|
||||
|
@ -82,7 +82,6 @@ public:
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetDoctype(nsIDOMDocumentType** aDocumentType);
|
||||
NS_IMETHOD CreateCDATASection(const nsAString& aData,
|
||||
nsIDOMCDATASection** aReturn);
|
||||
NS_IMETHOD CreateEntityReference(const nsAString& aName,
|
||||
@ -90,15 +89,6 @@ public:
|
||||
NS_IMETHOD CreateProcessingInstruction(const nsAString& aTarget,
|
||||
const nsAString& aData,
|
||||
nsIDOMProcessingInstruction** aReturn);
|
||||
NS_IMETHOD CreateElement(const nsAString& aTagName, nsIDOMElement** aReturn);
|
||||
NS_IMETHOD ImportNode(nsIDOMNode* aImportedNode, PRBool aDeep,
|
||||
nsIDOMNode** aReturn);
|
||||
NS_IMETHOD CreateElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMElement** aReturn);
|
||||
NS_IMETHOD CreateAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD GetElementById(const nsAString& aElementId,
|
||||
nsIDOMElement** aReturn);
|
||||
|
||||
|
@ -1024,6 +1024,9 @@ nsXULElement::SetAttribute(const nsAString& aName,
|
||||
const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);
|
||||
|
||||
if (!name) {
|
||||
nsresult rv = nsContentUtils::CheckQName(aName, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
@ -1172,9 +1175,10 @@ nsXULElement::SetAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
nsresult rv = NodeInfo()->NodeInfoManager()->GetNodeInfo(aQualifiedName,
|
||||
aNamespaceURI,
|
||||
getter_AddRefs(ni));
|
||||
nsresult rv =
|
||||
nsContentUtils::GetNodeInfoFromQName(aNamespaceURI, aQualifiedName,
|
||||
NodeInfo()->NodeInfoManager(),
|
||||
getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return SetAttr(ni->NamespaceID(), ni->NameAtom(), ni->GetPrefixAtom(),
|
||||
|
@ -1400,34 +1400,6 @@ nsXULDocument::SetCurrentPrototype(nsIXULPrototypeDocument* aDocument)
|
||||
// nsIDOMDocument interface
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::CreateElement(const nsAString& aTagName,
|
||||
nsIDOMElement** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gXULLog, PR_LOG_DEBUG)) {
|
||||
char* tagCStr = ToNewCString(aTagName);
|
||||
|
||||
PR_LOG(gXULLog, PR_LOG_DEBUG,
|
||||
("xul[CreateElement] %s", tagCStr));
|
||||
|
||||
nsCRT::free(tagCStr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// CreateElement in the XUL document defaults to the XUL namespace.
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mNodeInfoManager->GetNodeInfo(aTagName, nsnull, kNameSpaceID_XUL,
|
||||
getter_AddRefs(ni));
|
||||
|
||||
return nsDocument::CreateElement(ni, aReturn);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetElementsByAttribute(const nsAString& aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -160,8 +160,6 @@ public:
|
||||
NS_IMETHOD CloneNode(PRBool deep, nsIDOMNode **_retval);
|
||||
|
||||
// nsIDOMDocument interface overrides
|
||||
NS_IMETHOD CreateElement(const nsAString & tagName,
|
||||
nsIDOMElement **_retval);
|
||||
NS_IMETHOD GetElementById(const nsAString & elementId,
|
||||
nsIDOMElement **_retval);
|
||||
|
||||
@ -230,6 +228,11 @@ protected:
|
||||
|
||||
void GetFocusController(nsIFocusController** aFocusController);
|
||||
|
||||
PRInt32 GetDefaultNamespaceID() const
|
||||
{
|
||||
return kNameSpaceID_XUL;
|
||||
};
|
||||
|
||||
protected:
|
||||
// pseudo constants
|
||||
static PRInt32 gRefCnt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user