Bug 1288302 - Part 2: Pass ImageTracker to style struct image tracking methods instead of nsPresContext. r=xidorn

MozReview-Commit-ID: AsGfXliHLRf
This commit is contained in:
Cameron McCormack 2016-10-20 08:36:16 +08:00
Родитель 9cc773db64
Коммит 0387dc2875
4 изменённых файлов: 43 добавлений и 51 удалений

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

@ -670,7 +670,7 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
// We could do something fancy to avoid the TrackImage/UntrackImage
// work, but it doesn't seem worth it. (We need to call TrackImage
// since we're not going through nsRuleNode::ComputeBorderData.)
newStyleBorder.TrackImage(aPresContext);
newStyleBorder.TrackImage(aPresContext->Document()->ImageTracker());
NS_FOR_CSS_SIDES(side) {
nscolor color = aStyleContext->GetVisitedDependentColor(
@ -685,7 +685,7 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
// We could do something fancy to avoid the TrackImage/UntrackImage
// work, but it doesn't seem worth it. (We need to call UntrackImage
// since we're not going through nsStyleBorder::Destroy.)
newStyleBorder.UntrackImage(aPresContext);
newStyleBorder.UntrackImage(aPresContext->Document()->ImageTracker());
return result;
}

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

@ -7329,7 +7329,7 @@ nsRuleNode::ComputeBackgroundData(void* aStartStruct,
}
// Now that the dust has settled, register the images with the document
bg->mImage.TrackImages(aContext->PresContext());
bg->mImage.TrackImages(aContext->PresContext()->Document()->ImageTracker());
COMPUTE_END_RESET(Background, bg)
}
@ -7717,7 +7717,7 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
parentBorder->mBorderImageRepeatV,
NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH);
border->TrackImage(aContext->PresContext());
border->TrackImage(aContext->PresContext()->Document()->ImageTracker());
COMPUTE_END_RESET(Border, border)
}
@ -8985,7 +8985,8 @@ nsRuleNode::ComputeContentData(void* aStartStruct,
for (uint32_t i = 0; i < content->ContentCount(); ++i) {
if ((content->ContentAt(i).mType == eStyleContentType_Image) &&
content->ContentAt(i).mContent.mImage) {
content->ContentAt(i).TrackImage(aContext->PresContext());
content->ContentAt(i).TrackImage(
aContext->PresContext()->Document()->ImageTracker());
}
}
@ -10054,7 +10055,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
}
#endif
svgReset->mMask.TrackImages(aContext->PresContext());
svgReset->mMask.TrackImages(aContext->PresContext()->Document()->ImageTracker());
COMPUTE_END_RESET(SVGReset, svgReset)
}

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

@ -464,8 +464,10 @@ nsStyleBorder::GetImageOutset() const
}
void
nsStyleBorder::Destroy(nsPresContext* aContext) {
UntrackImage(aContext);
nsStyleBorder::Destroy(nsPresContext* aContext)
{
UntrackImage(aContext->Document()->ImageTracker());
this->~nsStyleBorder();
aContext->PresShell()->
FreeByObjectID(eArenaObjectID_nsStyleBorder, this);
@ -1169,7 +1171,7 @@ nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource)
void
nsStyleSVGReset::Destroy(nsPresContext* aContext)
{
mMask.UntrackImages(aContext);
mMask.UntrackImages(aContext->Document()->ImageTracker());
this->~nsStyleSVGReset();
aContext->PresShell()->
@ -2011,18 +2013,14 @@ nsStyleImage::SetImageData(imgRequestProxy* aImage)
}
void
nsStyleImage::TrackImage(nsPresContext* aContext)
nsStyleImage::TrackImage(ImageTracker* aImageTracker)
{
// 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()->Add(mImage);
}
aImageTracker->Add(mImage);
// Mark state
#ifdef DEBUG
@ -2031,18 +2029,14 @@ nsStyleImage::TrackImage(nsPresContext* aContext)
}
void
nsStyleImage::UntrackImage(nsPresContext* aContext)
nsStyleImage::UntrackImage(ImageTracker* aImageTracker)
{
// 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()->Remove(mImage);
}
aImageTracker->Remove(mImage);
// Mark state
#ifdef DEBUG
@ -2769,7 +2763,7 @@ void
nsStyleBackground::Destroy(nsPresContext* aContext)
{
// Untrack all the images stored in our layers
mImage.UntrackImages(aContext);
mImage.UntrackImages(aContext->Document()->ImageTracker());
this->~nsStyleBackground();
aContext->PresShell()->
@ -3427,7 +3421,7 @@ nsStyleContentData::operator==(const nsStyleContentData& aOther) const
}
void
nsStyleContentData::TrackImage(nsPresContext* aContext)
nsStyleContentData::TrackImage(ImageTracker* aImageTracker)
{
// Sanity
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
@ -3436,11 +3430,7 @@ nsStyleContentData::TrackImage(nsPresContext* aContext)
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()->Add(mContent.mImage);
}
aImageTracker->Add(mContent.mImage);
// Mark state
#ifdef DEBUG
@ -3449,7 +3439,7 @@ nsStyleContentData::TrackImage(nsPresContext* aContext)
}
void
nsStyleContentData::UntrackImage(nsPresContext* aContext)
nsStyleContentData::UntrackImage(ImageTracker* aImageTracker)
{
// Sanity
MOZ_ASSERT(mImageTracked, "Image not tracked!");
@ -3458,11 +3448,7 @@ nsStyleContentData::UntrackImage(nsPresContext* aContext)
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()->Remove(mContent.mImage);
}
aImageTracker->Remove(mContent.mImage);
// Mark state
#ifdef DEBUG
@ -3492,7 +3478,7 @@ nsStyleContent::Destroy(nsPresContext* aContext)
// Unregister any images we might have with the document.
for (auto& content : mContents) {
if (content.mType == eStyleContentType_Image && content.mContent.mImage) {
content.UntrackImage(aContext);
content.UntrackImage(aContext->Document()->ImageTracker());
}
}

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

