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:
Daniel Holbert
2025-05-09 03:35:11 +00:00
committed by dholbert@mozilla.com
parent a1b0d56c0a
commit fd9ebf44e3
2 changed files with 16 additions and 8 deletions

View File

@@ -622,9 +622,18 @@ nsIntSize HTMLImageElement::NaturalSize() {
return {};
}
nsIntSize size;
Unused << image->GetHeight(&size.height);
Unused << image->GetWidth(&size.width);
mozilla::image::ImageIntrinsicSize intrinsicSize;
nsresult rv = image->GetIntrinsicSize(&intrinsicSize);
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();
// NOTE(emilio): What we implement here matches the image-set() spec, but it's

View File

@@ -78,11 +78,10 @@ ImageMemoryCounter::ImageMemoryCounter(imgRequest* aRequest, Image* aImage,
imageURL->GetSpec(mURI);
}
int32_t width = 0;
int32_t height = 0;
aImage->GetWidth(&width);
aImage->GetHeight(&height);
mIntrinsicSize.SizeTo(width, height);
ImageIntrinsicSize size;
if (NS_SUCCEEDED(aImage->GetIntrinsicSize(&size))) {
mIntrinsicSize.SizeTo(size.mWidth.valueOr(0), size.mHeight.valueOr(0));
} // else, leave mIntrinsicSize default-initialized as IntSize(0,0).
mType = aImage->GetType();
mHasError = aImage->HasError();