Bug 1375189 - Don't use aNodesWithProperties in nsNodeUtils::CloneAndAdopt if it is not needed r=bz

MozReview-Commit-ID: 9vu3HCQkDKf

--HG--
extra : rebase_source : eb6231c88732133ee6d90e621a5833b9be1e81ce
This commit is contained in:
Kirk Steuber 2017-06-21 11:55:04 -07:00
Родитель 7eaeefca71
Коммит e967f9a6c1
5 изменённых файлов: 19 добавлений и 23 удалений

Просмотреть файл

@ -6535,9 +6535,8 @@ nsIDocument::ImportNode(nsINode& aNode, bool aDeep, ErrorResult& rv) const
case nsIDOMNode::DOCUMENT_TYPE_NODE:
{
nsCOMPtr<nsINode> newNode;
nsCOMArray<nsINode> nodesWithProperties;
rv = nsNodeUtils::Clone(imported, aDeep, mNodeInfoManager,
nodesWithProperties, getter_AddRefs(newNode));
rv = nsNodeUtils::Clone(imported, aDeep, mNodeInfoManager, nullptr,
getter_AddRefs(newNode));
if (rv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -408,9 +408,7 @@ nsNodeUtils::CloneNodeImpl(nsINode *aNode, bool aDeep, nsINode **aResult)
*aResult = nullptr;
nsCOMPtr<nsINode> newNode;
nsCOMArray<nsINode> nodesWithProperties;
nsresult rv = Clone(aNode, aDeep, nullptr, nodesWithProperties,
getter_AddRefs(newNode));
nsresult rv = Clone(aNode, aDeep, nullptr, nullptr, getter_AddRefs(newNode));
NS_ENSURE_SUCCESS(rv, rv);
newNode.forget(aResult);
@ -422,7 +420,7 @@ nsresult
nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
nsNodeInfoManager *aNewNodeInfoManager,
JS::Handle<JSObject*> aReparentScope,
nsCOMArray<nsINode> &aNodesWithProperties,
nsCOMArray<nsINode> *aNodesWithProperties,
nsINode *aParent, nsINode **aResult)
{
NS_PRECONDITION((!aClone && aNewNodeInfoManager) || !aReparentScope,
@ -650,10 +648,10 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
}
#endif
if (aNode->HasProperties()) {
bool ok = aNodesWithProperties.AppendObject(aNode);
if (aNodesWithProperties && aNode->HasProperties()) {
bool ok = aNodesWithProperties->AppendObject(aNode);
if (aClone) {
ok = ok && aNodesWithProperties.AppendObject(clone);
ok = ok && aNodesWithProperties->AppendObject(clone);
}
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -181,12 +181,13 @@ public:
* shouldn't be changed.
* @param aNodesWithProperties All nodes (from amongst aNode and its
* descendants) with properties. Every node will
* be followed by its clone.
* be followed by its clone. Null can be passed to
* prevent this from being used.
* @param aResult *aResult will contain the cloned node.
*/
static nsresult Clone(nsINode *aNode, bool aDeep,
nsNodeInfoManager *aNewNodeInfoManager,
nsCOMArray<nsINode> &aNodesWithProperties,
nsCOMArray<nsINode> *aNodesWithProperties,
nsINode **aResult)
{
return CloneAndAdopt(aNode, true, aDeep, aNewNodeInfoManager,
@ -198,9 +199,8 @@ public:
*/
static nsresult Clone(nsINode *aNode, bool aDeep, nsINode **aResult)
{
nsCOMArray<nsINode> dummyNodeWithProperties;
return CloneAndAdopt(aNode, true, aDeep, nullptr, nullptr,
dummyNodeWithProperties, aNode->GetParent(), aResult);
return CloneAndAdopt(aNode, true, aDeep, nullptr, nullptr, nullptr,
aNode->GetParent(), aResult);
}
/**
@ -226,7 +226,7 @@ public:
{
nsCOMPtr<nsINode> node;
nsresult rv = CloneAndAdopt(aNode, false, true, aNewNodeInfoManager,
aReparentScope, aNodesWithProperties,
aReparentScope, &aNodesWithProperties,
nullptr, getter_AddRefs(node));
nsMutationGuard::DidMutate();
@ -299,7 +299,8 @@ private:
* @param aNodesWithProperties All nodes (from amongst aNode and its
* descendants) with properties. If aClone is
* true every node will be followed by its
* clone.
* clone. Null can be passed to prevent this from
* being populated.
* @param aParent If aClone is true the cloned node will be appended to
* aParent's children. May be null. If not null then aNode
* must be an nsIContent.
@ -309,7 +310,7 @@ private:
static nsresult CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
nsNodeInfoManager *aNewNodeInfoManager,
JS::Handle<JSObject*> aReparentScope,
nsCOMArray<nsINode> &aNodesWithProperties,
nsCOMArray<nsINode> *aNodesWithProperties,
nsINode *aParent, nsINode **aResult);
enum class AnimationMutationType

Просмотреть файл

@ -263,11 +263,10 @@ SVGUseElement::CreateAnonymousContent()
}
nsCOMPtr<nsINode> newnode;
nsCOMArray<nsINode> unused;
nsNodeInfoManager* nodeInfoManager =
targetContent->OwnerDoc() == OwnerDoc() ?
nullptr : OwnerDoc()->NodeInfoManager();
nsNodeUtils::Clone(targetContent, true, nodeInfoManager, unused,
nsNodeUtils::Clone(targetContent, true, nodeInfoManager, nullptr,
getter_AddRefs(newnode));
nsCOMPtr<nsIContent> newcontent = do_QueryInterface(newnode);

Просмотреть файл

@ -321,9 +321,8 @@ nsXBLBinding::GenerateAnonymousContent()
nsIDocument* doc = mBoundElement->OwnerDoc();
nsCOMPtr<nsINode> clonedNode;
nsCOMArray<nsINode> nodesWithProperties;
nsNodeUtils::Clone(content, true, doc->NodeInfoManager(),
nodesWithProperties, getter_AddRefs(clonedNode));
nsNodeUtils::Clone(content, true, doc->NodeInfoManager(), nullptr,
getter_AddRefs(clonedNode));
mContent = clonedNode->AsElement();
// Search for <xbl:children> elements in the XBL content. In the presence