Bug 631269 - Reduce duplicate code in CloneAndReplaceChild; r=bz

This commit is contained in:
Ms2ger 2011-05-28 09:43:55 +02:00
Родитель d5b5dc43f8
Коммит fcb413f91a
1 изменённых файлов: 17 добавлений и 29 удалений

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

@ -10189,7 +10189,6 @@ struct NS_STACK_CLASS CloneAndReplaceData
nsDocShell::CloneAndReplaceChild(nsISHEntry *aEntry, nsDocShell *aShell,
PRInt32 aEntryIndex, void *aData)
{
nsresult result = NS_OK;
nsCOMPtr<nsISHEntry> dest;
CloneAndReplaceData *data = static_cast<CloneAndReplaceData*>(aData);
@ -10208,38 +10207,27 @@ nsDocShell::CloneAndReplaceChild(nsISHEntry *aEntry, nsDocShell *aShell,
PRUint32 srcID;
aEntry->GetID(&srcID);
nsresult rv = NS_OK;
if (srcID == cloneID) {
// Replace the entry
dest = replaceEntry;
dest->SetIsSubFrame(PR_TRUE);
if (data->cloneChildren) {
// Walk the children
CloneAndReplaceData childData(cloneID, replaceEntry,
data->cloneChildren, dest);
result = WalkHistoryEntries(aEntry, aShell,
CloneAndReplaceChild, &childData);
if (NS_FAILED(result))
return result;
}
} else {
// Clone the SHEntry...
result = aEntry->Clone(getter_AddRefs(dest));
if (NS_FAILED(result))
return result;
// This entry is for a subframe navigation
rv = aEntry->Clone(getter_AddRefs(dest));
NS_ENSURE_SUCCESS(rv, rv);
}
dest->SetIsSubFrame(PR_TRUE);
if (srcID != cloneID || data->cloneChildren) {
// Walk the children
CloneAndReplaceData childData(cloneID, replaceEntry,
data->cloneChildren, dest);
result = WalkHistoryEntries(aEntry, aShell,
rv = WalkHistoryEntries(aEntry, aShell,
CloneAndReplaceChild, &childData);
if (NS_FAILED(result))
return result;
NS_ENSURE_SUCCESS(rv, rv);
}
if (aShell)
if (srcID != cloneID && aShell) {
aShell->SwapHistoryEntries(aEntry, dest);
}
@ -10247,7 +10235,7 @@ nsDocShell::CloneAndReplaceChild(nsISHEntry *aEntry, nsDocShell *aShell,
container->AddChild(dest, aEntryIndex);
data->resultEntry = dest;
return result;
return rv;
}
/* static */ nsresult