From 63f3a642a0323d91b350864326cc4d237b4740b7 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Fri, 17 Nov 2017 09:55:29 -0800 Subject: [PATCH] Bug 1397426 - Add hasLayers to nsITabParent and use it in the async tab switcher. r=billm This is necessary because sometimes the async tab switcher will instantiate when there already exists some background tabs that are rendering via print preview. When that happens, it's important for the state to be set correctly for them so that we don't accidentally treat them as still loading, and wait (forever) for them to report having finished loading. MozReview-Commit-ID: 2dwo5WlXlgJ --HG-- extra : rebase_source : 4b1e2fb945f1dc4591c56f836a1caa9adeea9eb4 extra : source : 53bb2bc2b67673572dafc3093280fa72973b3d32 --- browser/base/content/tabbrowser.xml | 4 +++- dom/interfaces/base/nsITabParent.idl | 6 ++++++ dom/ipc/TabParent.cpp | 7 +++++++ toolkit/content/widgets/browser.xml | 8 ++++++++ toolkit/content/widgets/remote-browser.xml | 10 ++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index b4dabdc6ff3f..25fb9987d504 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -4485,7 +4485,9 @@ } for (let ppBrowser of this.tabbrowser._printPreviewBrowsers) { let ppTab = this.tabbrowser.getTabForBrowser(ppBrowser); - this.setTabState(ppTab, this.STATE_LOADING); + let state = ppBrowser.hasLayers ? this.STATE_LOADED + : this.STATE_LOADING; + this.setTabState(ppTab, state); } }, diff --git a/dom/interfaces/base/nsITabParent.idl b/dom/interfaces/base/nsITabParent.idl index 5c3cf2044b74..aa29f871b24b 100644 --- a/dom/interfaces/base/nsITabParent.idl +++ b/dom/interfaces/base/nsITabParent.idl @@ -32,6 +32,12 @@ interface nsITabParent : nsISupports */ void renderLayers(in bool aEnabled); + /** + * True if layers are being rendered and the compositor has reported + * receiving them. + */ + readonly attribute boolean hasLayers; + /** * Whether this tabParent is in prerender mode. */ diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index f4b6ef0f625e..f4ad9506b057 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -2994,6 +2994,13 @@ TabParent::RenderLayers(bool aEnabled) return NS_OK; } +NS_IMETHODIMP +TabParent::GetHasLayers(bool* aResult) +{ + *aResult = mHasLayers; + return NS_OK; +} + NS_IMETHODIMP TabParent::PreserveLayers(bool aPreserveLayers) { diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml index 57bf5309e16b..da27b51e5647 100644 --- a/toolkit/content/widgets/browser.xml +++ b/toolkit/content/widgets/browser.xml @@ -304,6 +304,14 @@ + + + + + + diff --git a/toolkit/content/widgets/remote-browser.xml b/toolkit/content/widgets/remote-browser.xml index af8ac817d9a9..451679546267 100644 --- a/toolkit/content/widgets/remote-browser.xml +++ b/toolkit/content/widgets/remote-browser.xml @@ -260,6 +260,16 @@ ]]> + + + +