зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 230439 (Remove anonymous nodeinfomanager and other cleanup) - share CreateElement. r=caillon, sr=jst.
This commit is contained in:
Родитель
379d6c8a41
Коммит
fbd88a1d66
|
@ -118,6 +118,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
|||
|
||||
#include "nsScriptEventManager.h"
|
||||
#include "nsIXPathEvaluatorInternal.h"
|
||||
#include "nsIElementFactory.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "nsICharsetAlias.h"
|
||||
|
@ -4073,3 +4074,29 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
PRInt32 namespaceID = aNodeInfo->NamespaceID();
|
||||
|
||||
nsCOMPtr<nsIElementFactory> elementFactory;
|
||||
nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID,
|
||||
getter_AddRefs(elementFactory));
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (elementFactory) {
|
||||
rv = elementFactory->CreateInstanceByTag(aNodeInfo,
|
||||
getter_AddRefs(content));
|
||||
} else {
|
||||
rv = NS_NewXMLElement(getter_AddRefs(content), aNodeInfo);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
content->SetContentID(mNextContentID++);
|
||||
|
||||
return CallQueryInterface(content, aResult);
|
||||
}
|
||||
|
|
|
@ -563,6 +563,8 @@ protected:
|
|||
nsCompatibility aCompatMode,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
|
||||
nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult);
|
||||
|
||||
nsDocument();
|
||||
virtual ~nsDocument();
|
||||
|
||||
|
|
|
@ -1487,26 +1487,7 @@ nsHTMLDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
|||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 namespaceID = nodeInfo->NamespaceID();
|
||||
|
||||
nsCOMPtr<nsIElementFactory> elementFactory;
|
||||
nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID,
|
||||
getter_AddRefs(elementFactory));
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
if (elementFactory) {
|
||||
rv = elementFactory->CreateInstanceByTag(nodeInfo,
|
||||
getter_AddRefs(content));
|
||||
} else {
|
||||
rv = NS_NewXMLElement(getter_AddRefs(content), nodeInfo);
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
content->SetContentID(mNextContentID++);
|
||||
|
||||
return CallQueryInterface(content, aReturn);
|
||||
return nsDocument::CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "nsIDocShell.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
|
@ -842,7 +841,7 @@ nsXMLDocument::CreateElement(const nsAString& aTagName,
|
|||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CreateElement(nodeInfo, aReturn);
|
||||
return nsDocument::CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -957,7 +956,7 @@ nsXMLDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
|||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CreateElement(nodeInfo, aReturn);
|
||||
return nsDocument::CreateElement(nodeInfo, aReturn);
|
||||
}
|
||||
|
||||
// Id attribute matching function used by nsXMLDocument and
|
||||
|
@ -1084,32 +1083,3 @@ nsXMLDocument::GetCSSLoader()
|
|||
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLDocument::CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
PRInt32 namespaceID = aNodeInfo->NamespaceID();
|
||||
|
||||
nsCOMPtr<nsIElementFactory> elementFactory;
|
||||
nsContentUtils::GetNSManagerWeakRef()->GetElementFactory(namespaceID,
|
||||
getter_AddRefs(elementFactory));
|
||||
|
||||
if (elementFactory) {
|
||||
rv = elementFactory->CreateInstanceByTag(aNodeInfo,
|
||||
getter_AddRefs(content));
|
||||
} else {
|
||||
rv = NS_NewXMLElement(getter_AddRefs(content), aNodeInfo);
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
content->SetContentID(mNextContentID++);
|
||||
|
||||
return CallQueryInterface(content, aResult);
|
||||
}
|
||||
|
|
|
@ -125,8 +125,6 @@ protected:
|
|||
virtual nsIStyleSheet* InternalGetStyleSheetAt(PRInt32 aIndex) const;
|
||||
virtual PRInt32 InternalGetNumberOfStyleSheets() const;
|
||||
|
||||
nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult);
|
||||
|
||||
virtual nsresult GetLoadGroup(nsILoadGroup **aLoadGroup);
|
||||
|
||||
nsresult SetDefaultStylesheets(nsIURI* aUrl);
|
||||
|
|
|
@ -1441,13 +1441,6 @@ nsXULDocument::CreateElement(const nsAString& aTagName,
|
|||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIAtom> name, prefix;
|
||||
|
||||
name = do_GetAtom(aTagName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gXULLog, PR_LOG_DEBUG)) {
|
||||
char* tagCStr = ToNewCString(aTagName);
|
||||
|
@ -1459,24 +1452,12 @@ nsXULDocument::CreateElement(const nsAString& aTagName,
|
|||
}
|
||||
#endif
|
||||
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
|
||||
// CreateElement in the XUL document defaults to the XUL namespace.
|
||||
mNodeInfoManager->GetNodeInfo(name, prefix, kNameSpaceID_XUL,
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mNodeInfoManager->GetNodeInfo(aTagName, nsnull, kNameSpaceID_XUL,
|
||||
getter_AddRefs(ni));
|
||||
|
||||
nsCOMPtr<nsIContent> result;
|
||||
rv = CreateElement(ni, getter_AddRefs(result));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// get the DOM interface
|
||||
rv = CallQueryInterface(result, aReturn);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM element");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
return nsDocument::CreateElement(ni, aReturn);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2327,40 +2308,6 @@ nsXULDocument::GetElementsByAttribute(nsIDOMNode* aNode,
|
|||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsXULDocument::CreateElement(nsINodeInfo *aNodeInfo, nsIContent** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNodeInfo);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> result;
|
||||
|
||||
if (aNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) {
|
||||
rv = nsXULElement::Create(aNodeInfo, getter_AddRefs(result));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIElementFactory> elementFactory;
|
||||
GetElementFactory(aNodeInfo->NamespaceID(),
|
||||
getter_AddRefs(elementFactory));
|
||||
|
||||
rv = elementFactory->CreateInstanceByTag(aNodeInfo,
|
||||
getter_AddRefs(result));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (! result)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
result->SetContentID(mNextContentID++);
|
||||
|
||||
*aResult = result;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsXULDocument::PrepareToLoad(nsISupports* aContainer,
|
||||
const char* aCommand,
|
||||
|
@ -3419,6 +3366,7 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe
|
|||
if (! aPrototype)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
|
|
|
@ -201,8 +201,6 @@ protected:
|
|||
|
||||
void SetIsPopup(PRBool isPopup) { mIsPopup = isPopup; };
|
||||
|
||||
nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIContent** aResult);
|
||||
|
||||
nsresult PrepareToLoad(nsISupports* aContainer,
|
||||
const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
|
|
Загрузка…
Ссылка в новой задаче