@ -46,6 +46,11 @@ class nsStyleContext;
class nsTextFrame;
class imgIContainer;
struct nsStyleVisibility;
namespace mozilla {
namespace dom {
class ImageTracker;
} // namespace dom
} // namespace mozilla
typedef nsINode RawGeckoNode;
typedef mozilla::dom::Element RawGeckoElement;
@ -326,8 +331,8 @@ struct nsStyleImage
void SetNull();
void SetImageData(imgRequestProxy* aImage);
void TrackImage(nsPresContext* aContext);
void UntrackImage(nsPresContext* aContext);
void TrackImage(mozilla::dom::ImageTracker* aImageTracker);
void UntrackImage(mozilla::dom::ImageTracker* aImageTracker);
void SetGradientData(nsStyleGradient* aGradient);
void SetElementId(const char16_t* aElementId);
void SetCropRect(mozilla::UniquePtr<nsStyleSides> aCropRect);
@ -721,14 +726,14 @@ struct nsStyleImageLayers {
// Register/unregister images with the document. We do this only
// after the dust has settled in ComputeBackgroundData.
void TrackImages(nsPresContext* aContext) {
void TrackImages(mozilla::dom::ImageTracker* aImageTracker) {
if (mImage.GetType() == eStyleImageType_Image) {
mImage.TrackImage(aContext);
mImage.TrackImage(aImageTracker);
}
}
void UntrackImages(nsPresContext* aContext) {
void UntrackImages(mozilla::dom::ImageTracker* aImageTracker) {
if (mImage.GetType() == eStyleImageType_Image) {
mImage.UntrackImage(aContext);
mImage.UntrackImage(aImageTracker);
}
}
@ -778,14 +783,14 @@ struct nsStyleImageLayers {
const Layer& BottomLayer() const { return mLayers[mImageCount - 1]; }
void TrackImages(nsPresContext* aContext) {
void TrackImages(mozilla::dom::ImageTracker* aImageTracker) {
for (uint32_t i = 0; i < mImageCount; ++i) {
mLayers[i].TrackImages(aContext);
mLayers[i].TrackImages(aImageTracker);
}
}
void UntrackImages(nsPresContext* aContext) {
void UntrackImages(mozilla::dom::ImageTracker* aImageTracker) {
for (uint32_t i = 0; i < mImageCount; ++i)
mLayers[i].UntrackImages(aContext);
mLayers[i].UntrackImages(aImageTracker);
}
nsChangeHint CalcDifference(const nsStyleImageLayers& aNewLayers,
@ -1217,16 +1222,16 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder
return mBorderImageSource.IsLoaded();
}
void TrackImage(nsPresContext* aContext)
void TrackImage(mozilla::dom::ImageTracker* aImageTracker)
{
if (mBorderImageSource.GetType() == eStyleImageType_Image) {
mBorderImageSource.TrackImage(aContext);
mBorderImageSource.TrackImage(aImageTracker);
}
}
void UntrackImage(nsPresContext* aContext)
void UntrackImage(mozilla::dom::ImageTracker* aImageTracker)
{
if (mBorderImageSource.GetType() == eStyleImageType_Image) {
mBorderImageSource.UntrackImage(aContext);
mBorderImageSource.UntrackImage(aImageTracker);
}
}
@ -3073,8 +3078,8 @@ struct nsStyleContentData
return !(*this == aOther);
}
void TrackImage(nsPresContext* aContext);
void UntrackImage(nsPresContext* aContext);
void TrackImage(mozilla::dom::ImageTracker* aImageTracker);
void UntrackImage(mozilla::dom::ImageTracker* aImageTracker);
void SetImage(imgRequestProxy* aRequest)
{