Backed out 5 changesets (bug 1323987) for browser-chrome printing failures a=backout

Backed out changeset 77bc28c97be0 (bug 1323987)
Backed out changeset 48837569b4e9 (bug 1323987)
Backed out changeset fcf065b47fdc (bug 1323987)
Backed out changeset 06444044d4e5 (bug 1323987)
Backed out changeset 1e7285465d1b (bug 1323987)

MozReview-Commit-ID: KTG6VusQeC0
This commit is contained in:
Wes Kocher 2017-01-25 13:06:47 -08:00
parent 4f96795b02
commit 4a3e331d92
7 changed files with 13 additions and 80 deletions

View File

@ -3353,7 +3353,7 @@ var PrintPreviewListener = {
let browser = gBrowser.selectedBrowser;
let preferredRemoteType = browser.remoteType;
this._tabBeforePrintPreview = gBrowser.selectedTab;
this._printPreviewTab = gBrowser.loadOneTab("about:printpreview",
this._printPreviewTab = gBrowser.loadOneTab("about:blank",
{ inBackground: false,
preferredRemoteType,
relatedBrowser: browser });
@ -3362,7 +3362,7 @@ var PrintPreviewListener = {
return gBrowser.getBrowserForTab(this._printPreviewTab);
},
createSimplifiedBrowser() {
this._simplifyPageTab = gBrowser.loadOneTab("about:printpreview",
this._simplifyPageTab = gBrowser.loadOneTab("about:blank",
{ inBackground: true });
return this.getSimplifiedSourceBrowser();
},

View File

@ -388,7 +388,7 @@ this.SessionStore = {
let win = aState.windows[i];
for (let j = win.tabs.length - 1; j >= 0; j--) {
let tab = win.tabs[j];
if (!SessionStoreInternal._shouldSaveTab(tab)) {
if (!SessionStoreInternal._shouldSaveTabState(tab)) {
win.tabs.splice(j, 1);
if (win.selected > j) {
win.selected--;
@ -4196,29 +4196,10 @@ var SessionStoreInternal = {
!(aTabState.entries.length == 1 &&
(aTabState.entries[0].url == "about:blank" ||
aTabState.entries[0].url == "about:newtab" ||
aTabState.entries[0].url == "about:printpreview" ||
aTabState.entries[0].url == "about:privatebrowsing") &&
!aTabState.userTypedValue);
},
/**
* Determine if the tab state we're passed is something we should keep to be
* reopened at session restore. This is used when we are saving the current
* session state to disk. This method is very similar to _shouldSaveTabState,
* however, "about:blank" and "about:newtab" tabs will still be saved to disk.
*
* @param aTabState
* The current tab state
* @returns boolean
*/
_shouldSaveTab: function ssi_shouldSaveTab(aTabState) {
// If the tab has one of the following transient about: history entry,
// then we don't actually want to write this tab's data to disk.
return aTabState.entries.length &&
!(aTabState.entries[0].url == "about:printpreview" ||
aTabState.entries[0].url == "about:privatebrowsing");
},
/**
* This is going to take a state as provided at startup (via
* nsISessionStartup.state) and split it into 2 parts. The first part

View File

@ -138,12 +138,6 @@ static RedirEntry kRedirMap[] = {
{
"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.html",
nsIAboutModule::ALLOW_SCRIPT
},
{
"printpreview", "about:blank",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT |
nsIAboutModule::URI_CAN_LOAD_IN_CHILD
}
};
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
@ -179,11 +173,9 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
&isUIResource);
NS_ENSURE_SUCCESS(rv, rv);
bool isAboutBlank = NS_IsAboutBlank(tempURI);
nsLoadFlags loadFlags = isUIResource || isAboutBlank
? static_cast<nsLoadFlags>(nsIChannel::LOAD_NORMAL)
: static_cast<nsLoadFlags>(nsIChannel::LOAD_REPLACE);
nsLoadFlags loadFlags =
isUIResource ? static_cast<nsLoadFlags>(nsIChannel::LOAD_NORMAL)
: static_cast<nsLoadFlags>(nsIChannel::LOAD_REPLACE);
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
tempURI,

View File

@ -14300,16 +14300,9 @@ nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview)
nsCOMPtr<nsIDocumentViewerPrint> print = do_QueryInterface(mContentViewer);
if (!print || !print->IsInitializedForPrintPreview()) {
Stop(nsIWebNavigation::STOP_ALL);
// Check if current content viewer is blank. If so, we skip ahead to where
// we QI the mContentViewer using it to host print preview, instead of
// creating a brand new one.
if (!IsContentViewerBlankForPrintPreview()) {
nsCOMPtr<nsIPrincipal> principal = nsNullPrincipal::CreateWithInheritedAttributes(this);
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:printpreview"));
nsresult rv = CreateAboutBlankContentViewer(principal, uri);
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIPrincipal> principal = nsNullPrincipal::CreateWithInheritedAttributes(this);
nsresult rv = CreateAboutBlankContentViewer(principal, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
print = do_QueryInterface(mContentViewer);
NS_ENSURE_STATE(print);
print->InitializeForPrintPreview();
@ -14434,19 +14427,6 @@ nsDocShell::GetOriginAttributes(JSContext* aCx,
return NS_OK;
}
bool
nsDocShell::IsContentViewerBlankForPrintPreview()
{
MOZ_ASSERT(mCurrentURI);
if (!mCurrentURI) {
return false;
}
nsCString spec = mCurrentURI->GetSpecOrDefault();
return (spec.EqualsLiteral("about:printpreview") ||
spec.EqualsLiteral("about:blank"));
}
bool
nsDocShell::CanSetOriginAttributes()
{

View File

@ -273,7 +273,6 @@ public:
bool InFrameSwap();
private:
bool IsContentViewerBlankForPrintPreview();
bool CanSetOriginAttributes();
public:

View File

@ -189,7 +189,6 @@ const mozilla::Module::ContractIDEntry kDocShellContracts[] = {
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "support", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "telemetry", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "webrtc", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "printpreview", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
{ NS_URI_LOADER_CONTRACTID, &kNS_URI_LOADER_CID },
{ NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &kNS_DOCUMENTLOADER_SERVICE_CID },
{ NS_HANDLERSERVICE_CONTRACTID, &kNS_CONTENTHANDLERSERVICE_CID, mozilla::Module::CONTENT_PROCESS_ONLY },

View File

@ -544,7 +544,7 @@ var Printing = {
// Set base URI of document. Print preview code will read this value to
// populate the URL field in print settings so that it doesn't show
// "about:printpreview" as its URI.
// "about:blank" as its URI.
let headBaseElement = content.document.createElement("base");
headBaseElement.setAttribute("href", URL);
content.document.head.appendChild(headBaseElement);
@ -647,29 +647,11 @@ var Printing = {
// If we happen to be on simplified mode, we need to set docURL in order
// to generate header/footer content correctly, since simplified tab has
// "about:printpreview" as its URI.
// "about:blank" as its URI.
if (printSettings && simplifiedMode)
printSettings.docURL = contentWindow.document.baseURI;
// Bug 1323987 optimizes nsDocShell::GetPrintPreview() method so it can
// return its current content viewer QI'd to nsIWebBrowserPrint if it's
// already a blank one. Bug 1323987 also adds a new about: page for
// "about:printpreview" (new redirector that essentially aliases itself
// to "about:blank").
// These changes together can cause a raciness condition in nsDocShell::
// GetPrintPreview() if we access it and nsDocShell hasn't even finished
// the redirect yet. We solve this issue by checking if the current top
// level document has finished loading prior to entering on print preview
// mode, and if not, wait until it completes.
let print = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebBrowserPrint);
if (print.doingPrintPreview || content.document.readyState == "complete") {
docShell.printPreview.printPreview(printSettings, contentWindow, this);
} else if (content.document.readyState != "complete") {
addEventListener("DOMContentLoaded", () => {
docShell.printPreview.printPreview(printSettings, contentWindow, this);
}, {once: true});
}
docShell.printPreview.printPreview(printSettings, contentWindow, this);
} catch (error) {
// This might fail if we, for example, attempt to print a XUL document.
// In that case, we inform the parent to bail out of print preview.
@ -687,7 +669,7 @@ var Printing = {
// If we happen to be on simplified mode, we need to set docURL in order
// to generate header/footer content correctly, since simplified tab has
// "about:printpreview" as its URI.
// "about:blank" as its URI.
if (printSettings && simplifiedMode) {
printSettings.docURL = contentWindow.document.baseURI;
}