Bug 1098417 part 1: Add optional anchor-point arg to nsLayoutUtils::ComputeObjectDestRect() and nsLayoutUtils::DrawSingleImage(). r=seth

This commit is contained in:
Daniel Holbert 2014-11-21 18:25:46 -08:00
Родитель 859be1ac2b
Коммит c7ce74a52e
3 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

@ -3628,7 +3628,8 @@ ComputeConcreteObjectSize(const nsSize& aConstraintSize,
nsLayoutUtils::ComputeObjectDestRect(const nsRect& aConstraintRect,
const IntrinsicSize& aIntrinsicSize,
const nsSize& aIntrinsicRatio,
const nsStylePosition* aStylePos)
const nsStylePosition* aStylePos,
nsPoint* aAnchorPoint)
{
// Step 1: Figure out our "concrete object size"
// (the size of the region we'll actually draw our image's pixels into).
@ -3648,8 +3649,9 @@ nsLayoutUtils::ComputeObjectDestRect(const nsRect& aConstraintRect,
imageTopLeftPt += aConstraintRect.TopLeft();
imageAnchorPt += aConstraintRect.TopLeft();
// XXXdholbert Per bug 1098417, we should be returning imageAnchorPt here,
// and our caller should make sure it's pixel-aligned.
if (aAnchorPoint) {
*aAnchorPoint = imageAnchorPt;
}
return nsRect(imageTopLeftPt, concreteObjectSize);
}
@ -5689,6 +5691,7 @@ nsLayoutUtils::DrawSingleImage(gfxContext& aContext,
const nsRect& aDirty,
const SVGImageContext* aSVGContext,
uint32_t aImageFlags,
const nsPoint* aAnchorPoint,
const nsRect* aSourceArea)
{
nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
@ -5724,7 +5727,8 @@ nsLayoutUtils::DrawSingleImage(gfxContext& aContext,
nsRect fill;
fill.IntersectRect(aDest, dest);
return DrawImageInternal(aContext, aPresContext, image,
aGraphicsFilter, dest, fill, fill.TopLeft(),
aGraphicsFilter, dest, fill,
aAnchorPoint ? *aAnchorPoint : fill.TopLeft(),
aDirty, aSVGContext, aImageFlags);
}

Просмотреть файл

@ -1149,13 +1149,17 @@ public:
* example, a <video>'s poster-image has a dedicated
* anonymous element & child-frame, but we should still use
* the <video>'s 'object-fit' and 'object-position' values.)
* @param aAnchorPoint [out] A point that should be pixel-aligned by functions
* like nsLayoutUtils::DrawImage. See documentation
* in nsCSSRendering.h for ComputeObjectAnchorPoint.
* @return The nsRect into which we should render the replaced content (using
* the same coordinate space as the passed-in aConstraintRect).
*/
static nsRect ComputeObjectDestRect(const nsRect& aConstraintRect,
const IntrinsicSize& aIntrinsicSize,
const nsSize& aIntrinsicRatio,
const nsStylePosition* aStylePos);
const nsStylePosition* aStylePos,
nsPoint* aAnchorPoint = nullptr);
/**
* Get the font metrics corresponding to the frame's style data.
@ -1677,6 +1681,8 @@ public:
* raster images.
* @param aImageFlags Image flags of the imgIContainer::FLAG_*
* variety.
* @param aAnchor If non-null, a point which we will ensure
* is pixel-aligned in the output.
* @param aSourceArea If non-null, this area is extracted from
* the image and drawn in aDest. It's
* in appunits. For best results it should
@ -1690,6 +1696,7 @@ public:
const nsRect& aDirty,
const mozilla::SVGImageContext* aSVGContext,
uint32_t aImageFlags,
const nsPoint* aAnchorPoint = nullptr,
const nsRect* aSourceArea = nullptr);
/**

Просмотреть файл

@ -343,7 +343,8 @@ nsImageBoxFrame::PaintImage(nsRenderingContext& aRenderingContext,
nsLayoutUtils::DrawSingleImage(*aRenderingContext.ThebesContext(),
PresContext(), imgCon,
nsLayoutUtils::GetGraphicsFilterForFrame(this),
rect, dirty, nullptr, aFlags, hasSubRect ? &mSubRect : nullptr);
rect, dirty, nullptr, aFlags, nullptr,
hasSubRect ? &mSubRect : nullptr);
}
}