Bug 1101020 - Add the ability to fall back to not snapping, if snapping results in a zero area rect r=roc

This commit is contained in:
James Kitchener
2015-10-17 10:18:00 -07:00
parent 66e8a3d8ac
commit 81ec642f75
20 changed files with 775 additions and 8 deletions

View File

@@ -8094,6 +8094,20 @@ Rect NSRectToSnappedRect(const nsRect& aRect, double aAppUnitsPerPixel,
MaybeSnapToDevicePixels(rect, aSnapDT, true);
return rect;
}
// Similar to a snapped rect, except an axis is left unsnapped if the snapping
// process results in a length of 0.
Rect NSRectToNonEmptySnappedRect(const nsRect& aRect, double aAppUnitsPerPixel,
const gfx::DrawTarget& aSnapDT)
{
// Note that by making aAppUnitsPerPixel a double we're doing floating-point
// division using a larger type and avoiding rounding error.
Rect rect(Float(aRect.x / aAppUnitsPerPixel),
Float(aRect.y / aAppUnitsPerPixel),
Float(aRect.width / aAppUnitsPerPixel),
Float(aRect.height / aAppUnitsPerPixel));
MaybeSnapToDevicePixels(rect, aSnapDT, true, false);
return rect;
}
void StrokeLineWithSnapping(const nsPoint& aP1, const nsPoint& aP2,
int32_t aAppUnitsPerDevPixel,