Bug 1309082 - Part 2: Rename some ImageTracker members. r=bholley
MozReview-Commit-ID: 6yOIKKl8npT
--- a/dom/base/ImageTracker.cpp
+++ b/dom/base/ImageTracker.cpp
@@ -8,154 +8,154 @@
* animating */
#include "ImageTracker.h"
namespace mozilla {
namespace dom {
ImageTracker::ImageTracker()
- : mLockingImages(false)
- , mAnimatingImages(true)
+ : mLocking(false)
+ , mAnimating(true)
{
}
ImageTracker::~ImageTracker()
{
- SetImageLockingState(false);
+ SetLockingState(false);
}
nsresult
-ImageTracker::AddImage(imgIRequest* aImage)
+ImageTracker::Add(imgIRequest* aImage)
{
MOZ_ASSERT(aImage);
// See if the image is already in the hashtable. If it is, get the old count.
uint32_t oldCount = 0;
- mImageTracker.Get(aImage, &oldCount);
+ mImages.Get(aImage, &oldCount);
// Put the image in the hashtable, with the proper count.
- mImageTracker.Put(aImage, oldCount + 1);
+ mImages.Put(aImage, oldCount + 1);
nsresult rv = NS_OK;
// If this is the first insertion and we're locking images, lock this image
// too.
- if (oldCount == 0 && mLockingImages) {
+ if (oldCount == 0 && mLocking) {
rv = aImage->LockImage();
}
// If this is the first insertion and we're animating images, request
// that this image be animated too.
- if (oldCount == 0 && mAnimatingImages) {
+ if (oldCount == 0 && mAnimating) {
nsresult rv2 = aImage->IncrementAnimationConsumers();
rv = NS_SUCCEEDED(rv) ? rv2 : rv;
}
return rv;
}
nsresult
-ImageTracker::RemoveImage(imgIRequest* aImage, uint32_t aFlags)
+ImageTracker::Remove(imgIRequest* aImage, uint32_t aFlags)
{
NS_ENSURE_ARG_POINTER(aImage);
// Get the old count. It should exist and be > 0.
uint32_t count = 0;
- DebugOnly<bool> found = mImageTracker.Get(aImage, &count);
+ DebugOnly<bool> found = mImages.Get(aImage, &count);
MOZ_ASSERT(found, "Removing image that wasn't in the tracker!");
MOZ_ASSERT(count > 0, "Entry in the cache tracker with count 0!");
// We're removing, so decrement the count.
count--;
// If the count is now zero, remove from the tracker.
// Otherwise, set the new value.
if (count != 0) {
- mImageTracker.Put(aImage, count);
+ mImages.Put(aImage, count);
return NS_OK;
}
- mImageTracker.Remove(aImage);
+ mImages.Remove(aImage);
nsresult rv = NS_OK;
// Now that we're no longer tracking this image, unlock it if we'd
// previously locked it.
- if (mLockingImages) {
+ if (mLocking) {
rv = aImage->UnlockImage();
}
// If we're animating images, remove our request to animate this one.
- if (mAnimatingImages) {
+ if (mAnimating) {
nsresult rv2 = aImage->DecrementAnimationConsumers();
rv = NS_SUCCEEDED(rv) ? rv2 : rv;
}
if (aFlags & REQUEST_DISCARD) {
// Request that the image be discarded if nobody else holds a lock on it.
- // Do this even if !mLockingImages, because even if we didn't just unlock
+ // Do this even if !mLocking, because even if we didn't just unlock
// this image, it might still be a candidate for discarding.
aImage->RequestDiscard();
}
return rv;
}
nsresult
-ImageTracker::SetImageLockingState(bool aLocked)
+ImageTracker::SetLockingState(bool aLocked)
{
if (XRE_IsContentProcess() &&
!Preferences::GetBool("image.mem.allow_locking_in_content_processes", true)) {
return NS_OK;
}
// If there's no change, there's nothing to do.
- if (mLockingImages == aLocked)
+ if (mLocking == aLocked)
return NS_OK;
// Otherwise, iterate over our images and perform the appropriate action.
- for (auto iter = mImageTracker.Iter(); !iter.Done(); iter.Next()) {
+ for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
imgIRequest* image = iter.Key();
if (aLocked) {
image->LockImage();
} else {
image->UnlockImage();
}
}
// Update state.
- mLockingImages = aLocked;
+ mLocking = aLocked;
return NS_OK;
}
void
-ImageTracker::SetImagesNeedAnimating(bool aAnimating)
+ImageTracker::SetAnimatingState(bool aAnimating)
{
// If there's no change, there's nothing to do.
- if (mAnimatingImages == aAnimating)
+ if (mAnimating == aAnimating)
return;
// Otherwise, iterate over our images and perform the appropriate action.
- for (auto iter = mImageTracker.Iter(); !iter.Done(); iter.Next()) {
+ for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
imgIRequest* image = iter.Key();
if (aAnimating) {
image->IncrementAnimationConsumers();
} else {
image->DecrementAnimationConsumers();
}
}
// Update state.
- mAnimatingImages = aAnimating;
+ mAnimating = aAnimating;
}
void
ImageTracker::RequestDiscardAll()
{
- for (auto iter = mImageTracker.Iter(); !iter.Done(); iter.Next()) {
+ for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
iter.Key()->RequestDiscard();
}
}
} // namespace dom
} // namespace mozilla
--- a/dom/base/ImageTracker.h
+++ b/dom/base/ImageTracker.h
@@ -21,49 +21,49 @@ namespace dom {
/*
* Image Tracking
*
* Style and content images register their imgIRequests with their document's
* image tracker, so that we can efficiently tell all descendant images when
* they are and are not visible. When an image is on-screen, we want to call
* LockImage() on it so that it doesn't do things like discarding frame data
* to save memory. The PresShell informs its document's image tracker whether
- * its images should be locked or not via SetImageLockingState().
+ * its images should be locked or not via SetLockingState().
*
* See bug 512260.
*/
class ImageTracker
{
public:
ImageTracker();
ImageTracker(const ImageTracker&) = delete;
ImageTracker& operator=(const ImageTracker&) = delete;
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageTracker)
- nsresult AddImage(imgIRequest* aImage);
+ nsresult Add(imgIRequest* aImage);
enum { REQUEST_DISCARD = 0x1 };
- nsresult RemoveImage(imgIRequest* aImage, uint32_t aFlags = 0);
+ nsresult Remove(imgIRequest* aImage, uint32_t aFlags = 0);
// Makes the images on this document locked/unlocked. By default, the locking
// state is unlocked/false.
- nsresult SetImageLockingState(bool aLocked);
+ nsresult SetLockingState(bool aLocked);
// Makes the images on this document capable of having their animation
// active or suspended. An Image will animate as long as at least one of its
// owning Documents needs it to animate; otherwise it can suspend.
- void SetImagesNeedAnimating(bool aAnimating);
+ void SetAnimatingState(bool aAnimating);
void RequestDiscardAll();
private:
~ImageTracker();
- nsDataHashtable<nsPtrHashKey<imgIRequest>, uint32_t> mImageTracker;
- bool mLockingImages;
- bool mAnimatingImages;
+ nsDataHashtable<nsPtrHashKey<imgIRequest>, uint32_t> mImages;
+ bool mLocking;
+ bool mAnimating;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ImageTracker
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -8709,17 +8709,17 @@ nsDocument::OnPageShow(bool aPersisted,
mIsShowing = true;
}
if (mAnimationController) {
mAnimationController->OnPageShow();
}
if (aPersisted) {
- ImageTracker()->SetImagesNeedAnimating(true);
+ ImageTracker()->SetAnimatingState(true);
}
UpdateVisibilityState();
nsCOMPtr<EventTarget> target = aDispatchStartTarget;
if (!target) {
target = do_QueryInterface(GetWindow());
}
@@ -8804,17 +8804,17 @@ nsDocument::OnPageHide(bool aPersisted,
if (mAnimationController) {
mAnimationController->OnPageHide();
}
// We do not stop the animations (bug 1024343)
// when the page is refreshing while being dragged out
nsDocShell* docShell = mDocumentContainer.get();
if (aPersisted && !(docShell && docShell->InFrameSwap())) {
- ImageTracker()->SetImagesNeedAnimating(false);
+ ImageTracker()->SetAnimatingState(false);
}
ExitPointerLock();
// Now send out a PageHide event.
nsCOMPtr<EventTarget> target = aDispatchStartTarget;
if (!target) {
target = do_QueryInterface(GetWindow());
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -1471,21 +1471,21 @@ nsImageLoadingContent::TrackImage(imgIRe
nsIFrame* frame = GetOurPrimaryFrame();
if ((frame && frame->GetVisibility() == Visibility::APPROXIMATELY_NONVISIBLE) ||
(!frame && !mFrameCreateCalled)) {
return;
}
if (aImage == mCurrentRequest && !(mCurrentRequestFlags & REQUEST_IS_TRACKED)) {
mCurrentRequestFlags |= REQUEST_IS_TRACKED;
- doc->ImageTracker()->AddImage(mCurrentRequest);
+ doc->ImageTracker()->Add(mCurrentRequest);
}
if (aImage == mPendingRequest && !(mPendingRequestFlags & REQUEST_IS_TRACKED)) {
mPendingRequestFlags |= REQUEST_IS_TRACKED;
- doc->ImageTracker()->AddImage(mPendingRequest);
+ doc->ImageTracker()->Add(mPendingRequest);
}
}
void
nsImageLoadingContent::UntrackImage(imgIRequest* aImage,
const Maybe<OnNonvisible>& aNonvisibleAction
/* = Nothing() */)
{
@@ -1498,30 +1498,30 @@ nsImageLoadingContent::UntrackImage(imgI
// We may not be in the document. If we outlived our document that's fine,
// because the document empties out the tracker and unlocks all locked images
// on destruction. But if we were never in the document we may need to force
// discarding the image here, since this is the only chance we have.
nsIDocument* doc = GetOurCurrentDoc();
if (aImage == mCurrentRequest) {
if (doc && (mCurrentRequestFlags & REQUEST_IS_TRACKED)) {
mCurrentRequestFlags &= ~REQUEST_IS_TRACKED;
- doc->ImageTracker()->RemoveImage(
+ doc->ImageTracker()->Remove(
mCurrentRequest,
aNonvisibleAction == Some(OnNonvisible::DISCARD_IMAGES)
? ImageTracker::REQUEST_DISCARD
: 0);
} else if (aNonvisibleAction == Some(OnNonvisible::DISCARD_IMAGES)) {
// If we're not in the document we may still need to be discarded.
aImage->RequestDiscard();
}
}
if (aImage == mPendingRequest) {
if (doc && (mPendingRequestFlags & REQUEST_IS_TRACKED)) {
mPendingRequestFlags &= ~REQUEST_IS_TRACKED;
- doc->ImageTracker()->RemoveImage(
+ doc->ImageTracker()->Remove(
mPendingRequest,
aNonvisibleAction == Some(OnNonvisible::DISCARD_IMAGES)
? ImageTracker::REQUEST_DISCARD
: 0);
} else if (aNonvisibleAction == Some(OnNonvisible::DISCARD_IMAGES)) {
// If we're not in the document we may still need to be discarded.
aImage->RequestDiscard();
}
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -166,17 +166,17 @@ gfxSVGGlyphsDocument::SetupPresentation(
}
mDocument->FlushPendingNotifications(Flush_Layout);
nsSMILAnimationController* controller = mDocument->GetAnimationController();
if (controller) {
controller->Resume(nsSMILTimeContainer::PAUSE_IMAGE);
}
- mDocument->ImageTracker()->SetImagesNeedAnimating(true);
+ mDocument->ImageTracker()->SetAnimatingState(true);
mViewer = viewer;
mPresShell = presShell;
mPresShell->AddPostRefreshObserver(this);
return NS_OK;
}
--- a/image/SVGDocumentWrapper.cpp
+++ b/image/SVGDocumentWrapper.cpp
@@ -150,17 +150,17 @@ SVGDocumentWrapper::StartAnimation()
}
nsIDocument* doc = mViewer->GetDocument();
if (doc) {
nsSMILAnimationController* controller = doc->GetAnimationController();
if (controller) {
controller->Resume(nsSMILTimeContainer::PAUSE_IMAGE);
}
- doc->ImageTracker()->SetImagesNeedAnimating(true);
+ doc->ImageTracker()->SetAnimatingState(true);
}
}
void
SVGDocumentWrapper::StopAnimation()
{
// Can be called for animated images during shutdown, after we've
// already Observe()'d XPCOM shutdown and cleared out our mViewer pointer.
@@ -169,17 +169,17 @@ SVGDocumentWrapper::StopAnimation()
}
nsIDocument* doc = mViewer->GetDocument();
if (doc) {
nsSMILAnimationController* controller = doc->GetAnimationController();
if (controller) {
controller->Pause(nsSMILTimeContainer::PAUSE_IMAGE);
}
- doc->ImageTracker()->SetImagesNeedAnimating(false);
+ doc->ImageTracker()->SetAnimatingState(false);
}
}
void
SVGDocumentWrapper::ResetAnimation()
{
SVGSVGElement* svgElem = GetRootSVGElem();
if (!svgElem) {
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -10938,17 +10938,17 @@ PresShell::SetIsActive(bool aIsActive)
* dependent factors changes.
*/
nsresult
PresShell::UpdateImageLockingState()
{
// We're locked if we're both thawed and active.
bool locked = !mFrozen && mIsActive;
- nsresult rv = mDocument->ImageTracker()->SetImageLockingState(locked);
+ nsresult rv = mDocument->ImageTracker()->SetLockingState(locked);
if (locked) {
// Request decodes for visible image frames; we want to start decoding as
// quickly as possible when we get foregrounded to minimize flashing.
for (auto iter = mApproximatelyVisibleFrames.Iter(); !iter.Done(); iter.Next()) {
nsImageFrame* imageFrame = do_QueryFrame(iter.Get()->GetKey());
if (imageFrame) {
imageFrame->MaybeDecodeForPredictedSize();
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2007,17 +2007,17 @@ nsStyleImage::TrackImage(nsPresContext*
// Sanity
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
MOZ_ASSERT(mType == eStyleImageType_Image,
"Can't track image when there isn't one!");
// Register the image with the document
nsIDocument* doc = aContext->Document();
if (doc) {
- doc->ImageTracker()->AddImage(mImage);
+ doc->ImageTracker()->Add(mImage);
}
// Mark state
#ifdef DEBUG
mImageTracked = true;
#endif
}
@@ -2027,17 +2027,17 @@ nsStyleImage::UntrackImage(nsPresContext
// Sanity
MOZ_ASSERT(mImageTracked, "Image not tracked!");
MOZ_ASSERT(mType == eStyleImageType_Image,
"Can't untrack image when there isn't one!");
// Unregister the image with the document
nsIDocument* doc = aContext->Document();
if (doc) {
- doc->ImageTracker()->RemoveImage(mImage);
+ doc->ImageTracker()->Remove(mImage);
}
// Mark state
#ifdef DEBUG
mImageTracked = false;
#endif
}
@@ -3434,17 +3434,17 @@ nsStyleContentData::TrackImage(nsPresCon
MOZ_ASSERT(mType == eStyleContentType_Image,
"Trying to do image tracking on non-image!");
MOZ_ASSERT(mContent.mImage,
"Can't track image when there isn't one!");
// Register the image with the document
nsIDocument* doc = aContext->Document();
if (doc) {
- doc->ImageTracker()->AddImage(mContent.mImage);
+ doc->ImageTracker()->Add(mContent.mImage);
}
// Mark state
#ifdef DEBUG
mImageTracked = true;
#endif
}
@@ -3456,17 +3456,17 @@ nsStyleContentData::UntrackImage(nsPresC
MOZ_ASSERT(mType == eStyleContentType_Image,
"Trying to do image tracking on non-image!");
MOZ_ASSERT(mContent.mImage,
"Can't untrack image when there isn't one!");
// Unregister the image with the document
nsIDocument* doc = aContext->Document();
if (doc) {
- doc->ImageTracker()->RemoveImage(mContent.mImage);
+ doc->ImageTracker()->Remove(mContent.mImage);
}
// Mark state
#ifdef DEBUG
mImageTracked = false;
#endif
}