This commit is contained in:
sharparrow1%yahoo.com 2007-05-23 01:57:41 +00:00
Родитель d06d1c566f
Коммит 1c0bcf37c2
5 изменённых файлов: 16 добавлений и 49 удалений

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

@ -159,15 +159,8 @@ struct NS_GFX nsRect {
height = NSToCoordRound(height * aScale);
return *this;}
// Scale by aScale, converting coordinates to integers so that the result
// is the smallest integer-coordinate rectangle containing the unrounded result
nsRect& ScaleRoundOut(float aScale);
// Scale by aScale, converting coordinates to integers so that the result
// is the larges integer-coordinate rectangle contained in the unrounded result
nsRect& ScaleRoundIn(float aScale);
// Scale by aScale, converting coordinates to integers so that the result
// contains the same pixel centers as the unrounded result
nsRect& ScaleRoundPreservingCenters(float aScale);
nsRect& ScaleRoundOut(const float aScale);
nsRect& ScaleRoundIn(const float aScale);
// Helpers for accessing the vertices
nsPoint TopLeft() const { return nsPoint(x, y); }

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

@ -181,10 +181,10 @@ void nsRect::Deflate(const nsMargin &aMargin)
}
// scale the rect but round to smallest containing rect
nsRect& nsRect::ScaleRoundOut(float aScale)
nsRect& nsRect::ScaleRoundOut(const float aScale)
{
nscoord right = NSToCoordCeil(float(XMost()) * aScale);
nscoord bottom = NSToCoordCeil(float(YMost()) * aScale);
nscoord right = NSToCoordCeil(float(x + width) * aScale);
nscoord bottom = NSToCoordCeil(float(y + height) * aScale);
x = NSToCoordFloor(float(x) * aScale);
y = NSToCoordFloor(float(y) * aScale);
width = (right - x);
@ -193,10 +193,10 @@ nsRect& nsRect::ScaleRoundOut(float aScale)
}
// scale the rect but round to largest contained rect
nsRect& nsRect::ScaleRoundIn(float aScale)
nsRect& nsRect::ScaleRoundIn(const float aScale)
{
nscoord right = NSToCoordFloor(float(XMost()) * aScale);
nscoord bottom = NSToCoordFloor(float(YMost()) * aScale);
nscoord right = NSToCoordFloor(float(x + width) * aScale);
nscoord bottom = NSToCoordFloor(float(y + height) * aScale);
x = NSToCoordCeil(float(x) * aScale);
y = NSToCoordCeil(float(y) * aScale);
width = (right - x);
@ -204,17 +204,6 @@ nsRect& nsRect::ScaleRoundIn(float aScale)
return *this;
}
nsRect& nsRect::ScaleRoundPreservingCenters(float aScale)
{
nscoord right = NSToCoordRound(float(XMost()) * aScale);
nscoord bottom = NSToCoordRound(float(YMost()) * aScale);
x = NSToCoordRound(float(x) * aScale);
y = NSToCoordRound(float(y) * aScale);
width = (right - x);
height = (bottom - y);
return *this;
}
#ifdef DEBUG
// Diagnostics

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

@ -386,11 +386,11 @@ void nsView::DoResetWidgetBounds(PRBool aMoveOnly,
}
}
nsRect viewBounds(mDimBounds + offset);
nsRect newBounds(viewBounds);
newBounds.ScaleRoundPreservingCenters(1.0f / p2a);
nsRect newBounds(NSAppUnitsToIntPixels((mDimBounds.x + offset.x), p2a),
NSAppUnitsToIntPixels((mDimBounds.y + offset.y), p2a),
NSAppUnitsToIntPixels(mDimBounds.width, p2a),
NSAppUnitsToIntPixels(mDimBounds.height, p2a));
PRBool changedPos = PR_TRUE;
PRBool changedSize = PR_TRUE;
if (!(mVFlags & NS_VIEW_FLAG_HAS_POSITIONED_WIDGET)) {
@ -412,10 +412,6 @@ void nsView::DoResetWidgetBounds(PRBool aMoveOnly,
mWindow->Resize(newBounds.width, newBounds.height, aInvalidateChangedSize);
} // else do nothing!
}
nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.x, p2a),
NSIntPixelsToAppUnits(newBounds.y, p2a));
mViewToWidgetOffset = viewBounds.TopLeft() - roundedOffset;
}
void nsView::SetDimensions(const nsRect& aRect, PRBool aPaint, PRBool aResizeWidget)
@ -862,8 +858,7 @@ nsIWidget* nsIView::GetNearestWidget(nsPoint* aOffset) const
// not coincide with v's origin
if (aOffset) {
nsRect vBounds = v->GetBounds();
*aOffset = pt + v->GetPosition() - nsPoint(vBounds.x, vBounds.y) -
v->ViewToWidgetOffset();
*aOffset = pt + v->GetPosition() - nsPoint(vBounds.x, vBounds.y);
}
return v->GetWidget();
}

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

@ -218,10 +218,6 @@ public:
virtual ~nsView();
nsPoint ViewToWidgetOffset() const {
return mViewToWidgetOffset;
}
protected:
// Do the actual work of ResetWidgetBounds, unconditionally. Don't
// call this method if we have no widget.
@ -232,7 +228,6 @@ protected:
// mClipRect is relative to the view's origin.
nsRect* mClipRect;
nsRegion* mDirtyRegion;
nsPoint mViewToWidgetOffset;
PRPackedBool mChildRemoved;
};

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

@ -483,13 +483,8 @@ void nsViewManager::Refresh(nsView *aView, nsIRenderingContext *aContext,
ctx->Save();
nsPoint vtowoffset = aView->ViewToWidgetOffset();
ctx->Translate(gfxPoint(gfxFloat(vtowoffset.x) / p2a,
gfxFloat(vtowoffset.y) / p2a));
NS_ASSERTION(!viewRect.x && !viewRect.y, "When exactly is this supposed to be non-zero?");
ctx->Translate(gfxPoint(gfxFloat(viewRect.x) / p2a,
gfxFloat(viewRect.y) / p2a));
ctx->Translate(gfxPoint(NSAppUnitsToIntPixels(viewRect.x, p2a),
NSAppUnitsToIntPixels(viewRect.y, p2a)));
nsRegion opaqueRegion;
AddCoveringWidgetsToOpaqueRegion(opaqueRegion, mContext, aView);