зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1375573 - Part 2: Avoid creating an about:blank document in setupJSON() by creating a Window binding through exposing a getter for the inner window ID on nsIWebProgress; r=billm
This commit is contained in:
Родитель
bc4c49bb3f
Коммит
d732ce4442
|
@ -81,6 +81,14 @@ nsBrowserStatusFilter::GetDOMWindowID(uint64_t *aResult)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserStatusFilter::GetInnerDOMWindowID(uint64_t *aResult)
|
||||
{
|
||||
*aResult = 0;
|
||||
NS_NOTREACHED("nsBrowserStatusFilter::GetInnerDOMWindowID");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserStatusFilter::GetIsTopLevel(bool *aIsTopLevel)
|
||||
{
|
||||
|
|
|
@ -72,15 +72,12 @@ var WebProgressListener = {
|
|||
if (aWebProgress) {
|
||||
let domWindowID = null;
|
||||
try {
|
||||
let utils = aWebProgress.DOMWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
domWindowID = utils.outerWindowID;
|
||||
innerWindowID = utils.currentInnerWindowID;
|
||||
domWindowID = aWebProgress.DOMWindowID;
|
||||
innerWindowID = aWebProgress.innerDOMWindowID;
|
||||
} catch (e) {
|
||||
// If nsDocShell::Destroy has already been called, then we'll
|
||||
// get NS_NOINTERFACE when trying to get the DOM window.
|
||||
// If there is no current inner window, we'll get
|
||||
// NS_ERROR_NOT_AVAILABLE.
|
||||
// The DOM Window ID getters above may throw if the inner or outer
|
||||
// windows aren't created yet or are destroyed at the time we're making
|
||||
// this call but that isn't fatal so ignore the exceptions here.
|
||||
}
|
||||
|
||||
aWebProgress = {
|
||||
|
|
|
@ -923,6 +923,29 @@ nsDocLoader::GetDOMWindowID(uint64_t *aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoader::GetInnerDOMWindowID(uint64_t *aResult)
|
||||
{
|
||||
*aResult = 0;
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> window;
|
||||
nsresult rv = GetDOMWindow(getter_AddRefs(window));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outer = nsPIDOMWindowOuter::From(window);
|
||||
NS_ENSURE_STATE(outer);
|
||||
|
||||
nsPIDOMWindowInner* inner = outer->GetCurrentInnerWindow();
|
||||
if (!inner) {
|
||||
// If we don't have an inner window, return 0.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(inner->IsInnerWindow());
|
||||
*aResult = inner->WindowID();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoader::GetIsTopLevel(bool *aResult)
|
||||
{
|
||||
|
|
|
@ -133,6 +133,7 @@ interface nsIWebProgress : nsISupports
|
|||
*/
|
||||
readonly attribute mozIDOMWindowProxy DOMWindow;
|
||||
readonly attribute uint64_t DOMWindowID;
|
||||
readonly attribute uint64_t innerDOMWindowID;
|
||||
|
||||
/**
|
||||
* Indicates whether DOMWindow.top == DOMWindow.
|
||||
|
|
Загрузка…
Ссылка в новой задаче