Backed out changeset 261be8ec0554 (bug 1397426)

--HG--
extra : rebase_source : f43fabcbb096e007ff81261f8249f9b53f5a5d37
This commit is contained in:
Mike Conley 2017-12-06 16:10:55 -05:00
Родитель 7f920db3d5
Коммит 0d20da44b7
6 изменённых файлов: 69 добавлений и 125 удалений

Просмотреть файл

@ -17,21 +17,10 @@ interface nsITabParent : nsISupports
readonly attribute boolean useAsyncPanZoom;
/**
* Manages the docshell active state of the remote browser. Setting the
* docShell to be active will also cause it to render layers and upload
* them to the compositor. Setting the docShell as not active will clear
* those layers.
* Manages the docshell active state of the remote browser.
*/
attribute boolean docShellIsActive;
/**
* When aEnabled is set to true, this tells the child to paint and
* upload layers to the compositor. When aEnabled is set to false,
* previous layers are cleared from the compositor, but only if
* preserveLayers is also set to false.
*/
void renderLayers(in bool aEnabled);
/**
* Whether this tabParent is in prerender mode.
*/

Просмотреть файл

@ -791,22 +791,11 @@ child:
* Whether to activate or deactivate the docshell.
* @param aPreserveLayers
* Whether layer trees should be preserved for inactive docshells.
*/
async SetDocShellIsActive(bool aIsActive);
/**
* If aEnabled is true, tells the child to paint and upload layers to
* the compositor. If aEnabled is false, the child stops painting and
* clears the layers from the compositor.
*
* @param aEnabled
* True if the child should render and upload layers, false if the
* child should clear layers.
* @param aLayerObserverEpoch
* The layer observer epoch for this activation. This message should be
* ignored if this epoch has already been observed (via ForcePaint).
*/
async RenderLayers(bool aEnabled, uint64_t aLayerObserverEpoch);
async SetDocShellIsActive(bool aIsActive, bool aPreserveLayers, uint64_t aLayerObserverEpoch);
/**
* Notify the child that it shouldn't paint the offscreen displayport.

Просмотреть файл

@ -436,6 +436,7 @@ TabChild::TabChild(nsIContentChild* aManager,
, mTopLevelDocAccessibleChild(nullptr)
#endif
, mPendingDocShellIsActive(false)
, mPendingDocShellPreserveLayers(false)
, mPendingDocShellReceivedMessage(false)
, mPendingDocShellBlockers(0)
, mWidgetNativeData(0)
@ -2661,7 +2662,8 @@ TabChild::RemovePendingDocShellBlocker()
mPendingDocShellBlockers--;
if (!mPendingDocShellBlockers && mPendingDocShellReceivedMessage) {
mPendingDocShellReceivedMessage = false;
InternalSetDocShellIsActive(mPendingDocShellIsActive);
InternalSetDocShellIsActive(mPendingDocShellIsActive,
mPendingDocShellPreserveLayers);
}
}
@ -2683,52 +2685,15 @@ TabChild::OnDocShellActivated(bool aIsActive)
}
void
TabChild::InternalSetDocShellIsActive(bool aIsActive)
TabChild::InternalSetDocShellIsActive(bool aIsActive, bool aPreserveLayers)
{
// docshell is consider prerendered only if not active yet
mIsPrerendered &= !aIsActive;
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
if (docShell) {
docShell->SetIsActive(aIsActive);
}
}
mozilla::ipc::IPCResult
TabChild::RecvSetDocShellIsActive(const bool& aIsActive)
{
// If we're currently waiting for window opening to complete, we need to hold
// off on setting the docshell active. We queue up the values we're receiving
// in the mWindowOpenDocShellActiveStatus.
if (mPendingDocShellBlockers > 0) {
mPendingDocShellReceivedMessage = true;
mPendingDocShellIsActive = aIsActive;
return IPC_OK();
}
InternalSetDocShellIsActive(aIsActive);
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvRenderLayers(const bool& aEnabled, const uint64_t& aLayerObserverEpoch)
{
// Since requests to change the rendering state come in from both the hang
// monitor channel and the PContent channel, we have an ordering problem. This
// code ensures that we respect the order in which the requests were made and
// ignore stale requests.
if (mLayerObserverEpoch >= aLayerObserverEpoch) {
return IPC_OK();
}
mLayerObserverEpoch = aLayerObserverEpoch;
auto clearForcePaint = MakeScopeExit([&] {
// We might force a paint, or we might already have painted and this is a
// no-op. In either case, once we exit this scope, we need to alert the
// ProcessHangMonitor that we've finished responding to what might have
// been a request to force paint. This is so that the BackgroundHangMonitor
// for force painting can be made to wait again.
if (aEnabled) {
if (aIsActive) {
ProcessHangMonitor::ClearForcePaint();
}
});
@ -2740,26 +2705,34 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const uint64_t& aLayerObserverE
// We send the current layer observer epoch to the compositor so that
// TabParent knows whether a layer update notification corresponds to the
// latest RecvRenderLayers request that was made.
// latest SetDocShellIsActive request that was made.
lm->SetLayerObserverEpoch(mLayerObserverEpoch);
}
if (aEnabled) {
if (IsVisible()) {
// docshell is consider prerendered only if not active yet
mIsPrerendered &= !aIsActive;
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
if (docShell) {
bool wasActive;
docShell->GetIsActive(&wasActive);
if (aIsActive && wasActive) {
// This request is a no-op. In this case, we still want a MozLayerTreeReady
// notification to fire in the parent (so that it knows that the child has
// updated its epoch). ForcePaintNoOp does that.
if (IPCOpen()) {
Unused << SendForcePaintNoOp(mLayerObserverEpoch);
return IPC_OK();
return;
}
}
docShell->SetIsActive(aIsActive);
}
if (aIsActive) {
MakeVisible();
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
if (!docShell) {
return IPC_OK();
return;
}
// We don't use TabChildBase::GetPresShell() here because that would create
@ -2767,8 +2740,6 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const uint64_t& aLayerObserverE
// cause JS to run, which we want to avoid. nsIDocShell::GetPresShell
// returns null if no content viewer exists yet.
if (nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell()) {
presShell->SetIsActive(true);
if (nsIFrame* root = presShell->FrameConstructor()->GetRootFrame()) {
FrameLayerBuilder::InvalidateAllLayersForFrame(
nsLayoutUtils::GetDisplayRootFrame(root));
@ -2792,10 +2763,36 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const uint64_t& aLayerObserverE
}
APZCCallbackHelper::SuppressDisplayport(false, presShell);
}
} else {
} else if (!aPreserveLayers) {
MakeHidden();
}
}
mozilla::ipc::IPCResult
TabChild::RecvSetDocShellIsActive(const bool& aIsActive,
const bool& aPreserveLayers,
const uint64_t& aLayerObserverEpoch)
{
// Since requests to change the active docshell come in from both the hang
// monitor channel and the PContent channel, we have an ordering problem. This
// code ensures that we respect the order in which the requests were made and
// ignore stale requests.
if (mLayerObserverEpoch >= aLayerObserverEpoch) {
return IPC_OK();
}
mLayerObserverEpoch = aLayerObserverEpoch;
// If we're currently waiting for window opening to complete, we need to hold
// off on setting the docshell active. We queue up the values we're receiving
// in the mWindowOpenDocShellActiveStatus.
if (mPendingDocShellBlockers > 0) {
mPendingDocShellReceivedMessage = true;
mPendingDocShellIsActive = aIsActive;
mPendingDocShellPreserveLayers = aPreserveLayers;
return IPC_OK();
}
InternalSetDocShellIsActive(aIsActive, aPreserveLayers);
return IPC_OK();
}
@ -3040,7 +3037,7 @@ TabChild::NotifyPainted()
void
TabChild::MakeVisible()
{
if (IsVisible()) {
if (mPuppetWidget && mPuppetWidget->IsVisible()) {
return;
}
@ -3052,7 +3049,7 @@ TabChild::MakeVisible()
void
TabChild::MakeHidden()
{
if (!IsVisible()) {
if (mPuppetWidget && !mPuppetWidget->IsVisible()) {
return;
}
@ -3066,7 +3063,6 @@ TabChild::MakeHidden()
rootPresContext->ComputePluginGeometryUpdates(rootFrame, nullptr, nullptr);
rootPresContext->ApplyPluginGeometryUpdates();
}
shell->SetIsActive(false);
}
if (mPuppetWidget) {
@ -3074,12 +3070,6 @@ TabChild::MakeHidden()
}
}
bool
TabChild::IsVisible()
{
return mPuppetWidget && mPuppetWidget->IsVisible();
}
NS_IMETHODIMP
TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult)
{
@ -3568,7 +3558,7 @@ TabChild::ForcePaint(uint64_t aLayerObserverEpoch)
}
nsAutoScriptBlocker scriptBlocker;
RecvRenderLayers(true, aLayerObserverEpoch);
RecvSetDocShellIsActive(true, false, aLayerObserverEpoch);
}
void

Просмотреть файл

@ -579,7 +579,6 @@ public:
*/
void MakeVisible();
void MakeHidden();
bool IsVisible();
void OnDocShellActivated(bool aIsActive);
@ -803,9 +802,9 @@ protected:
virtual mozilla::ipc::IPCResult RecvDestroy() override;
virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive) override;
virtual mozilla::ipc::IPCResult RecvRenderLayers(const bool& aEnabled, const uint64_t& aLayerObserverEpoch) override;
virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive,
const bool& aIsHidden,
const uint64_t& aLayerObserverEpoch) override;
virtual mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
const bool& aForDocumentNavigation) override;
@ -896,7 +895,8 @@ private:
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId);
void InternalSetDocShellIsActive(bool aIsActive);
void InternalSetDocShellIsActive(bool aIsActive,
bool aPreserveLayers);
bool CreateRemoteLayerManager(mozilla::layers::PCompositorBridgeChild* aCompositorChild);
@ -986,6 +986,7 @@ private:
bool mCoalesceMouseMoveEvents;
bool mPendingDocShellIsActive;
bool mPendingDocShellPreserveLayers;
bool mPendingDocShellReceivedMessage;
uint32_t mPendingDocShellBlockers;

