mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1315155 - Part 2: Make nsStyleContentData use nsStyleImageRequest for images. r=xidorn
MozReview-Commit-ID: 80gQBdNrGq1
This commit is contained in:
parent
e50e656e7d
commit
f27506cc5a
@ -8994,7 +8994,7 @@ nsRuleNode::ComputeContentData(void* aStartStruct,
|
||||
nsStyleContentData& data = content->ContentAt(count++);
|
||||
switch (unit) {
|
||||
case eCSSUnit_Image:
|
||||
data.SetImage(CreateImageRequest(mPresContext, value));
|
||||
data.SetImageRequest(CreateStyleImageRequest(mPresContext, value));
|
||||
break;
|
||||
case eCSSUnit_String:
|
||||
case eCSSUnit_Attr: {
|
||||
@ -9143,15 +9143,6 @@ nsRuleNode::ComputeContentData(void* aStartStruct,
|
||||
MOZ_ASSERT(false, "unexpected value unit");
|
||||
}
|
||||
|
||||
// If we ended up with an image, track it.
|
||||
for (uint32_t i = 0; i < content->ContentCount(); ++i) {
|
||||
if (content->ContentAt(i).GetType() == eStyleContentType_Image &&
|
||||
content->ContentAt(i).GetImage()) {
|
||||
content->ContentAt(i).TrackImage(
|
||||
aContext->PresContext()->Document()->ImageTracker());
|
||||
}
|
||||
}
|
||||
|
||||
COMPUTE_END_RESET(Content, content)
|
||||
}
|
||||
|
||||
|
@ -3508,10 +3508,9 @@ nsStyleVisibility::CalcDifference(const nsStyleVisibility& aNewData) const
|
||||
nsStyleContentData::~nsStyleContentData()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsStyleContentData);
|
||||
MOZ_ASSERT(!mImageTracked,
|
||||
"nsStyleContentData being destroyed while still tracking image!");
|
||||
|
||||
if (mType == eStyleContentType_Image) {
|
||||
NS_IF_RELEASE(mContent.mImage);
|
||||
mContent.mImage->Release();
|
||||
} else if (mType == eStyleContentType_Counter ||
|
||||
mType == eStyleContentType_Counters) {
|
||||
mContent.mCounters->Release();
|
||||
@ -3522,14 +3521,11 @@ nsStyleContentData::~nsStyleContentData()
|
||||
|
||||
nsStyleContentData::nsStyleContentData(const nsStyleContentData& aOther)
|
||||
: mType(aOther.mType)
|
||||
#ifdef DEBUG
|
||||
, mImageTracked(false)
|
||||
#endif
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStyleContentData);
|
||||
if (mType == eStyleContentType_Image) {
|
||||
mContent.mImage = aOther.mContent.mImage;
|
||||
NS_IF_ADDREF(mContent.mImage);
|
||||
mContent.mImage->AddRef();
|
||||
} else if (mType == eStyleContentType_Counter ||
|
||||
mType == eStyleContentType_Counters) {
|
||||
mContent.mCounters = aOther.mContent.mCounters;
|
||||
@ -3560,17 +3556,7 @@ nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
||||
return false;
|
||||
}
|
||||
if (mType == eStyleContentType_Image) {
|
||||
if (!mContent.mImage || !aOther.mContent.mImage) {
|
||||
return mContent.mImage == aOther.mContent.mImage;
|
||||
}
|
||||
bool eq;
|
||||
nsCOMPtr<nsIURI> thisURI, otherURI;
|
||||
mContent.mImage->GetURI(getter_AddRefs(thisURI));
|
||||
aOther.mContent.mImage->GetURI(getter_AddRefs(otherURI));
|
||||
return thisURI == otherURI || // handles null==null
|
||||
(thisURI && otherURI &&
|
||||
NS_SUCCEEDED(thisURI->Equals(otherURI, &eq)) &&
|
||||
eq);
|
||||
return DefinitelyEqualImages(mContent.mImage, aOther.mContent.mImage);
|
||||
}
|
||||
if (mType == eStyleContentType_Counter ||
|
||||
mType == eStyleContentType_Counters) {
|
||||
@ -3579,42 +3565,6 @@ nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
||||
return safe_strcmp(mContent.mString, aOther.mContent.mString) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContentData::TrackImage(ImageTracker* aImageTracker)
|
||||
{
|
||||
// Sanity
|
||||
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
|
||||
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!");
|
||||
|
||||
aImageTracker->Add(mContent.mImage);
|
||||
|
||||
// Mark state
|
||||
#ifdef DEBUG
|
||||
mImageTracked = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContentData::UntrackImage(ImageTracker* aImageTracker)
|
||||
{
|
||||
// Sanity
|
||||
MOZ_ASSERT(mImageTracked, "Image not tracked!");
|
||||
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!");
|
||||
|
||||
aImageTracker->Remove(mContent.mImage);
|
||||
|
||||
// Mark state
|
||||
#ifdef DEBUG
|
||||
mImageTracked = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------
|
||||
// nsStyleContent
|
||||
@ -3633,14 +3583,6 @@ nsStyleContent::~nsStyleContent()
|
||||
void
|
||||
nsStyleContent::Destroy(nsPresContext* aContext)
|
||||
{
|
||||
// Unregister any images we might have with the document.
|
||||
for (auto& content : mContents) {
|
||||
if (content.GetType() == eStyleContentType_Image &&
|
||||
content.GetImage()) {
|
||||
content.UntrackImage(aContext->Document()->ImageTracker());
|
||||
}
|
||||
}
|
||||
|
||||
this->~nsStyleContent();
|
||||
aContext->PresShell()->FreeByObjectID(eArenaObjectID_nsStyleContent, this);
|
||||
}
|
||||
|
@ -3186,9 +3186,6 @@ class nsStyleContentData
|
||||
public:
|
||||
nsStyleContentData()
|
||||
: mType(eStyleContentType_Uninitialized)
|
||||
#ifdef DEBUG
|
||||
, mImageTracked(false)
|
||||
#endif
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsStyleContentData);
|
||||
mContent.mString = nullptr;
|
||||
@ -3203,9 +3200,6 @@ public:
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
void TrackImage(mozilla::dom::ImageTracker* aImageTracker);
|
||||
void UntrackImage(mozilla::dom::ImageTracker* aImageTracker);
|
||||
|
||||
nsStyleContentType GetType() const { return mType; }
|
||||
|
||||
char16_t* GetString() const
|
||||
@ -3222,12 +3216,17 @@ public:
|
||||
return mContent.mCounters;
|
||||
}
|
||||
|
||||
imgRequestProxy* GetImage() const
|
||||
nsStyleImageRequest* GetImageRequest() const
|
||||
{
|
||||
MOZ_ASSERT(mType == eStyleContentType_Image);
|
||||
return mContent.mImage;
|
||||
}
|
||||
|
||||
imgRequestProxy* GetImage() const
|
||||
{
|
||||
return GetImageRequest()->get();
|
||||
}
|
||||
|
||||
void SetKeyword(nsStyleContentType aType)
|
||||
{
|
||||
MOZ_ASSERT(aType == eStyleContentType_OpenQuote ||
|
||||
@ -3263,26 +3262,22 @@ public:
|
||||
mContent.mCounters->AddRef();
|
||||
}
|
||||
|
||||
void SetImage(already_AddRefed<imgRequestProxy> aRequest)
|
||||
void SetImageRequest(already_AddRefed<nsStyleImageRequest> aRequest)
|
||||
{
|
||||
MOZ_ASSERT(mType == eStyleContentType_Uninitialized,
|
||||
"should only initialize nsStyleContentData once");
|
||||
MOZ_ASSERT(!mImageTracked,
|
||||
"Setting a new image without untracking the old one!");
|
||||
mType = eStyleContentType_Image;
|
||||
mContent.mImage = aRequest.take();
|
||||
MOZ_ASSERT(mContent.mImage);
|
||||
}
|
||||
|
||||
private:
|
||||
nsStyleContentType mType;
|
||||
union {
|
||||
char16_t *mString;
|
||||
imgRequestProxy *mImage;
|
||||
nsStyleImageRequest* mImage;
|
||||
nsCSSValue::Array* mCounters;
|
||||
} mContent;
|
||||
#ifdef DEBUG
|
||||
bool mImageTracked;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct nsStyleCounterData
|
||||
|
Loading…
Reference in New Issue
Block a user