Bug 870021 - Part 5.2 - Ask content to compute its intrinsic size in nsImageFrame. r=roc

This commit is contained in:
John Schoenick 2014-05-23 16:05:42 -07:00
parent 89ad23c2f0
commit 2b1f9633ee

View File

@ -734,9 +734,29 @@ nsImageFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsPresContext *presContext = PresContext();
EnsureIntrinsicSizeAndRatio(presContext);
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
NS_ASSERTION(imageLoader, "No content node??");
mozilla::IntrinsicSize intrinsicSize(mIntrinsicSize);
if (intrinsicSize.width.GetUnit() == eStyleUnit_Coord) {
uint32_t width;
if (NS_SUCCEEDED(imageLoader->GetNaturalWidth(&width))) {
nscoord appWidth = nsPresContext::CSSPixelsToAppUnits((int32_t)width);
intrinsicSize.width.SetCoordValue(appWidth);
}
}
if (intrinsicSize.height.GetUnit() == eStyleUnit_Coord) {
uint32_t height;
if (NS_SUCCEEDED(imageLoader->GetNaturalHeight(&height))) {
nscoord appHeight = nsPresContext::CSSPixelsToAppUnits((int32_t)height);
intrinsicSize.height.SetCoordValue(appHeight);
}
}
return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
aRenderingContext, this,
mIntrinsicSize, mIntrinsicRatio, aCBSize,
intrinsicSize, mIntrinsicRatio, aCBSize,
aMargin, aBorder, aPadding);
}