Bug 879004 - Cleanups for consistency; no functional changes. r=BenWa, ketuckyfriedtakahe

This commit is contained in:
Kartikaya Gupta 2013-06-10 09:05:43 -04:00
Родитель 95a5f9d752
Коммит 2e046cb0db
4 изменённых файлов: 60 добавлений и 47 удалений

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

@ -191,7 +191,7 @@ public:
//
// This is valid for any layer, but is always relative to this frame and
// not any parents, regardless of parent transforms.
mozilla::CSSPoint mScrollOffset;
CSSPoint mScrollOffset;
// A unique ID assigned to each scrollable frame (unless this is
// ROOT_SCROLL_ID, in which case it is not unique).
@ -208,7 +208,7 @@ public:
// window.scrollTo().
//
// This is valid on any layer unless it has no content.
mozilla::CSSRect mScrollableRect;
CSSRect mScrollableRect;
// ---------------------------------------------------------------------------
// The following metrics are dimensionless.

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

@ -839,7 +839,7 @@ void AsyncPanZoomController::SetPageRect(const CSSRect& aCSSPageRect) {
// The page rect is the css page rect scaled by the current zoom.
// Round the page rect so we don't get any truncation, then get the nsIntRect
// from this.
metrics.mContentRect = LayerRect::FromCSSRectRoundOut(aCSSPageRect, resolution);
metrics.mContentRect = LayerRect::FromCSSRectRoundOut(aCSSPageRect, resolution, resolution);
metrics.mScrollableRect = aCSSPageRect;
mFrameMetrics = metrics;
@ -916,7 +916,7 @@ const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort(
gfxSize resolution = CalculateResolution(aFrameMetrics);
CSSIntRect compositionBounds = LayerIntRect::ToCSSIntRectRoundIn(
aFrameMetrics.mCompositionBounds, resolution);
aFrameMetrics.mCompositionBounds, resolution.width, resolution.height);
CSSRect scrollableRect = aFrameMetrics.mScrollableRect;
// Ensure the scrollableRect is at least as big as the compositionBounds
@ -1007,7 +1007,7 @@ AsyncPanZoomController::CalculateCompositedRectInCssPixels(const FrameMetrics& a
{
gfxSize resolution = CalculateResolution(aMetrics);
CSSIntRect rect = LayerIntRect::ToCSSIntRectRoundIn(
aMetrics.mCompositionBounds, resolution);
aMetrics.mCompositionBounds, resolution.width, resolution.height);
return CSSRect(rect);
}
@ -1364,7 +1364,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
(currentZoom.width == mMaxZoom && targetZoom >= mMaxZoom) ||
(currentZoom.width == localMinZoom && targetZoom <= localMinZoom)) {
CSSIntRect cssCompositionBounds = LayerIntRect::ToCSSIntRectRoundIn(
compositionBounds, resolution);
compositionBounds, resolution.width, resolution.height);
float y = scrollOffset.y;
float newHeight =

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

@ -318,9 +318,9 @@ bool Axis::ScaleWillOverscrollBothSides(float aScale) {
CSSRect cssContentRect = metrics.mScrollableRect;
float currentScale = metrics.mZoom.width;
float scale = metrics.mZoom.width * aScale;
CSSIntRect cssCompositionBounds = LayerIntRect::ToCSSIntRectRoundIn(
metrics.mCompositionBounds, currentScale * aScale);
metrics.mCompositionBounds, scale, scale);
return GetRectLength(cssContentRect) < GetRectLength(CSSRect(cssCompositionBounds));
}

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

