Bug 1268348 - Pass the previous visibility state to OnVisibilityChange(). r=mstange

This commit is contained in:
Seth Fowler 2016-05-11 19:27:27 -07:00
parent 1039567f4e
commit 180fb0583d
10 changed files with 64 additions and 31 deletions

View File

@ -180,6 +180,7 @@ interface nsIImageLoadingContent : imgINotificationObserver
* Called by layout to announce when the frame associated with this content
* has changed its visibility state.
*
* @param aOldVisibility The previous visibility state.
* @param aNewVisibility The new visibility state.
* @param aNonvisibleAction A requested action if the frame has become
* nonvisible. If Nothing(), no action is
@ -188,6 +189,7 @@ interface nsIImageLoadingContent : imgINotificationObserver
* associated with to discard their surfaces if
* possible.
*/
[noscript, notxpcom] void onVisibilityChange(in Visibility aNewVisibility,
[noscript, notxpcom] void onVisibilityChange(in Visibility aOldVisibility,
in Visibility aNewVisibility,
in MaybeOnNonvisible aNonvisibleAction);
};

View File

@ -1425,14 +1425,17 @@ nsImageLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
}
void
nsImageLoadingContent::OnVisibilityChange(Visibility aNewVisibility,
nsImageLoadingContent::OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
const Maybe<OnNonvisible>& aNonvisibleAction)
{
switch (aNewVisibility) {
case Visibility::MAY_BECOME_VISIBLE:
case Visibility::IN_DISPLAYPORT:
TrackImage(mCurrentRequest);
TrackImage(mPendingRequest);
if (aOldVisibility == Visibility::NONVISIBLE) {
TrackImage(mCurrentRequest);
TrackImage(mPendingRequest);
}
break;
case Visibility::NONVISIBLE:

View File

@ -1600,7 +1600,7 @@ nsIFrame::DisableVisibilityTracking()
}
// We were visible, so send an OnVisibilityChange() notification.
OnVisibilityChange(Visibility::NONVISIBLE);
OnVisibilityChange(previousVisibility, Visibility::NONVISIBLE);
}
void
@ -1636,7 +1636,7 @@ nsIFrame::DecVisibilityCount(VisibilityCounter aCounter,
}
// Our visibility just changed, so send an OnVisibilityChange() notification.
OnVisibilityChange(newVisibility, aNonvisibleAction);
OnVisibilityChange(previousVisibility, newVisibility, aNonvisibleAction);
}
void
@ -1667,16 +1667,21 @@ nsIFrame::IncVisibilityCount(VisibilityCounter aCounter)
}
// Our visibility just changed, so send an OnVisibilityChange() notification.
OnVisibilityChange(newVisibility);
OnVisibilityChange(previousVisibility, newVisibility);
}
void
nsIFrame::OnVisibilityChange(Visibility aNewVisibility,
nsIFrame::OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction
/* = Nothing() */)
{
// XXX(seth): In bug 1218990 we'll implement visibility tracking for CSS
// images here.
MOZ_ASSERT(aOldVisibility != Visibility::UNTRACKED,
"Should've started at Visibility::NONVISIBLE");
MOZ_ASSERT(aNewVisibility != Visibility::UNTRACKED,
"Shouldn't notify for Visibility::UNTRACKED");
}
static nsIFrame*

View File

@ -1158,6 +1158,7 @@ protected:
* Called when a frame transitions between visibility states (for example,
* from nonvisible to visible, or from visible to nonvisible).
*
* @param aOldVisibility The previous visibility state.
* @param aNewVisibility The new visibility state.
* @param aNonvisibleAction A requested action if the frame has become
* nonvisible. If Nothing(), no action is
@ -1169,7 +1170,8 @@ protected:
* Subclasses which override this method should call their parent class's
* implementation.
*/
virtual void OnVisibilityChange(Visibility aNewVisibility,
virtual void OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction = Nothing());
public:

View File

@ -2073,24 +2073,29 @@ nsImageFrame::AttributeChanged(int32_t aNameSpaceID,
}
void
nsImageFrame::OnVisibilityChange(Visibility aNewVisibility,
nsImageFrame::OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction)
{
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
if (!imageLoader) {
MOZ_ASSERT_UNREACHABLE("Should have an nsIImageLoadingContent");
nsAtomicContainerFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsAtomicContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
return;
}
imageLoader->OnVisibilityChange(aNewVisibility, aNonvisibleAction);
imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
if (aNewVisibility == Visibility::MAY_BECOME_VISIBLE ||
aNewVisibility == Visibility::IN_DISPLAYPORT) {
if (aOldVisibility == Visibility::NONVISIBLE &&
(aNewVisibility == Visibility::MAY_BECOME_VISIBLE ||
aNewVisibility == Visibility::IN_DISPLAYPORT)) {
MaybeDecodeForPredictedSize();
}
nsAtomicContainerFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsAtomicContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
}
nsIAtom*

View File

@ -106,7 +106,8 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
void OnVisibilityChange(Visibility aNewVisibility,
void OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction = Nothing()) override;
#ifdef ACCESSIBILITY

View File

@ -618,18 +618,22 @@ nsVideoFrame::AttributeChanged(int32_t aNameSpaceID,
}
void
nsVideoFrame::OnVisibilityChange(Visibility aNewVisibility,
nsVideoFrame::OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction)
{
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mPosterImage);
if (!imageLoader) {
nsContainerFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
return;
}
imageLoader->OnVisibilityChange(aNewVisibility, aNonvisibleAction);
imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
nsContainerFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
}
bool nsVideoFrame::HasVideoElement() {

View File

@ -52,7 +52,8 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
void OnVisibilityChange(Visibility aNewVisibility,
void OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction = Nothing()) override;
/* get the size of the video's display */

View File

@ -64,7 +64,8 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
void OnVisibilityChange(Visibility aNewVisibility,
void OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction = Nothing()) override;
virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
@ -146,18 +147,22 @@ SVGFEImageFrame::AttributeChanged(int32_t aNameSpaceID,
}
void
SVGFEImageFrame::OnVisibilityChange(Visibility aNewVisibility,
SVGFEImageFrame::OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction)
{
nsCOMPtr<nsIImageLoadingContent> imageLoader =
do_QueryInterface(nsFrame::mContent);
if (!imageLoader) {
MOZ_ASSERT_UNREACHABLE("Should have an nsIImageLoadingContent");
nsFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
return;
}
imageLoader->OnVisibilityChange(aNewVisibility, aNonvisibleAction);
imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
nsFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
}

View File

@ -79,7 +79,8 @@ public:
nsIAtom* aAttribute,
int32_t aModType) override;
void OnVisibilityChange(Visibility aNewVisibility,
void OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction = Nothing()) override;
virtual void Init(nsIContent* aContent,
@ -240,18 +241,22 @@ nsSVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
}
void
nsSVGImageFrame::OnVisibilityChange(Visibility aNewVisibility,
nsSVGImageFrame::OnVisibilityChange(Visibility aOldVisibility,
Visibility aNewVisibility,
Maybe<OnNonvisible> aNonvisibleAction)
{
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
if (!imageLoader) {
nsSVGPathGeometryFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsSVGPathGeometryFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
return;
}
imageLoader->OnVisibilityChange(aNewVisibility, aNonvisibleAction);
imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
nsSVGPathGeometryFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
nsSVGPathGeometryFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
aNonvisibleAction);
}
gfx::Matrix