author | Bobby Holley <bobbyholley@gmail.com> |
Wed, 05 Sep 2012 11:32:06 -0700 | |
changeset 104318 | 783bd41565ececb0b8c5124d67eb9f328866df91 |
parent 104317 | a22a0ad64bb6509c5b59d9dab3fd4560806438e1 |
child 104319 | 32ecf0cec2c305c65792b9a5a75e4ee4a9714ad3 |
push id | 23417 |
push user | ryanvm@gmail.com |
push date | Thu, 06 Sep 2012 02:27:31 +0000 |
treeherder | mozilla-central@501f4e46a88c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jst |
bugs | 774633 |
milestone | 18.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1503,54 +1503,20 @@ nsGlobalWindow::WouldReuseInnerWindow(ns return itemType == nsIDocShellTreeItem::typeChrome; } // No treeItem: don't reuse the current inner window. return false; } void -nsGlobalWindow::SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal) -{ - FORWARD_TO_OUTER_VOID(SetOpenerScriptPrincipal, (aPrincipal)); - - if (mDoc) { - if (!mDoc->IsInitialDocument()) { - // We have a document already, and it's not the original one. Bail out. - return; - } - -#ifdef DEBUG - // We better have an about:blank document loaded at this point. Otherwise, - // something is really weird. - nsCOMPtr<nsIURI> uri; - mDoc->NodePrincipal()->GetURI(getter_AddRefs(uri)); - NS_ASSERTION(uri && NS_IsAboutBlank(uri) && - NS_IsAboutBlank(mDoc->GetDocumentURI()), - "Unexpected original document"); -#endif - - GetDocShell()->CreateAboutBlankContentViewer(aPrincipal); - mDoc->SetIsInitialDocument(true); - - nsCOMPtr<nsIPresShell> shell; - GetDocShell()->GetPresShell(getter_AddRefs(shell)); - - if (shell && !shell->DidInitialReflow()) { - // Ensure that if someone plays with this document they will get - // layout happening. - nsRect r = shell->GetPresContext()->GetVisibleArea(); - shell->InitialReflow(r.width, r.height); - } - } -} - -void nsGlobalWindow::SetInitialPrincipalToSubject() { + FORWARD_TO_OUTER_VOID(SetInitialPrincipalToSubject, ()); + // First, grab the subject principal. These methods never fail. nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); nsCOMPtr<nsIPrincipal> newWindowPrincipal, systemPrincipal; ssm->GetSubjectPrincipal(getter_AddRefs(newWindowPrincipal)); ssm->GetSystemPrincipal(getter_AddRefs(systemPrincipal)); if (!newWindowPrincipal) { newWindowPrincipal = systemPrincipal; } @@ -1561,18 +1527,48 @@ nsGlobalWindow::SetInitialPrincipalToSub int32_t itemType; nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(GetDocShell()); nsresult rv = item->GetItemType(&itemType); if (NS_FAILED(rv) || itemType != nsIDocShellTreeItem::typeChrome) { newWindowPrincipal = nullptr; } } - // Set the initial about:blank document up with the correct principal. - SetOpenerScriptPrincipal(newWindowPrincipal); + // If there's an existing document, bail if it either: + if (mDoc) { + // (a) is not an initial about:blank document, or + if (!mDoc->IsInitialDocument()) + return; + // (b) already has the correct principal. + if (mDoc->NodePrincipal() == newWindowPrincipal) + return; + +#ifdef DEBUG + // If we have a document loaded at this point, it had better be about:blank. + // Otherwise, something is really weird. + nsCOMPtr<nsIURI> uri; + mDoc->NodePrincipal()->GetURI(getter_AddRefs(uri)); + NS_ASSERTION(uri && NS_IsAboutBlank(uri) && + NS_IsAboutBlank(mDoc->GetDocumentURI()), + "Unexpected original document"); +#endif + } + + GetDocShell()->CreateAboutBlankContentViewer(newWindowPrincipal); + mDoc->SetIsInitialDocument(true); + + nsCOMPtr<nsIPresShell> shell; + GetDocShell()->GetPresShell(getter_AddRefs(shell)); + + if (shell && !shell->DidInitialReflow()) { + // Ensure that if someone plays with this document they will get + // layout happening. + nsRect r = shell->GetPresContext()->GetVisibleArea(); + shell->InitialReflow(r.width, r.height); + } } PopupControlState PushPopupControlState(PopupControlState aState, bool aForce) { PopupControlState oldState = gPopupControlState; if (aState < gPopupControlState || aForce) {
--- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -337,17 +337,16 @@ public: // nsPIDOMWindow virtual NS_HIDDEN_(nsPIDOMWindow*) GetPrivateRoot(); virtual NS_HIDDEN_(void) ActivateOrDeactivate(bool aActivate); virtual NS_HIDDEN_(void) SetActive(bool aActive); virtual NS_HIDDEN_(void) SetIsBackground(bool aIsBackground); virtual NS_HIDDEN_(void) SetChromeEventHandler(nsIDOMEventTarget* aChromeEventHandler); - virtual NS_HIDDEN_(void) SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal); virtual NS_HIDDEN_(void) SetInitialPrincipalToSubject(); virtual NS_HIDDEN_(PopupControlState) PushPopupControlState(PopupControlState state, bool aForce) const; virtual NS_HIDDEN_(void) PopPopupControlState(PopupControlState state) const; virtual NS_HIDDEN_(PopupControlState) GetPopupControlState() const; virtual NS_HIDDEN_(nsresult) SaveWindowState(nsISupports **aState); virtual NS_HIDDEN_(nsresult) RestoreWindowState(nsISupports *aState);
--- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -275,22 +275,18 @@ public: } win = this; } return win->mIsHandlingResizeEvent; } - // Tell this window who opened it. This only has an effect if there is - // either no document currently in the window or if the document is the - // original document this window came with (an about:blank document either - // preloaded into it when it was created, or created by - // CreateAboutBlankContentViewer()). - virtual void SetOpenerScriptPrincipal(nsIPrincipal* aPrincipal) = 0; + // Set the window up with an about:blank document with the current subject + // principal. virtual void SetInitialPrincipalToSubject() = 0; virtual PopupControlState PushPopupControlState(PopupControlState aState, bool aForce) const = 0; virtual void PopPopupControlState(PopupControlState state) const = 0; virtual PopupControlState GetPopupControlState() const = 0; // Returns an object containing the window's state. This also suspends