Bug 1464113 Part 1: Make ImageShapeInfo tolerate shapes that are shifted left or above their margin rects.
MozReview-Commit-ID: 9NuHsjQfLxP
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -1925,19 +1925,16 @@ nsFloatManager::ImageShapeInfo::ImageSha
aAppUnitsPerDevPixel);
// Allocate our distance field. The distance field has to cover
// the entire aMarginRect, since aShapeMargin could bleed into it,
// beyond the content rect covered by aAlphaPixels. To make this work,
// we calculate a dfOffset value which is the top left of the content
// rect relative to the margin rect.
nsPoint offsetPoint = aContentRect.TopLeft() - aMarginRect.TopLeft();
- MOZ_ASSERT(offsetPoint.x >= 0 && offsetPoint.y >= 0,
- "aContentRect should be within aMarginRect, which we need "
- "for our math to make sense.");
LayoutDeviceIntPoint dfOffset =
LayoutDevicePixel::FromAppUnitsRounded(offsetPoint,
aAppUnitsPerDevPixel);
// Since our distance field is computed with a 5x5 neighborhood,
// we need to expand our distance field by a further 4 pixels in
// both axes, 2 on the leading edge and 2 on the trailing edge.
// We call this edge area the "expanded region".
@@ -2009,20 +2006,20 @@ nsFloatManager::ImageShapeInfo::ImageSha
// Handle our three cases, in order.
if (col < kExpansionPerSide ||
col >= wEx - kExpansionPerSide ||
row < kExpansionPerSide ||
row >= hEx - kExpansionPerSide) {
// Case 1: Expanded pixel.
df[index] = MAX_MARGIN_5X;
- } else if (col >= (uint32_t)dfOffset.x &&
- col < (uint32_t)(dfOffset.x + w) &&
- row >= (uint32_t)dfOffset.y &&
- row < (uint32_t)(dfOffset.y + h) &&
+ } else if ((int32_t)col >= dfOffset.x &&
+ (int32_t)col < (dfOffset.x + aImageSize.width) &&
+ (int32_t)row >= dfOffset.y &&
+ (int32_t)row < (dfOffset.y + aImageSize.height) &&
aAlphaPixels[col - dfOffset.x +
(row - dfOffset.y) * aStride] > threshold) {
// Case 2: Image pixel that is opaque.
DebugOnly<uint32_t> alphaIndex = col - dfOffset.x +
(row - dfOffset.y) * aStride;
MOZ_ASSERT(alphaIndex < (aStride * h),
"Our aAlphaPixels index should be in-bounds.");