From 1f6cb072003c6fd3da638028b3eeb07dc77f4b3c Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 10 Apr 2014 15:48:42 +0100 Subject: [PATCH] Backed out changeset c80f64bfb7b7 (bug 968835) for Android failures in test_getWebIDLCaller.html; CLOSED TREE --- content/html/document/src/nsHTMLDocument.cpp | 27 +++++++++++--------- content/html/document/src/nsHTMLDocument.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 32dc46811e20..81f032e4e4eb 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -9,7 +9,6 @@ #include "mozilla/DebugOnly.h" #include "mozilla/dom/HTMLAllCollection.h" #include "nsCOMPtr.h" -#include "nsGlobalWindow.h" #include "nsXPIDLString.h" #include "nsPrintfCString.h" #include "nsReadableUtils.h" @@ -2155,24 +2154,28 @@ NS_IMETHODIMP nsHTMLDocument::GetSelection(nsISelection** aReturn) { ErrorResult rv; - NS_IF_ADDREF(*aReturn = GetSelection(rv)); + *aReturn = GetSelection(rv).take(); return rv.ErrorCode(); } -Selection* -nsHTMLDocument::GetSelection(ErrorResult& aRv) +already_AddRefed +nsHTMLDocument::GetSelection(ErrorResult& rv) { - nsCOMPtr window = do_QueryInterface(GetScopeObject()); - if (!window) { + nsCOMPtr window = do_QueryInterface(GetScopeObject()); + nsCOMPtr pwin = do_QueryInterface(window); + if (!pwin) { + return nullptr; + } + NS_ASSERTION(pwin->IsInnerWindow(), "Should have inner window here!"); + if (!pwin->GetOuterWindow() || + pwin->GetOuterWindow()->GetCurrentInnerWindow() != pwin) { return nullptr; } - NS_ASSERTION(window->IsInnerWindow(), "Should have inner window here!"); - if (!window->IsCurrentInnerWindow()) { - return nullptr; - } - - return static_cast(window.get())->GetSelection(aRv); + nsCOMPtr sel; + rv = window->GetSelection(getter_AddRefs(sel)); + nsRefPtr selection = static_cast(sel.get()); + return selection.forget(); } NS_IMETHODIMP diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index 774bc70dfbbc..fd9b8e05c92a 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -233,7 +233,7 @@ public: { // Deprecated } - mozilla::Selection* GetSelection(mozilla::ErrorResult& aRv); + already_AddRefed GetSelection(mozilla::ErrorResult& rv); // The XPCOM CaptureEvents works fine for us. // The XPCOM ReleaseEvents works fine for us. // We're picking up GetLocation from Document