mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 631269 - Reduce duplicate code in CloneAndReplaceChild; r=bz
This commit is contained in:
parent
b171b9ae5c
commit
6469ece53a
@ -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);
|
||||
@ -10199,55 +10198,44 @@ nsDocShell::CloneAndReplaceChild(nsISHEntry *aEntry, nsDocShell *aShell,
|
||||
nsCOMPtr<nsISHContainer> container =
|
||||
do_QueryInterface(data->destTreeParent);
|
||||
if (!aEntry) {
|
||||
if (container) {
|
||||
container->AddChild(nsnull, aEntryIndex);
|
||||
}
|
||||
return NS_OK;
|
||||
if (container) {
|
||||
container->AddChild(nsnull, aEntryIndex);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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
|
||||
dest->SetIsSubFrame(PR_TRUE);
|
||||
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,
|
||||
CloneAndReplaceChild, &childData);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
rv = WalkHistoryEntries(aEntry, aShell,
|
||||
CloneAndReplaceChild, &childData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aShell)
|
||||
aShell->SwapHistoryEntries(aEntry, dest);
|
||||
if (srcID != cloneID && aShell) {
|
||||
aShell->SwapHistoryEntries(aEntry, dest);
|
||||
}
|
||||
|
||||
if (container)
|
||||
container->AddChild(dest, aEntryIndex);
|
||||
|
||||
data->resultEntry = dest;
|
||||
return result;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
|
Loading…
Reference in New Issue
Block a user