bug 512260 - part 5 - make nsCursorImage::mImage private, add getter/setter, and lock images in the setter.r=dbaron,a=blocker

This commit is contained in:
Bobby Holley 2010-08-16 12:19:26 -04:00
Родитель bd679e5549
Коммит bb37093329
5 изменённых файлов: 52 добавлений и 5 удалений

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

@ -6240,10 +6240,10 @@ void nsFrame::FillCursorInformationFromStyle(const nsStyleUserInterface* ui,
*item_end = ui->mCursorArray + ui->mCursorArrayLength;
item < item_end; ++item) {
PRUint32 status;
nsresult rv = item->mImage->GetImageStatus(&status);
nsresult rv = item->GetImage()->GetImageStatus(&status);
if (NS_SUCCEEDED(rv) && (status & imgIRequest::STATUS_LOAD_COMPLETE)) {
// This is the one we want
item->mImage->GetImage(getter_AddRefs(aCursor.mContainer));
item->GetImage()->GetImage(getter_AddRefs(aCursor.mContainer));
aCursor.mHaveHotspot = item->mHaveHotspot;
aCursor.mHotspotX = item->mHotspotX;
aCursor.mHotspotY = item->mHotspotY;

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

@ -2771,7 +2771,7 @@ nsComputedDOMStyle::DoGetCursor(nsIDOMCSSValue** aValue)
}
nsCOMPtr<nsIURI> uri;
item->mImage->GetURI(getter_AddRefs(uri));
item->GetImage()->GetURI(getter_AddRefs(uri));
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
if (!val || !itemList->AppendCSSValue(val)) {

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

@ -3831,7 +3831,7 @@ nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
nsCSSValue::Array *arr = list2->mValue.GetArrayValue();
imgIRequest *req = arr->Item(0).GetImageValue();
if (req) {
item->mImage = req;
item->SetImage(req);
if (arr->Item(1).GetUnit() != eCSSUnit_Null) {
item->mHaveHotspot = PR_TRUE;
item->mHotspotX = arr->Item(1).GetFloatValue(),

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

@ -2605,6 +2605,32 @@ nsCursorImage::nsCursorImage()
{
}
nsCursorImage::nsCursorImage(const nsCursorImage& aOther)
: mHaveHotspot(aOther.mHaveHotspot)
, mHotspotX(aOther.mHotspotX)
, mHotspotY(aOther.mHotspotY)
{
SetImage(aOther.GetImage());
}
nsCursorImage::~nsCursorImage()
{
SetImage(nsnull);
}
nsCursorImage&
nsCursorImage::operator=(const nsCursorImage& aOther)
{
if (this != &aOther) {
mHaveHotspot = aOther.mHaveHotspot;
mHotspotX = aOther.mHotspotX;
mHotspotY = aOther.mHotspotY;
SetImage(aOther.GetImage());
}
return *this;
}
nsStyleUserInterface::nsStyleUserInterface(void)
{
MOZ_COUNT_CTOR(nsStyleUserInterface);

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

@ -1729,11 +1729,32 @@ struct nsStyleUIReset {
};
struct nsCursorImage {
nsCOMPtr<imgIRequest> mImage;
PRBool mHaveHotspot;
float mHotspotX, mHotspotY;
nsCursorImage();
nsCursorImage(const nsCursorImage& aOther);
~nsCursorImage();
nsCursorImage& operator=(const nsCursorImage& aOther);
/*
* We hide mImage and force access through the getter and setter so that we
* can lock the images we use. Cursor images are likely to be small, so we
* don't care about discarding them. See bug 512260.
* */
void SetImage(imgIRequest *aImage) {
if (mImage)
mImage->UnlockImage();
mImage = aImage;
if (mImage)
mImage->LockImage();
}
imgIRequest* GetImage() const {
return mImage;
}
private:
nsCOMPtr<imgIRequest> mImage;
};
struct nsStyleUserInterface {