Backed out changeset c8fe09ac1842 (bug 825720) on suspicion of making bug 772443 nearly perma-orange.

This commit is contained in:
Ryan VanderMeulen 2013-01-12 21:00:30 -05:00
parent f0eeb8a037
commit c78c56e1d2
5 changed files with 38 additions and 95 deletions

View File

@ -41,7 +41,6 @@ native gfxImageFormat(gfxASurface::gfxImageFormat);
native gfxGraphicsFilter(gfxPattern::GraphicsFilter);
[ref] native nsIntRect(nsIntRect);
[ref] native nsIntSize(nsIntSize);
native nsSize(nsSize);
[ptr] native nsIFrame(nsIFrame);
[ptr] native ImageContainer(mozilla::layers::ImageContainer);
[ptr] native LayerManager(mozilla::layers::LayerManager);
@ -56,7 +55,7 @@ native nsSize(nsSize);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, builtinclass, uuid(a9a6835f-ca7e-4c80-8892-962c959fcd27)]
[scriptable, builtinclass, uuid(01e12ac9-7d9f-40d9-9ec1-70b64c53ce7a)]
interface imgIContainer : nsISupports
{
/**
@ -71,19 +70,6 @@ interface imgIContainer : nsISupports
*/
readonly attribute int32_t height;
/**
* 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
* any error, an exception will be thrown.
*/
[noscript] readonly attribute nsSize intrinsicSize;
/**
* The (dimensionless) intrinsic ratio of this image. In the case of any error,
* an exception will be thrown.
*/
[noscript] readonly attribute nsSize intrinsicRatio;
/**
* Enumerated values for the 'type' attribute (below).
*/

View File

@ -17,7 +17,6 @@
#include "prenv.h"
#include "ImageContainer.h"
#include "Layers.h"
#include "nsPresContext.h"
#include "nsPNGDecoder.h"
#include "nsGIFDecoder2.h"
@ -780,31 +779,6 @@ RasterImage::GetHeight(int32_t *aHeight)
*aHeight = mSize.height;
return NS_OK;
}
//******************************************************************************
/* [noscript] readonly attribute nsSize intrinsicSize; */
NS_IMETHODIMP
RasterImage::GetIntrinsicSize(nsSize* aSize)
{
if (mError)
return NS_ERROR_FAILURE;
*aSize = nsSize(nsPresContext::CSSPixelsToAppUnits(mSize.width),
nsPresContext::CSSPixelsToAppUnits(mSize.height));
return NS_OK;
}
//******************************************************************************
/* [noscript] readonly attribute nsSize intrinsicRatio; */
NS_IMETHODIMP
RasterImage::GetIntrinsicRatio(nsSize* aRatio)
{
if (mError)
return NS_ERROR_FAILURE;
*aRatio = nsSize(mSize.width, mSize.height);
return NS_OK;
}
//******************************************************************************
/* unsigned short GetType(); */

View File

@ -350,38 +350,6 @@ VectorImage::GetHeight(int32_t* aHeight)
return NS_OK;
}
//******************************************************************************
/* [noscript] readonly attribute nsSize intrinsicSize; */
NS_IMETHODIMP
VectorImage::GetIntrinsicSize(nsSize* aSize)
{
nsIFrame* rootFrame = GetRootLayoutFrame();
if (!rootFrame)
return NS_ERROR_FAILURE;
*aSize = nsSize(-1, -1);
nsIFrame::IntrinsicSize rfSize = rootFrame->GetIntrinsicSize();
if (rfSize.width.GetUnit() == eStyleUnit_Coord)
aSize->width = rfSize.width.GetCoordValue();
if (rfSize.height.GetUnit() == eStyleUnit_Coord)
aSize->height = rfSize.height.GetCoordValue();
return NS_OK;
}
//******************************************************************************
/* [noscript] readonly attribute nsSize intrinsicRatio; */
NS_IMETHODIMP
VectorImage::GetIntrinsicRatio(nsSize* aRatio)
{
nsIFrame* rootFrame = GetRootLayoutFrame();
if (!rootFrame)
return NS_ERROR_FAILURE;
*aRatio = rootFrame->GetIntrinsicRatio();
return NS_OK;
}
//******************************************************************************
/* readonly attribute unsigned short type; */
NS_IMETHODIMP

View File

