mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1083597, part 2 - Add a variant of NSRectToRect that snaps to device pixels, and have nsTableCellFrame::DecorateForSelection use it to restore its snapping behavior.
This commit is contained in:
parent
5cf1157461
commit
9e43325322
@ -8,6 +8,7 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/gfx/PathHelpers.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsPresContext.h"
|
||||
@ -7036,12 +7037,27 @@ AutoMaybeDisableFontInflation::~AutoMaybeDisableFontInflation()
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
Rect NSRectToRect(const nsRect& aRect, int32_t aAppUnitsPerPixel)
|
||||
Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel)
|
||||
{
|
||||
return Rect(Float(aRect.x) / aAppUnitsPerPixel,
|
||||
Float(aRect.y) / aAppUnitsPerPixel,
|
||||
Float(aRect.width) / aAppUnitsPerPixel,
|
||||
Float(aRect.height) / aAppUnitsPerPixel);
|
||||
// Note that by making aAppUnitsPerPixel a double we're doing floating-point
|
||||
// division using a larger type and avoiding rounding error.
|
||||
return Rect(Float(aRect.x / aAppUnitsPerPixel),
|
||||
Float(aRect.y / aAppUnitsPerPixel),
|
||||
Float(aRect.width / aAppUnitsPerPixel),
|
||||
Float(aRect.height / aAppUnitsPerPixel));
|
||||
}
|
||||
|
||||
Rect NSRectToRect(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);
|
||||
return rect;
|
||||
}
|
||||
|
||||
namespace layout {
|
||||
|
@ -2410,7 +2410,20 @@ inline gfx::Point NSPointToPoint(const nsPoint& aPoint,
|
||||
* are device pixels or CSS px depends on what the caller chooses to pass as
|
||||
* aAppUnitsPerPixel).
|
||||
*/
|
||||
gfx::Rect NSRectToRect(const nsRect& aRect, int32_t aAppUnitsPerPixel);
|
||||
gfx::Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel);
|
||||
|
||||
/**
|
||||
* Converts an nsRect in app units to a Moz2D Rect in pixels (whether those
|
||||
* are device pixels or CSS px depends on what the caller chooses to pass as
|
||||
* aAppUnitsPerPixel).
|
||||
*
|
||||
* The passed DrawTarget is used to additionally snap the returned Rect to
|
||||
* device pixels, if appropriate (as decided and carried out by Moz2D's
|
||||
* MaybeSnapToDevicePixels helper, which this function calls to do any
|
||||
* snapping).
|
||||
*/
|
||||
gfx::Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel,
|
||||
const gfx::DrawTarget& aSnapDT);
|
||||
|
||||
namespace layout {
|
||||
|
||||
|
@ -343,7 +343,8 @@ nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext,
|
||||
//middle
|
||||
nsRect r(onePixel, onePixel,
|
||||
mRect.width - onePixel, mRect.height - onePixel);
|
||||
drawTarget->StrokeRect(NSRectToRect(r, appUnitsPerDevPixel), color);
|
||||
Rect devPixelRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
|
||||
drawTarget->StrokeRect(devPixelRect, color);
|
||||
//shading
|
||||
aRenderingContext.DrawLine(2*onePixel, mRect.height-2*onePixel,
|
||||
mRect.width-onePixel, mRect.height- (2*onePixel));
|
||||
|
Loading…
Reference in New Issue
Block a user