Bug 1965282: Rename imgIContainer::intrinsicSize to intrinsicSizeInAppUnits. r=tnikkel
This patch doesn't change behavior; it's just a rename. Without this, it's easy to get confused and assume that img.intrinsicSize would just be a shorthand for img.width and img.height -- but it's not. (It has different units from the 'width' and 'height' attributes, and in some cases -- e.g. the VectorImage implementation -- it queries for its answer in a different way from how 'width' and 'height' do. (I'm doing this partly because I'll soon be adding a new attribute that *does* just represent img.width and img.height, and that new attribute will also be named something like "intrinsicSize"; and I want to minimize confusion between that new attribute and this existing one.) Differential Revision: https://phabricator.services.mozilla.com/D248492
This commit is contained in:
committed by
dholbert@mozilla.com
parent
4080333baa
commit
47b8f999ed
@@ -196,11 +196,12 @@ ClippedImage::GetHeight(int32_t* aHeight) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
ClippedImage::GetIntrinsicSize(nsSize* aSize) {
|
ClippedImage::GetIntrinsicSizeInAppUnits(nsSize* aSize) {
|
||||||
if (!ShouldClip()) {
|
if (!ShouldClip()) {
|
||||||
return InnerImage()->GetIntrinsicSize(aSize);
|
return InnerImage()->GetIntrinsicSizeInAppUnits(aSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXXdholbert This probably needs to be scaled; see bug 1965106.
|
||||||
*aSize = nsSize(mClip.Width(), mClip.Height());
|
*aSize = nsSize(mClip.Width(), mClip.Height());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ClippedImage : public ImageWrapper {
|
|||||||
|
|
||||||
NS_IMETHOD GetWidth(int32_t* aWidth) override;
|
NS_IMETHOD GetWidth(int32_t* aWidth) override;
|
||||||
NS_IMETHOD GetHeight(int32_t* aHeight) override;
|
NS_IMETHOD GetHeight(int32_t* aHeight) override;
|
||||||
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) override;
|
NS_IMETHOD GetIntrinsicSizeInAppUnits(nsSize* aSize) override;
|
||||||
AspectRatio GetIntrinsicRatio() override;
|
AspectRatio GetIntrinsicRatio() override;
|
||||||
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
||||||
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
|
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ nsresult DynamicImage::GetNativeSizes(nsTArray<IntSize>&) {
|
|||||||
size_t DynamicImage::GetNativeSizesLength() { return 0; }
|
size_t DynamicImage::GetNativeSizesLength() { return 0; }
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DynamicImage::GetIntrinsicSize(nsSize* aSize) {
|
DynamicImage::GetIntrinsicSizeInAppUnits(nsSize* aSize) {
|
||||||
|
// XXXdholbert This probably needs to be scaled; see bug 1965106.
|
||||||
IntSize intSize(mDrawable->Size());
|
IntSize intSize(mDrawable->Size());
|
||||||
*aSize = nsSize(intSize.width, intSize.height);
|
*aSize = nsSize(intSize.width, intSize.height);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ size_t ImageWrapper::GetNativeSizesLength() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
ImageWrapper::GetIntrinsicSize(nsSize* aSize) {
|
ImageWrapper::GetIntrinsicSizeInAppUnits(nsSize* aSize) {
|
||||||
return mInnerImage->GetIntrinsicSize(aSize);
|
return mInnerImage->GetIntrinsicSizeInAppUnits(aSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
AspectRatio ImageWrapper::GetIntrinsicRatio() {
|
AspectRatio ImageWrapper::GetIntrinsicRatio() {
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ nsresult OrientedImage::GetNativeSizes(nsTArray<IntSize>& aNativeSizes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
OrientedImage::GetIntrinsicSize(nsSize* aSize) {
|
OrientedImage::GetIntrinsicSizeInAppUnits(nsSize* aSize) {
|
||||||
nsresult rv = InnerImage()->GetIntrinsicSize(aSize);
|
nsresult rv = InnerImage()->GetIntrinsicSizeInAppUnits(aSize);
|
||||||
|
|
||||||
if (mOrientation.SwapsWidthAndHeight()) {
|
if (mOrientation.SwapsWidthAndHeight()) {
|
||||||
swap(aSize->width, aSize->height);
|
swap(aSize->width, aSize->height);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class OrientedImage : public ImageWrapper {
|
|||||||
NS_IMETHOD GetWidth(int32_t* aWidth) override;
|
NS_IMETHOD GetWidth(int32_t* aWidth) override;
|
||||||
NS_IMETHOD GetHeight(int32_t* aHeight) override;
|
NS_IMETHOD GetHeight(int32_t* aHeight) override;
|
||||||
nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) override;
|
nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) override;
|
||||||
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) override;
|
NS_IMETHOD GetIntrinsicSizeInAppUnits(nsSize* aSize) override;
|
||||||
AspectRatio GetIntrinsicRatio() override;
|
AspectRatio GetIntrinsicRatio() override;
|
||||||
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
||||||
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
|
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ size_t RasterImage::GetNativeSizesLength() {
|
|||||||
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
RasterImage::GetIntrinsicSize(nsSize* aSize) {
|
RasterImage::GetIntrinsicSizeInAppUnits(nsSize* aSize) {
|
||||||
if (mError) {
|
if (mError) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ VectorImage::GetHeight(int32_t* aHeight) {
|
|||||||
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
VectorImage::GetIntrinsicSize(nsSize* aSize) {
|
VectorImage::GetIntrinsicSizeInAppUnits(nsSize* aSize) {
|
||||||
if (mError || !mIsFullyLoaded) {
|
if (mError || !mIsFullyLoaded) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,8 +102,12 @@ interface imgIContainer : nsISupports
|
|||||||
* The intrinsic size of this image in appunits. If the image has no intrinsic
|
* The intrinsic size of this image in appunits. If the image has no intrinsic
|
||||||
* size in a dimension, -1 will be returned for that dimension. In the case of
|
* size in a dimension, -1 will be returned for that dimension. In the case of
|
||||||
* any error, an exception will be thrown.
|
* any error, an exception will be thrown.
|
||||||
|
*
|
||||||
|
* XXXdholbert maybe this should use the actual IntrinsicSize type (defined
|
||||||
|
* in nsIFrame.h, specifically for replaced elements like images, also
|
||||||
|
* using nscoord units but with Maybe<> to represent sizes being missing)?
|
||||||
*/
|
*/
|
||||||
[noscript] readonly attribute nsSize intrinsicSize;
|
[noscript] readonly attribute nsSize intrinsicSizeInAppUnits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The (dimensionless) intrinsic ratio of this image. Might return a
|
* The (dimensionless) intrinsic ratio of this image. Might return a
|
||||||
|
|||||||
@@ -852,7 +852,7 @@ IntrinsicSize nsImageFrame::ComputeIntrinsicSize(
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsSize size;
|
nsSize size;
|
||||||
if (mImage && NS_SUCCEEDED(mImage->GetIntrinsicSize(&size))) {
|
if (mImage && NS_SUCCEEDED(mImage->GetIntrinsicSizeInAppUnits(&size))) {
|
||||||
IntrinsicSize intrinsicSize;
|
IntrinsicSize intrinsicSize;
|
||||||
intrinsicSize.width = size.width == -1 ? Nothing() : Some(size.width);
|
intrinsicSize.width = size.width == -1 ? Nothing() : Some(size.width);
|
||||||
intrinsicSize.height = size.height == -1 ? Nothing() : Some(size.height);
|
intrinsicSize.height = size.height == -1 ? Nothing() : Some(size.height);
|
||||||
@@ -1035,7 +1035,8 @@ bool nsImageFrame::GetSourceToDestTransform(nsTransform2D& aTransform) {
|
|||||||
// size (mIntrinsicSize), which can be scaled due to ResponsiveImageSelector,
|
// size (mIntrinsicSize), which can be scaled due to ResponsiveImageSelector,
|
||||||
// see ScaleIntrinsicSizeForDensity.
|
// see ScaleIntrinsicSizeForDensity.
|
||||||
nsSize intrinsicSize;
|
nsSize intrinsicSize;
|
||||||
if (!mImage || !NS_SUCCEEDED(mImage->GetIntrinsicSize(&intrinsicSize)) ||
|
if (!mImage ||
|
||||||
|
!NS_SUCCEEDED(mImage->GetIntrinsicSizeInAppUnits(&intrinsicSize)) ||
|
||||||
intrinsicSize.IsEmpty()) {
|
intrinsicSize.IsEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user