mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
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:
parent
d4de8fe94d
commit
2c0304b286
@ -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;
|
||||
}
|
||||
|
@ -7331,7 +7331,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)
|
||||
}
|
||||
@ -7719,7 +7719,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)
|
||||
}
|
||||
@ -8981,7 +8981,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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -10048,7 +10049,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct,
|
||||
}
|
||||
#endif
|
||||
|
||||
svgReset->mMask.TrackImages(aContext->PresContext());
|
||||
svgReset->mMask.TrackImages(aContext->PresContext()->Document()->ImageTracker());
|
||||
|
||||
COMPUTE_END_RESET(SVGReset, svgReset)
|
||||
}
|
||||
|
@ -462,8 +462,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);
|
||||
@ -1167,7 +1169,7 @@ nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource)
|
||||
void
|
||||
nsStyleSVGReset::Destroy(nsPresContext* aContext)
|
||||
{
|
||||
mMask.UntrackImages(aContext);
|
||||
mMask.UntrackImages(aContext->Document()->ImageTracker());
|
||||
|
||||
this->~nsStyleSVGReset();
|
||||
aContext->PresShell()->
|
||||
@ -2009,18 +2011,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
|
||||
@ -2029,18 +2027,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
|
||||
@ -2737,7 +2731,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()->
|
||||
@ -3395,7 +3389,7 @@ nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContentData::TrackImage(nsPresContext* aContext)
|
||||
nsStyleContentData::TrackImage(ImageTracker* aImageTracker)
|
||||
{
|
||||
// Sanity
|
||||
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
|
||||
@ -3404,11 +3398,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
|
||||
@ -3417,7 +3407,7 @@ nsStyleContentData::TrackImage(nsPresContext* aContext)
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContentData::UntrackImage(nsPresContext* aContext)
|
||||
nsStyleContentData::UntrackImage(ImageTracker* aImageTracker)
|
||||
{
|
||||
// Sanity
|
||||
MOZ_ASSERT(mImageTracked, "Image not tracked!");
|
||||
@ -3426,11 +3416,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
|
||||
@ -3459,7 +3445,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
|
||||
|
||||
// Includes nsStyleStructID.
|
||||
#include "nsStyleStructFwd.h"
|
||||
@ -321,8 +326,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);
|
||||
@ -718,14 +723,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -775,14 +780,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,
|
||||
@ -1214,16 +1219,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3072,8 +3077,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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user