@ -4067,11 +4067,18 @@ nsLayoutUtils::ComputeSizeForDrawing(imgIContainer *aImage,
{
aGotWidth = NS_SUCCEEDED(aImage->GetWidth(&aImageSize.width));
aGotHeight = NS_SUCCEEDED(aImage->GetHeight(&aImageSize.height));
bool gotRatio = NS_SUCCEEDED(aImage->GetIntrinsicRatio(&aIntrinsicRatio));
if (!(aGotWidth && aGotHeight) && !gotRatio) {
// We hit an error (say, because the image failed to load or couldn't be
// decoded) and should return zero size.
if (aGotWidth && aGotHeight) {
aIntrinsicRatio = nsSize(aImageSize.width, aImageSize.height);
return;
}
// If we failed to get width or height, we either have a vector image and
// should return its intrinsic ratio, or we hit an error (say, because the
// image failed to load or couldn't be decoded) and should return zero size.
if (nsIFrame* rootFrame = aImage->GetRootLayoutFrame()) {
aIntrinsicRatio = rootFrame->GetIntrinsicRatio();
} else {
aGotWidth = aGotHeight = true;
aImageSize = nsIntSize(0, 0);
aIntrinsicRatio = nsSize(0, 0);

View File

@ -286,23 +286,22 @@ nsImageFrame::UpdateIntrinsicSize(imgIContainer* aImage)
return false;
nsIFrame::IntrinsicSize oldIntrinsicSize = mIntrinsicSize;
mIntrinsicSize = nsIFrame::IntrinsicSize();
// Set intrinsic size to match aImage's reported intrinsic width & height.
nsSize intrinsicSize;
if (NS_SUCCEEDED(aImage->GetIntrinsicSize(&intrinsicSize))) {
// If the image has no intrinsic width, intrinsicSize.width will be -1, and
// we can leave mIntrinsicSize.width at its default value of eStyleUnit_None.
// Otherwise we use intrinsicSize.width. Height works the same way.
if (intrinsicSize.width != -1)
mIntrinsicSize.width.SetCoordValue(intrinsicSize.width);
if (intrinsicSize.height != -1)
mIntrinsicSize.height.SetCoordValue(intrinsicSize.height);
nsIFrame* rootFrame = aImage->GetRootLayoutFrame();
if (rootFrame) {
// Set intrinsic size to match that of aImage's rootFrame.
mIntrinsicSize = rootFrame->GetIntrinsicSize();
} else {
// Failure means that the image hasn't loaded enough to report a result. We
// treat this case as if the image's intrinsic size was 0x0.
mIntrinsicSize.width.SetCoordValue(0);
mIntrinsicSize.height.SetCoordValue(0);
// Set intrinsic size to match aImage's reported width & height.
nsIntSize imageSizeInPx;
if (NS_FAILED(aImage->GetWidth(&imageSizeInPx.width)) ||
NS_FAILED(aImage->GetHeight(&imageSizeInPx.height))) {
imageSizeInPx.SizeTo(0, 0);
}
mIntrinsicSize.width.SetCoordValue(
nsPresContext::CSSPixelsToAppUnits(imageSizeInPx.width));
mIntrinsicSize.height.SetCoordValue(
nsPresContext::CSSPixelsToAppUnits(imageSizeInPx.height));
}
return mIntrinsicSize != oldIntrinsicSize;
@ -318,9 +317,18 @@ nsImageFrame::UpdateIntrinsicRatio(imgIContainer* aImage)
nsSize oldIntrinsicRatio = mIntrinsicRatio;
// Set intrinsic ratio to match aImage's reported intrinsic ratio.
if (NS_FAILED(aImage->GetIntrinsicRatio(&mIntrinsicRatio)))
mIntrinsicRatio.SizeTo(0, 0);
nsIFrame* rootFrame = aImage->GetRootLayoutFrame();
if (rootFrame) {
// Set intrinsic ratio to match that of aImage's rootFrame.
mIntrinsicRatio = rootFrame->GetIntrinsicRatio();
} else {
NS_ABORT_IF_FALSE(mIntrinsicSize.width.GetUnit() == eStyleUnit_Coord &&
mIntrinsicSize.height.GetUnit() == eStyleUnit_Coord,
"since aImage doesn't have a rootFrame, our intrinsic "
"dimensions must have coord units (not percent units)");
mIntrinsicRatio.width = mIntrinsicSize.width.GetCoordValue();
mIntrinsicRatio.height = mIntrinsicSize.height.GetCoordValue();
}
return mIntrinsicRatio != oldIntrinsicRatio;
}