зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1186790 - Replace nsBaseHashtable::EnumerateRead() calls in xpfe/ with iterators. r=neil.
--HG-- extra : rebase_source : 5d966b0ac332ebe9666b8c8ebc1a2de1cb1f6a86
This commit is contained in:
Родитель
5bf85e9f9d
Коммит
4669b76df0
|
@ -265,23 +265,6 @@ nsWindowDataSource::OnCloseWindow(nsIXULWindow *window)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
struct findWindowClosure {
|
||||
nsIRDFResource* targetResource;
|
||||
nsIXULWindow *resultWindow;
|
||||
};
|
||||
|
||||
static PLDHashOperator
|
||||
findWindow(nsIXULWindow* aWindow, nsIRDFResource* aResource, void* aClosure)
|
||||
{
|
||||
findWindowClosure* closure = static_cast<findWindowClosure*>(aClosure);
|
||||
|
||||
if (aResource == closure->targetResource) {
|
||||
closure->resultWindow = aWindow;
|
||||
return PL_DHASH_STOP;
|
||||
}
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
// nsIWindowDataSource implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -297,20 +280,23 @@ nsWindowDataSource::GetWindowForResource(const char *aResourceString,
|
|||
getter_AddRefs(windowResource));
|
||||
|
||||
// now reverse-lookup in the hashtable
|
||||
findWindowClosure closure = { windowResource.get(), nullptr };
|
||||
mWindowResources.EnumerateRead(findWindow, &closure);
|
||||
if (closure.resultWindow) {
|
||||
for (auto iter = mWindowResources.Iter(); !iter.Done(); iter.Next()) {
|
||||
nsIXULWindow* window = iter.Key();
|
||||
nsIRDFResource* resource = iter.UserData();
|
||||
|
||||
// this sucks, we have to jump through docshell to go from
|
||||
// nsIXULWindow -> nsIDOMWindow
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
closure.resultWindow->GetDocShell(getter_AddRefs(docShell));
|
||||
if (resource == windowResource) {
|
||||
// This sucks, we have to jump through docshell to go from
|
||||
// nsIXULWindow -> nsIDOMWindow.
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
window->GetDocShell(getter_AddRefs(docShell));
|
||||
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIDOMWindow> result = do_GetInterface(docShell);
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIDOMWindow> result = do_GetInterface(docShell);
|
||||
|
||||
*aResult = result;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
*aResult = result;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче