Bug 1965114 part 3: Use new imgIContainer intrinsicSize getter in place of width/height in a few places. r=tnikkel
This just demonstrates/tests proper use of the new API. Differential Revision: https://phabricator.services.mozilla.com/D248527
This commit is contained in:
committed by
dholbert@mozilla.com
parent
a1b0d56c0a
commit
fd9ebf44e3
@@ -622,9 +622,18 @@ nsIntSize HTMLImageElement::NaturalSize() {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIntSize size;
|
mozilla::image::ImageIntrinsicSize intrinsicSize;
|
||||||
Unused << image->GetHeight(&size.height);
|
nsresult rv = image->GetIntrinsicSize(&intrinsicSize);
|
||||||
Unused << image->GetWidth(&size.width);
|
if (NS_FAILED(rv)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// For now, treat a missing intrinsic 'width' or 'height' as a natural size
|
||||||
|
// of '0' in that axis, per spec. But we'll be changing that soon for
|
||||||
|
// webcompat reasons per https://github.com/whatwg/html/issues/11287
|
||||||
|
// and https://bugzilla.mozilla.org/show_bug.cgi?id=1935269 .
|
||||||
|
nsIntSize size(intrinsicSize.mWidth.valueOr(0),
|
||||||
|
intrinsicSize.mHeight.valueOr(0));
|
||||||
|
|
||||||
ImageResolution resolution = image->GetResolution();
|
ImageResolution resolution = image->GetResolution();
|
||||||
// NOTE(emilio): What we implement here matches the image-set() spec, but it's
|
// NOTE(emilio): What we implement here matches the image-set() spec, but it's
|
||||||
|
|||||||
@@ -78,11 +78,10 @@ ImageMemoryCounter::ImageMemoryCounter(imgRequest* aRequest, Image* aImage,
|
|||||||
imageURL->GetSpec(mURI);
|
imageURL->GetSpec(mURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t width = 0;
|
ImageIntrinsicSize size;
|
||||||
int32_t height = 0;
|
if (NS_SUCCEEDED(aImage->GetIntrinsicSize(&size))) {
|
||||||
aImage->GetWidth(&width);
|
mIntrinsicSize.SizeTo(size.mWidth.valueOr(0), size.mHeight.valueOr(0));
|
||||||
aImage->GetHeight(&height);
|
} // else, leave mIntrinsicSize default-initialized as IntSize(0,0).
|
||||||
mIntrinsicSize.SizeTo(width, height);
|
|
||||||
|
|
||||||
mType = aImage->GetType();
|
mType = aImage->GetType();
|
||||||
mHasError = aImage->HasError();
|
mHasError = aImage->HasError();
|
||||||
|
|||||||
Reference in New Issue
Block a user