mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 561173 - Reduce QIing and Addref/Release while setting innerHTML, r=jst, a=1hourlimit
This commit is contained in:
parent
4766900491
commit
a164f239a1
@ -1019,7 +1019,7 @@ public:
|
||||
* transferred to the caller.
|
||||
* @param aReturn [out] the created DocumentFragment
|
||||
*/
|
||||
static nsresult CreateContextualFragment(nsIDOMNode* aContextNode,
|
||||
static nsresult CreateContextualFragment(nsINode* aContextNode,
|
||||
const nsAString& aFragment,
|
||||
PRBool aWillOwnFragment,
|
||||
nsIDOMDocumentFragment** aReturn);
|
||||
|
@ -3696,27 +3696,26 @@ nsContentUtils::IsValidNodeName(nsIAtom *aLocalName, nsIAtom *aPrefix,
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
|
||||
nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
const nsAString& aFragment,
|
||||
PRBool aWillOwnFragment,
|
||||
nsIDOMDocumentFragment** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG(aContextNode);
|
||||
*aReturn = nsnull;
|
||||
NS_ENSURE_ARG(aContextNode);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aContextNode);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
// If we don't have a document here, we can't get the right security context
|
||||
// for compiling event handlers... so just bail out.
|
||||
nsCOMPtr<nsIDocument> document = node->GetOwnerDoc();
|
||||
nsCOMPtr<nsIDocument> document = aContextNode->GetOwnerDoc();
|
||||
NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
PRBool bCaseSensitive = !document->IsHTML();
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(document));
|
||||
PRBool isHTML = htmlDoc && !bCaseSensitive;
|
||||
PRBool isHTML = document->IsHTML();
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
|
||||
NS_ASSERTION(!isHTML || htmlDoc, "Should have HTMLDocument here!");
|
||||
#endif
|
||||
|
||||
if (isHTML && nsHtml5Module::sEnabled) {
|
||||
// See if the document has a cached fragment parser. nsHTMLDocument is the
|
||||
@ -3760,7 +3759,7 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
|
||||
(document->GetCompatibilityMode() == eCompatibility_NavQuirks));
|
||||
}
|
||||
|
||||
NS_ADDREF(*aReturn = frag);
|
||||
frag.swap(*aReturn);
|
||||
document->SetFragmentParser(parser);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2033,10 +2033,9 @@ NS_IMETHODIMP
|
||||
nsRange::CreateContextualFragment(const nsAString& aFragment,
|
||||
nsIDOMDocumentFragment** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> start = do_QueryInterface(mStartParent);
|
||||
if (mIsPositioned) {
|
||||
return nsContentUtils::CreateContextualFragment(start, aFragment, PR_TRUE,
|
||||
aReturn);
|
||||
return nsContentUtils::CreateContextualFragment(mStartParent, aFragment,
|
||||
PR_TRUE, aReturn);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -681,14 +681,12 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
|
||||
loader->SetEnabled(PR_FALSE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> thisNode(do_QueryInterface(static_cast<nsIContent *>
|
||||
(this)));
|
||||
nsresult rv = nsContentUtils::CreateContextualFragment(thisNode, aInnerHTML,
|
||||
nsresult rv = nsContentUtils::CreateContextualFragment(this, aInnerHTML,
|
||||
PR_FALSE,
|
||||
getter_AddRefs(df));
|
||||
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
rv = thisNode->AppendChild(df, getter_AddRefs(tmpNode));
|
||||
static_cast<nsINode*>(this)->AppendChild(fragment, &rv);
|
||||
}
|
||||
|
||||
if (scripts_enabled) {
|
||||
|
Loading…
Reference in New Issue
Block a user