Bug 1343728 - Part 1: Add the ability to temporarially delay remote docshells from becoming active, r=smaug

MozReview-Commit-ID: KAaeu5ETc0x
This commit is contained in:
Michael Layzell 2017-06-15 13:23:55 -04:00
Родитель cc6563e878
Коммит 67f704555d
2 изменённых файлов: 62 добавлений и 15 удалений

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

@ -407,6 +407,10 @@ TabChild::TabChild(nsIContentChild* aManager,
#if defined(ACCESSIBILITY)
, mTopLevelDocAccessibleChild(nullptr)
#endif
, mPendingDocShellIsActive(false)
, mPendingDocShellPreserveLayers(false)
, mPendingDocShellReceivedMessage(false)
, mPendingDocShellBlockers(0)
{
nsWeakPtr weakPtrThis(do_GetWeakReference(static_cast<nsITabChild*>(this))); // for capture by the lambda
mSetAllowedTouchBehaviorCallback = [weakPtrThis](uint64_t aInputBlockId,
@ -2363,20 +2367,26 @@ TabChild::RecvDestroy()
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvSetDocShellIsActive(const bool& aIsActive,
const bool& aPreserveLayers,
const uint64_t& aLayerObserverEpoch)
void
TabChild::AddPendingDocShellBlocker()
{
// Since SetDocShellIsActive requests 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;
mPendingDocShellBlockers++;
}
void
TabChild::RemovePendingDocShellBlocker()
{
mPendingDocShellBlockers--;
if (!mPendingDocShellBlockers && mPendingDocShellReceivedMessage) {
mPendingDocShellReceivedMessage = false;
InternalSetDocShellIsActive(mPendingDocShellIsActive,
mPendingDocShellPreserveLayers);
}
}
void
TabChild::InternalSetDocShellIsActive(bool aIsActive, bool aPreserveLayers)
{
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
@ -2402,7 +2412,7 @@ TabChild::RecvSetDocShellIsActive(const bool& aIsActive,
// We send the current layer observer epoch to the compositor so that
// TabParent knows whether a layer update notification corresponds to the
// latest SetDocShellIsActive request that was made.
mPuppetWidget->GetLayerManager()->SetLayerObserverEpoch(aLayerObserverEpoch);
mPuppetWidget->GetLayerManager()->SetLayerObserverEpoch(mLayerObserverEpoch);
}
// docshell is consider prerendered only if not active yet
@ -2416,8 +2426,8 @@ TabChild::RecvSetDocShellIsActive(const bool& aIsActive,
// notification to fire in the parent (so that it knows that the child has
// updated its epoch). ForcePaintNoOp does that.
if (IPCOpen()) {
Unused << SendForcePaintNoOp(aLayerObserverEpoch);
return IPC_OK();
Unused << SendForcePaintNoOp(mLayerObserverEpoch);
return;
}
}
@ -2458,7 +2468,33 @@ TabChild::RecvSetDocShellIsActive(const bool& aIsActive,
} 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();
}

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

@ -694,6 +694,9 @@ public:
}
#endif
void AddPendingDocShellBlocker();
void RemovePendingDocShellBlocker();
protected:
virtual ~TabChild();
@ -790,6 +793,9 @@ private:
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId);
void InternalSetDocShellIsActive(bool aIsActive,
bool aPreserveLayers);
class DelayedDeleteRunnable;
TextureFactoryIdentifier mTextureFactoryIdentifier;
@ -870,6 +876,11 @@ private:
PDocAccessibleChild* mTopLevelDocAccessibleChild;
#endif
bool mPendingDocShellIsActive;
bool mPendingDocShellPreserveLayers;
bool mPendingDocShellReceivedMessage;
uint32_t mPendingDocShellBlockers;
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
};