Bug 1444580: Devirtualize the visibility state stuff. r=smaug

Also rename GetVisibilityState to ComputeVisibilityState, since that's what it
does, the getter is VisibilityState.

MozReview-Commit-ID: 9qfKvUmO0dW
This commit is contained in:
Emilio Cobos Álvarez 2018-03-10 05:52:58 +01:00
Родитель ac1848dee7
Коммит 0f6e1aec50
3 изменённых файлов: 22 добавлений и 22 удалений

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

@ -4971,7 +4971,7 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
// doing the initial document load and don't want to fire the event for this
// change.
dom::VisibilityState oldState = mVisibilityState;
mVisibilityState = GetVisibilityState();
mVisibilityState = ComputeVisibilityState();
// When the visibility is changed, notify it to observers.
// Some observers need the notification, for example HTMLMediaElement uses
// it to update internal media resource allocation.
@ -11816,10 +11816,10 @@ nsIDocument::UnlockPointer(nsIDocument* aDoc)
}
void
nsDocument::UpdateVisibilityState()
nsIDocument::UpdateVisibilityState()
{
dom::VisibilityState oldState = mVisibilityState;
mVisibilityState = GetVisibilityState();
mVisibilityState = ComputeVisibilityState();
if (oldState != mVisibilityState) {
nsContentUtils::DispatchTrustedEvent(this, static_cast<nsIDocument*>(this),
NS_LITERAL_STRING("visibilitychange"),
@ -11834,7 +11834,7 @@ nsDocument::UpdateVisibilityState()
}
VisibilityState
nsDocument::GetVisibilityState() const
nsIDocument::ComputeVisibilityState() const
{
// We have to check a few pieces of information here:
// 1) Are we in bfcache (!IsVisible())? If so, nothing else matters.
@ -11851,18 +11851,18 @@ nsDocument::GetVisibilityState() const
return dom::VisibilityState::Visible;
}
/* virtual */ void
nsDocument::PostVisibilityUpdateEvent()
void
nsIDocument::PostVisibilityUpdateEvent()
{
nsCOMPtr<nsIRunnable> event =
NewRunnableMethod("nsDocument::UpdateVisibilityState",
NewRunnableMethod("nsIDocument::UpdateVisibilityState",
this,
&nsDocument::UpdateVisibilityState);
&nsIDocument::UpdateVisibilityState);
Dispatch(TaskCategory::Other, event.forget());
}
void
nsDocument::MaybeActiveMediaComponents()
nsIDocument::MaybeActiveMediaComponents()
{
if (!mWindow) {
return;

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

@ -747,16 +747,6 @@ public:
void SetOrientationPendingPromise(mozilla::dom::Promise* aPromise) override;
mozilla::dom::Promise* GetOrientationPendingPromise() const override;
// This method may fire a DOM event; if it does so it will happen
// synchronously.
void UpdateVisibilityState();
// Posts an event to call UpdateVisibilityState
virtual void PostVisibilityUpdateEvent() override;
// Since we wouldn't automatically play media from non-visited page, we need
// to notify window when the page was first visited.
void MaybeActiveMediaComponents();
virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const override;
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
@ -901,8 +891,6 @@ public:
nsCOMPtr<nsIContent> mFirstBaseNodeWithHref;
private:
friend class nsUnblockOnloadEvent;
// Recomputes the visibility state but doesn't set the new value.
mozilla::dom::VisibilityState GetVisibilityState() const;
void PostUnblockOnloadEvent();
void DoUnblockOnload();

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

@ -2822,7 +2822,8 @@ public:
const char16_t **aParams = nullptr,
uint32_t aParamsLength = 0) const;
virtual void PostVisibilityUpdateEvent() = 0;
// Posts an event to call UpdateVisibilityState
void PostVisibilityUpdateEvent();
bool IsSyntheticDocument() const { return mIsSyntheticDocument; }
@ -3332,6 +3333,17 @@ protected:
void RecordNavigationTiming(ReadyState aReadyState);
// This method may fire a DOM event; if it does so it will happen
// synchronously.
void UpdateVisibilityState();
// Recomputes the visibility state but doesn't set the new value.
mozilla::dom::VisibilityState ComputeVisibilityState() const;
// Since we wouldn't automatically play media from non-visited page, we need
// to notify window when the page was first visited.
void MaybeActiveMediaComponents();
bool GetUseCounter(mozilla::UseCounter aUseCounter)
{
return mUseCounters[aUseCounter];