Просмотреть файл

@ -173,7 +173,6 @@ TabParent::TabParent(nsIContentParent* aManager,
#endif
, mLayerTreeEpoch(0)
, mPreserveLayers(false)
, mRenderingLayers(false)
, mHasPresented(false)
, mHasBeforeUnload(false)
, mIsMouseEnterIntoWidgetEventSuppressed(false)
@ -2903,11 +2902,14 @@ TabParent::GetUseAsyncPanZoom(bool* useAsyncPanZoom)
NS_IMETHODIMP
TabParent::SetDocShellIsActive(bool isActive)
{
// Increment the epoch so that layer tree updates from previous
// SetDocShellIsActive requests are ignored.
mLayerTreeEpoch++;
// docshell is consider prerendered only if not active yet
mIsPrerendered &= !isActive;
mDocShellIsActive = isActive;
RenderLayers(isActive);
Unused << SendSetDocShellIsActive(isActive);
Unused << SendSetDocShellIsActive(isActive, mPreserveLayers, mLayerTreeEpoch);
// update active accessible documents on windows
#if defined(XP_WIN) && defined(ACCESSIBILITY)
@ -2930,6 +2932,13 @@ TabParent::SetDocShellIsActive(bool isActive)
// changing of the process priority.
ProcessPriorityManager::TabActivityChanged(this, isActive);
// Ask the child to repaint using the PHangMonitor channel/thread (which may
// be less congested).
if (isActive) {
ContentParent* cp = Manager()->AsContentParent();
cp->ForceTabPaint(this, mLayerTreeEpoch);
}
return NS_OK;
}
@ -2947,37 +2956,6 @@ TabParent::GetIsPrerendered(bool* aIsPrerendered)
return NS_OK;
}
NS_IMETHODIMP
TabParent::RenderLayers(bool aEnabled)
{
if (aEnabled == mRenderingLayers) {
return NS_OK;
}
// Preserve layers means that attempts to stop rendering layers
// will be ignored.
if (!aEnabled && mPreserveLayers) {
return NS_OK;
}
mRenderingLayers = aEnabled;
// Increment the epoch so that layer tree updates from previous
// RenderLayers requests are ignored.
mLayerTreeEpoch++;
Unused << SendRenderLayers(aEnabled, mLayerTreeEpoch);
// Ask the child to repaint using the PHangMonitor channel/thread (which may
// be less congested).
if (aEnabled) {
ContentParent* cp = Manager()->AsContentParent();
cp->ForceTabPaint(this, mLayerTreeEpoch);
}
return NS_OK;
}
NS_IMETHODIMP
TabParent::PreserveLayers(bool aPreserveLayers)
{

Просмотреть файл

@ -782,9 +782,6 @@ private:
// the tab's docshell is inactive.
bool mPreserveLayers;
// Holds the most recent value passed to the RenderLayers function.
bool mRenderingLayers;
// True if this TabParent has had its layer tree sent to the compositor
// at least once.
bool mHasPresented;