@ -11,23 +11,25 @@
namespace mozilla {
// The pixels that content authors use to specify sizes in.
/*
* The pixels that content authors use to specify sizes in.
*/
struct CSSPixel {
static gfx::PointTyped<CSSPixel> FromAppUnits(const nsPoint &pt) {
return gfx::PointTyped<CSSPixel>(NSAppUnitsToFloatPixels(pt.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(pt.y, float(nsDeviceContext::AppUnitsPerCSSPixel())));
static gfx::PointTyped<CSSPixel> FromAppUnits(const nsPoint& aPoint) {
return gfx::PointTyped<CSSPixel>(NSAppUnitsToFloatPixels(aPoint.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(aPoint.y, float(nsDeviceContext::AppUnitsPerCSSPixel())));
}
static nsPoint ToAppUnits(const gfx::PointTyped<CSSPixel> &pt) {
return nsPoint(NSFloatPixelsToAppUnits(pt.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSFloatPixelsToAppUnits(pt.y, float(nsDeviceContext::AppUnitsPerCSSPixel())));
static nsPoint ToAppUnits(const gfx::PointTyped<CSSPixel>& aPoint) {
return nsPoint(NSFloatPixelsToAppUnits(aPoint.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSFloatPixelsToAppUnits(aPoint.y, float(nsDeviceContext::AppUnitsPerCSSPixel())));
}
static gfx::RectTyped<CSSPixel> FromAppUnits(const nsRect &rect) {
return gfx::RectTyped<CSSPixel>(NSAppUnitsToFloatPixels(rect.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(rect.y, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(rect.width, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(rect.height, float(nsDeviceContext::AppUnitsPerCSSPixel())));
static gfx::RectTyped<CSSPixel> FromAppUnits(const nsRect& aRect) {
return gfx::RectTyped<CSSPixel>(NSAppUnitsToFloatPixels(aRect.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(aRect.y, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(aRect.width, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(aRect.height, float(nsDeviceContext::AppUnitsPerCSSPixel())));
}
static nsRect ToAppUnits(const gfx::RectTyped<CSSPixel>& aRect) {
@ -43,45 +45,47 @@ typedef gfx::SizeTyped<CSSPixel> CSSSize;
typedef gfx::RectTyped<CSSPixel> CSSRect;
typedef gfx::IntRectTyped<CSSPixel> CSSIntRect;
/*
* The pixels that layout rasterizes and delivers to the graphics code.
* These are generally referred to as "device pixels" in layout code. Layer
* pixels are affected by:
* 1) the "display resolution" (see nsIPresShell::SetResolution)
* 2) the "full zoom" (see nsPresContext::SetFullZoom)
* 3) the "widget scale" (nsIWidget::GetDefaultScale)
*/
struct LayerPixel {
static gfx::IntPointTyped<LayerPixel> FromCSSPointRounded(const CSSPoint& pt, float resolutionX, float resolutionY) {
return gfx::IntPointTyped<LayerPixel>(NS_lround(pt.x * resolutionX),
NS_lround(pt.y * resolutionY));
static gfx::IntPointTyped<LayerPixel> FromCSSPointRounded(const CSSPoint& aPoint, float aResolutionX, float aResolutionY) {
return gfx::IntPointTyped<LayerPixel>(NS_lround(aPoint.x * aResolutionX),
NS_lround(aPoint.y * aResolutionY));
}
static gfx::IntRectTyped<LayerPixel> RoundToInt(const gfx::RectTyped<LayerPixel>& rect) {
return gfx::IntRectTyped<LayerPixel>(NS_lround(rect.x),
NS_lround(rect.y),
NS_lround(rect.width),
NS_lround(rect.height));
static gfx::IntRectTyped<LayerPixel> RoundToInt(const gfx::RectTyped<LayerPixel>& aRect) {
return gfx::IntRectTyped<LayerPixel>(NS_lround(aRect.x),
NS_lround(aRect.y),
NS_lround(aRect.width),
NS_lround(aRect.height));
}
static gfx::RectTyped<LayerPixel> FromCSSRect(const CSSRect& rect, float resolutionX, float resolutionY) {
return gfx::RectTyped<LayerPixel>(rect.x * resolutionX,
rect.y * resolutionY,
rect.width * resolutionX,
rect.height * resolutionY);
static gfx::RectTyped<LayerPixel> FromCSSRect(const CSSRect& aRect, float aResolutionX, float aResolutionY) {
return gfx::RectTyped<LayerPixel>(aRect.x * aResolutionX,
aRect.y * aResolutionY,
aRect.width * aResolutionX,
aRect.height * aResolutionY);
}
static gfx::IntRectTyped<LayerPixel> FromCSSRectRounded(const CSSRect& rect, float resolutionX, float resolutionY) {
return RoundToInt(FromCSSRect(rect, resolutionX, resolutionY));
static gfx::IntRectTyped<LayerPixel> FromCSSRectRounded(const CSSRect& aRect, float aResolutionX, float aResolutionY) {
return RoundToInt(FromCSSRect(aRect, aResolutionX, aResolutionY));
}
static gfx::IntRectTyped<LayerPixel> FromCSSRectRoundOut(const CSSRect& rect, gfxFloat resolution) {
gfx::RectTyped<LayerPixel> scaled(rect.x, rect.y, rect.width, rect.height);
scaled.ScaleInverseRoundOut(resolution);
static gfx::IntRectTyped<LayerPixel> FromCSSRectRoundOut(const CSSRect& aRect, float aResolutionX, float aResolutionY) {
gfx::RectTyped<LayerPixel> scaled(aRect.x, aRect.y, aRect.width, aRect.height);
scaled.ScaleInverseRoundOut(aResolutionX, aResolutionY);
return gfx::IntRectTyped<LayerPixel>(scaled.x, scaled.y, scaled.width, scaled.height);
}
static CSSIntRect ToCSSIntRectRoundIn(const gfx::IntRectTyped<LayerPixel>& rect, gfxFloat resolution) {
gfx::IntRectTyped<CSSPixel> ret(rect.x, rect.y, rect.width, rect.height);
ret.ScaleInverseRoundIn(resolution, resolution);
return ret;
}
static CSSIntRect ToCSSIntRectRoundIn(const gfx::IntRectTyped<LayerPixel>& rect, gfxSize resolution) {
gfx::IntRectTyped<CSSPixel> ret(rect.x, rect.y, rect.width, rect.height);
ret.ScaleInverseRoundIn(resolution.width, resolution.height);
static CSSIntRect ToCSSIntRectRoundIn(const gfx::IntRectTyped<LayerPixel>& aRect, float aResolutionX, float aResolutionY) {
gfx::IntRectTyped<CSSPixel> ret(aRect.x, aRect.y, aRect.width, aRect.height);
ret.ScaleInverseRoundIn(aResolutionX, aResolutionY);
return ret;
}
};
@ -92,6 +96,15 @@ typedef gfx::IntSizeTyped<LayerPixel> LayerIntSize;
typedef gfx::RectTyped<LayerPixel> LayerRect;
typedef gfx::IntRectTyped<LayerPixel> LayerIntRect;
/*
* The pixels that are displayed on the screen.
* On non-OMTC platforms this should be equivalent to LayerPixel units.
* On OMTC platforms these may diverge from LayerPixel units temporarily,
* while an asynchronous zoom is happening, but should eventually converge
* back to LayerPixel units. Some variables (such as those representing
* chrome UI element sizes) that are not subject to content zoom should
* generally be represented in ScreenPixel units.
*/
struct ScreenPixel {
};