mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 870021 - Part 5.3 - nsImageFrame should take orientation into account when getting natural size from content. r=roc
This commit is contained in:
parent
2b1f9633ee
commit
4b5e0520b0
@ -738,19 +738,28 @@ nsImageFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
||||
NS_ASSERTION(imageLoader, "No content node??");
|
||||
mozilla::IntrinsicSize intrinsicSize(mIntrinsicSize);
|
||||
|
||||
if (intrinsicSize.width.GetUnit() == eStyleUnit_Coord) {
|
||||
// Content may override our default dimensions. This is termed as overriding
|
||||
// the intrinsic size by the spec, but all other consumers of mIntrinsic*
|
||||
// values are being used to refer to the real/true size of the image data.
|
||||
if (imageLoader && mImage &&
|
||||
intrinsicSize.width.GetUnit() == eStyleUnit_Coord &&
|
||||
intrinsicSize.height.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))) {
|
||||
if (NS_SUCCEEDED(imageLoader->GetNaturalWidth(&width)) &&
|
||||
NS_SUCCEEDED(imageLoader->GetNaturalHeight(&height))) {
|
||||
nscoord appWidth = nsPresContext::CSSPixelsToAppUnits((int32_t)width);
|
||||
nscoord appHeight = nsPresContext::CSSPixelsToAppUnits((int32_t)height);
|
||||
intrinsicSize.height.SetCoordValue(appHeight);
|
||||
// If this image is rotated, we'll need to transpose the natural
|
||||
// width/height.
|
||||
bool coordFlip;
|
||||
if (StyleVisibility()->mImageOrientation.IsFromImage()) {
|
||||
coordFlip = mImage->GetOrientation().SwapsWidthAndHeight();
|
||||
} else {
|
||||
coordFlip = StyleVisibility()->mImageOrientation.SwapsWidthAndHeight();
|
||||
}
|
||||
intrinsicSize.width.SetCoordValue(coordFlip ? appHeight : appWidth);
|
||||
intrinsicSize.height.SetCoordValue(coordFlip ? appWidth : appHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1606,6 +1606,10 @@ struct nsStyleImageOrientation {
|
||||
bool IsDefault() const { return mOrientation == 0; }
|
||||
bool IsFlipped() const { return mOrientation & FLIP_MASK; }
|
||||
bool IsFromImage() const { return mOrientation & FROM_IMAGE_MASK; }
|
||||
bool SwapsWidthAndHeight() const {
|
||||
uint8_t angle = mOrientation & ORIENTATION_MASK;
|
||||
return (angle == ANGLE_90) || (angle == ANGLE_270);
|
||||
}
|
||||
|
||||
mozilla::image::Angle Angle() const {
|
||||
switch (mOrientation & ORIENTATION_MASK) {
|
||||
|
Loading…
Reference in New Issue
Block a user