mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 624187 - r=smaug a=blocking-beta
--HG-- extra : rebase_source : e8ed7004507dfcef58d7144d89eb5205d2b0b99c
This commit is contained in:
parent
b550e1a0a6
commit
9bf43d33a0
@ -70,9 +70,11 @@ NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports **outCurItem)
|
||||
if (mCurIndex >= mItemArray.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// post-increment is important here
|
||||
return CallQueryInterface(mItemArray[mCurIndex++], outCurItem);
|
||||
nsCOMPtr<nsISupports> item = do_QueryReferent(mItemArray[mCurIndex++], &rv);
|
||||
item.forget(outCurItem);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* boolean hasMoreElements (); */
|
||||
@ -91,14 +93,14 @@ NS_IMETHODIMP nsDocShellEnumerator::HasMoreElements(PRBool *outHasMore)
|
||||
nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEnumerationRootItem);
|
||||
*aEnumerationRootItem = mRootItem;
|
||||
NS_IF_ADDREF(*aEnumerationRootItem);
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
||||
item.forget(aEnumerationRootItem);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem)
|
||||
{
|
||||
mRootItem = aEnumerationRootItem;
|
||||
mRootItem = do_GetWeakReference(aEnumerationRootItem);
|
||||
ClearState();
|
||||
return NS_OK;
|
||||
}
|
||||
@ -142,14 +144,15 @@ nsresult nsDocShellEnumerator::ClearState()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsIDocShellTreeItem*>& inItemArray)
|
||||
nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray)
|
||||
{
|
||||
NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED);
|
||||
inItemArray.Clear();
|
||||
return BuildArrayRecursive(mRootItem, inItemArray);
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
||||
return BuildArrayRecursive(item, inItemArray);
|
||||
}
|
||||
|
||||
nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsIDocShellTreeItem*>& inItemArray)
|
||||
nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocShellTreeNode> itemAsNode = do_QueryInterface(inItem, &rv);
|
||||
@ -160,7 +163,7 @@ nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem*
|
||||
if ((mDocShellType == nsIDocShellTreeItem::typeAll) ||
|
||||
(NS_SUCCEEDED(inItem->GetItemType(&itemType)) && (itemType == mDocShellType)))
|
||||
{
|
||||
if (!inItemArray.AppendElement(inItem))
|
||||
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -182,7 +185,7 @@ nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem*
|
||||
}
|
||||
|
||||
|
||||
nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsIDocShellTreeItem*>& inItemArray)
|
||||
nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocShellTreeNode> itemAsNode = do_QueryInterface(inItem, &rv);
|
||||
@ -207,7 +210,7 @@ nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem*
|
||||
if ((mDocShellType == nsIDocShellTreeItem::typeAll) ||
|
||||
(NS_SUCCEEDED(inItem->GetItemType(&itemType)) && (itemType == mDocShellType)))
|
||||
{
|
||||
if (!inItemArray.AppendElement(inItem))
|
||||
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,8 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
|
||||
class nsIDocShellTreeItem;
|
||||
|
||||
@ -98,14 +100,14 @@ protected:
|
||||
nsresult EnsureDocShellArray();
|
||||
nsresult ClearState();
|
||||
|
||||
nsresult BuildDocShellArray(nsTArray<nsIDocShellTreeItem*>& inItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsIDocShellTreeItem*>& inItemArray) = 0;
|
||||
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
nsIDocShellTreeItem* mRootItem; // weak ref!
|
||||
nsWeakPtr mRootItem; // weak ref!
|
||||
|
||||
nsTArray<nsIDocShellTreeItem*> mItemArray; // flattened list of items with matching type
|
||||
nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
|
||||
PRUint32 mCurIndex;
|
||||
|
||||
PRInt32 mDocShellType; // only want shells of this type
|
||||
@ -126,7 +128,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsIDocShellTreeItem*>& inItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
|
||||
|
||||
};
|
||||
|
||||
@ -140,6 +142,6 @@ public:
|
||||
}
|
||||
protected:
|
||||
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsIDocShellTreeItem*>& inItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user