зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1352096 - Part 1. Implement nsStyleImage::SetURL and GetURLValueData. r=heycam
This patch implements two things: 1. Add one extra type, nsStyleImageType::eStyleImageType_Url, and puts data of this type in nsStyleImage::mUrlData. 2. Export SetURLValueData and GetURLValueData from nsStyleImage With these chnages, we can simply use nsStyleImage::mUrlData to replace Layer::mSourceURI in the next patch. MozReview-Commit-ID: E20MEzXv8cg --HG-- extra : rebase_source : 5461edacb28676e9d3a12068f330b5db7b9fe32c
This commit is contained in:
Родитель
dba46f6082
Коммит
0a71f961c5
|
@ -1411,7 +1411,7 @@ static void SetStyleImage(nsStyleContext* aStyleContext,
|
||||||
isLocalRef,
|
isLocalRef,
|
||||||
"unexpected unit; maybe nsCSSValue::Image::Image() failed?");
|
"unexpected unit; maybe nsCSSValue::Image::Image() failed?");
|
||||||
#endif
|
#endif
|
||||||
|
aResult.SetURLValue(do_AddRef(aValue.GetURLStructValue()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2194,6 +2194,8 @@ nsStyleImage::DoCopy(const nsStyleImage& aOther)
|
||||||
SetGradientData(aOther.mGradient);
|
SetGradientData(aOther.mGradient);
|
||||||
} else if (aOther.mType == eStyleImageType_Element) {
|
} else if (aOther.mType == eStyleImageType_Element) {
|
||||||
SetElementId(aOther.mElementId);
|
SetElementId(aOther.mElementId);
|
||||||
|
} else if (aOther.mType == eStyleImageType_URL) {
|
||||||
|
SetURLValue(do_AddRef(aOther.mURLValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniquePtr<nsStyleSides> cropRectCopy;
|
UniquePtr<nsStyleSides> cropRectCopy;
|
||||||
|
@ -2212,6 +2214,8 @@ nsStyleImage::SetNull()
|
||||||
NS_RELEASE(mImage);
|
NS_RELEASE(mImage);
|
||||||
} else if (mType == eStyleImageType_Element) {
|
} else if (mType == eStyleImageType_Element) {
|
||||||
free(mElementId);
|
free(mElementId);
|
||||||
|
} else if (mType == eStyleImageType_URL) {
|
||||||
|
NS_RELEASE(mURLValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
mType = eStyleImageType_Null;
|
mType = eStyleImageType_Null;
|
||||||
|
@ -2272,6 +2276,21 @@ nsStyleImage::SetCropRect(UniquePtr<nsStyleSides> aCropRect)
|
||||||
mCropRect = Move(aCropRect);
|
mCropRect = Move(aCropRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsStyleImage::SetURLValue(already_AddRefed<URLValue> aValue)
|
||||||
|
{
|
||||||
|
RefPtr<URLValue> value = aValue;
|
||||||
|
|
||||||
|
if (mType != eStyleImageType_Null) {
|
||||||
|
SetNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
mURLValue = value.forget().take();
|
||||||
|
mType = eStyleImageType_URL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t
|
static int32_t
|
||||||
ConvertToPixelCoord(const nsStyleCoord& aCoord, int32_t aPercentScale)
|
ConvertToPixelCoord(const nsStyleCoord& aCoord, int32_t aPercentScale)
|
||||||
{
|
{
|
||||||
|
@ -2417,6 +2436,7 @@ nsStyleImage::IsComplete() const
|
||||||
return false;
|
return false;
|
||||||
case eStyleImageType_Gradient:
|
case eStyleImageType_Gradient:
|
||||||
case eStyleImageType_Element:
|
case eStyleImageType_Element:
|
||||||
|
case eStyleImageType_URL:
|
||||||
return true;
|
return true;
|
||||||
case eStyleImageType_Image: {
|
case eStyleImageType_Image: {
|
||||||
imgRequestProxy* req = GetImageData();
|
imgRequestProxy* req = GetImageData();
|
||||||
|
@ -2442,6 +2462,7 @@ nsStyleImage::IsLoaded() const
|
||||||
return false;
|
return false;
|
||||||
case eStyleImageType_Gradient:
|
case eStyleImageType_Gradient:
|
||||||
case eStyleImageType_Element:
|
case eStyleImageType_Element:
|
||||||
|
case eStyleImageType_URL:
|
||||||
return true;
|
return true;
|
||||||
case eStyleImageType_Image: {
|
case eStyleImageType_Image: {
|
||||||
imgRequestProxy* req = GetImageData();
|
imgRequestProxy* req = GetImageData();
|
||||||
|
@ -2489,6 +2510,10 @@ nsStyleImage::operator==(const nsStyleImage& aOther) const
|
||||||
return NS_strcmp(mElementId, aOther.mElementId) == 0;
|
return NS_strcmp(mElementId, aOther.mElementId) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mType == eStyleImageType_URL) {
|
||||||
|
return DefinitelyEqualURIs(mURLValue, aOther.mURLValue);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2523,6 +2548,18 @@ nsStyleImage::GetImageURI() const
|
||||||
return uri.forget();
|
return uri.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
css::URLValueData*
|
||||||
|
nsStyleImage::GetURLValue() const
|
||||||
|
{
|
||||||
|
if (mType == eStyleImageType_Image) {
|
||||||
|
return mImage->GetImageValue();
|
||||||
|
} else if (mType == eStyleImageType_URL) {
|
||||||
|
return mURLValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
// nsStyleImageLayers
|
// nsStyleImageLayers
|
||||||
//
|
//
|
||||||
|
|
|
@ -305,6 +305,8 @@ private:
|
||||||
class nsStyleImageRequest
|
class nsStyleImageRequest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef mozilla::css::URLValueData URLValueData;
|
||||||
|
|
||||||
// Flags describing whether the imgRequestProxy must be tracked in the
|
// Flags describing whether the imgRequestProxy must be tracked in the
|
||||||
// ImageTracker, whether LockImage/UnlockImage calls will be made
|
// ImageTracker, whether LockImage/UnlockImage calls will be made
|
||||||
// when obtaining and releasing the imgRequestProxy, and whether
|
// when obtaining and releasing the imgRequestProxy, and whether
|
||||||
|
@ -360,7 +362,6 @@ public:
|
||||||
mozilla::css::ImageValue* GetImageValue() const { return mImageValue; }
|
mozilla::css::ImageValue* GetImageValue() const { return mImageValue; }
|
||||||
|
|
||||||
already_AddRefed<nsIURI> GetImageURI() const;
|
already_AddRefed<nsIURI> GetImageURI() const;
|
||||||
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsStyleImageRequest);
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsStyleImageRequest);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -386,7 +387,8 @@ enum nsStyleImageType {
|
||||||
eStyleImageType_Null,
|
eStyleImageType_Null,
|
||||||
eStyleImageType_Image,
|
eStyleImageType_Image,
|
||||||
eStyleImageType_Gradient,
|
eStyleImageType_Gradient,
|
||||||
eStyleImageType_Element
|
eStyleImageType_Element,
|
||||||
|
eStyleImageType_URL
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CachedBorderImageData
|
struct CachedBorderImageData
|
||||||
|
@ -419,6 +421,9 @@ private:
|
||||||
*/
|
*/
|
||||||
struct nsStyleImage
|
struct nsStyleImage
|
||||||
{
|
{
|
||||||
|
typedef mozilla::css::URLValue URLValue;
|
||||||
|
typedef mozilla::css::URLValueData URLValueData;
|
||||||
|
|
||||||
nsStyleImage();
|
nsStyleImage();
|
||||||
~nsStyleImage();
|
~nsStyleImage();
|
||||||
nsStyleImage(const nsStyleImage& aOther);
|
nsStyleImage(const nsStyleImage& aOther);
|
||||||
|
@ -429,6 +434,7 @@ struct nsStyleImage
|
||||||
void SetGradientData(nsStyleGradient* aGradient);
|
void SetGradientData(nsStyleGradient* aGradient);
|
||||||
void SetElementId(const char16_t* aElementId);
|
void SetElementId(const char16_t* aElementId);
|
||||||
void SetCropRect(mozilla::UniquePtr<nsStyleSides> aCropRect);
|
void SetCropRect(mozilla::UniquePtr<nsStyleSides> aCropRect);
|
||||||
|
void SetURLValue(already_AddRefed<URLValue> aData);
|
||||||
|
|
||||||
void ResolveImage(nsPresContext* aContext) {
|
void ResolveImage(nsPresContext* aContext) {
|
||||||
MOZ_ASSERT(mType != eStyleImageType_Image || mImage);
|
MOZ_ASSERT(mType != eStyleImageType_Image || mImage);
|
||||||
|
@ -464,6 +470,8 @@ struct nsStyleImage
|
||||||
|
|
||||||
already_AddRefed<nsIURI> GetImageURI() const;
|
already_AddRefed<nsIURI> GetImageURI() const;
|
||||||
|
|
||||||
|
URLValueData* GetURLValue() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the actual crop rect in pixels, using the source image bounds.
|
* Compute the actual crop rect in pixels, using the source image bounds.
|
||||||
* The computation involves converting percentage unit to pixel unit and
|
* The computation involves converting percentage unit to pixel unit and
|
||||||
|
@ -547,6 +555,9 @@ private:
|
||||||
union {
|
union {
|
||||||
nsStyleImageRequest* mImage;
|
nsStyleImageRequest* mImage;
|
||||||
nsStyleGradient* mGradient;
|
nsStyleGradient* mGradient;
|
||||||
|
URLValue* mURLValue; // See the comment in SetStyleImage's 'case
|
||||||
|
// eCSSUnit_URL' section to know why we need to
|
||||||
|
// store URLValues separately from mImage.
|
||||||
char16_t* mElementId;
|
char16_t* mElementId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче