Bug 1144951. Rename ConvertAppUnits to ScaleToOtherAppUnits. r=mats

This commit is contained in:
Timothy Nikkel 2015-03-26 16:44:40 -05:00
parent 6c9c9adad9
commit 67581c6b64
15 changed files with 47 additions and 46 deletions

View File

@ -1176,7 +1176,7 @@ ContentEventHandler::OnQueryCharacterAtPoint(WidgetQueryContentEvent* aEvent)
nsPoint ptInTarget = ptInRoot + rootFrame->GetOffsetToCrossDoc(targetFrame);
int32_t rootAPD = rootFrame->PresContext()->AppUnitsPerDevPixel();
int32_t targetAPD = targetFrame->PresContext()->AppUnitsPerDevPixel();
ptInTarget = ptInTarget.ConvertAppUnits(rootAPD, targetAPD);
ptInTarget = ptInTarget.ScaleToOtherAppUnits(rootAPD, targetAPD);
nsTextFrame* textframe = static_cast<nsTextFrame*>(targetFrame);
nsIFrame::ContentOffsets contentOffsets =

View File

@ -1307,7 +1307,7 @@ GetOffsetRootContent(nsIFrame* aFrame)
int32_t newAPD = f ? f->PresContext()->AppUnitsPerDevPixel() : 0;
if (!f || newAPD != currAPD) {
// Convert docOffset to the right APD and add it to offset.
offset += docOffset.ConvertAppUnits(currAPD, apd);
offset += docOffset.ScaleToOtherAppUnits(currAPD, apd);
docOffset.x = docOffset.y = 0;
}
currAPD = newAPD;
@ -1315,7 +1315,7 @@ GetOffsetRootContent(nsIFrame* aFrame)
}
}
offset += docOffset.ConvertAppUnits(currAPD, apd);
offset += docOffset.ScaleToOtherAppUnits(currAPD, apd);
return offset;
}

View File

@ -32,7 +32,7 @@ struct nsPoint : public mozilla::gfx::BasePoint<nscoord, nsPoint> {
* @param aToAPP the APP to scale to
*/
MOZ_WARN_UNUSED_RESULT inline nsPoint
ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
};
// nsIntPoint represents a point in one of the types of pixels.
@ -65,7 +65,7 @@ nsPoint::ToNearestPixels(nscoord aAppUnitsPerPixel) const
}
inline nsPoint
nsPoint::ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const
nsPoint::ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const
{
if (aFromAPP != aToAPP) {
nsPoint point;

View File

@ -144,9 +144,9 @@ struct NS_GFX nsRect :
* @note this can turn an empty rectangle into a non-empty rectangle
*/
MOZ_WARN_UNUSED_RESULT inline nsRect
ConvertAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const;
ScaleToOtherAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const;
MOZ_WARN_UNUSED_RESULT inline nsRect
ConvertAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const;
ScaleToOtherAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const;
inline nsIntRect ScaleToNearestPixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const;
@ -207,7 +207,7 @@ struct NS_GFX nsIntRect :
*/
inline nsRect
nsRect::ConvertAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const
nsRect::ScaleToOtherAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const
{
if (aFromAPP == aToAPP) {
return *this;
@ -225,7 +225,7 @@ nsRect::ConvertAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const
}
inline nsRect
nsRect::ConvertAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const
nsRect::ScaleToOtherAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const
{
if (aFromAPP == aToAPP) {
return *this;

View File

@ -639,7 +639,7 @@ nsRegion& nsRegion::Transform (const gfx3DMatrix &aTransform)
}
nsRegion nsRegion::ConvertAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const
nsRegion nsRegion::ScaleToOtherAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const
{
if (aFromAPP == aToAPP) {
return *this;
@ -650,7 +650,7 @@ nsRegion nsRegion::ConvertAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) co
pixman_box32_t *boxes = pixman_region32_rectangles(&region.mImpl, &n);
for (int i=0; i<n; i++) {
nsRect rect = BoxToRect(boxes[i]);
rect = rect.ConvertAppUnitsRoundOut(aFromAPP, aToAPP);
rect = rect.ScaleToOtherAppUnitsRoundOut(aFromAPP, aToAPP);
boxes[i] = RectToBox(rect);
}
@ -663,7 +663,7 @@ nsRegion nsRegion::ConvertAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) co
return region;
}
nsRegion nsRegion::ConvertAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const
nsRegion nsRegion::ScaleToOtherAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const
{
if (aFromAPP == aToAPP) {
return *this;
@ -674,7 +674,7 @@ nsRegion nsRegion::ConvertAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) con
pixman_box32_t *boxes = pixman_region32_rectangles(&region.mImpl, &n);
for (int i=0; i<n; i++) {
nsRect rect = BoxToRect(boxes[i]);
rect = rect.ConvertAppUnitsRoundIn(aFromAPP, aToAPP);
rect = rect.ScaleToOtherAppUnitsRoundIn(aFromAPP, aToAPP);
boxes[i] = RectToBox(rect);
}

View File

@ -288,15 +288,15 @@ public:
/**
* Return this region scaled to a different appunits per pixel (APP) ratio.
* This applies nsRect::ConvertAppUnitsRoundOut/In to each rect of the region.
* This applies nsRect::ScaleToOtherAppUnitsRoundOut/In to each rect of the region.
* @param aFromAPP the APP to scale from
* @param aToAPP the APP to scale to
* @note this can turn an empty region into a non-empty region
*/
MOZ_WARN_UNUSED_RESULT nsRegion
ConvertAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const;
ScaleToOtherAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const;
MOZ_WARN_UNUSED_RESULT nsRegion
ConvertAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const;
ScaleToOtherAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const;
nsRegion& ScaleRoundOut(float aXScale, float aYScale);
nsRegion& ScaleInverseRoundOut(float aXScale, float aYScale);
nsRegion& Transform (const gfx3DMatrix &aTransform);

View File

@ -32,7 +32,7 @@ struct nsSize : public mozilla::gfx::BaseSize<nscoord, nsSize> {
* @param aToAPP the APP to scale to
*/
MOZ_WARN_UNUSED_RESULT inline nsSize
ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
};
struct nsIntSize : public mozilla::gfx::BaseSize<int32_t, nsIntSize> {
@ -64,7 +64,7 @@ nsSize::ToNearestPixels(nscoord aAppUnitsPerPixel) const
}
inline nsSize
nsSize::ConvertAppUnits(int32_t aFromAPP, int32_t aToAPP) const {
nsSize::ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const {
if (aFromAPP != aToAPP) {
nsSize size;
size.width = NSToCoordRound(NSCoordScale(width, aFromAPP, aToAPP));

View File

@ -4887,7 +4887,7 @@ nsRect nsDisplayZoom::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
{
nsRect bounds = nsDisplaySubDocument::GetBounds(aBuilder, aSnap);
*aSnap = false;
return bounds.ConvertAppUnitsRoundOut(mAPD, mParentAPD);
return bounds.ScaleToOtherAppUnitsRoundOut(mAPD, mParentAPD);
}
void nsDisplayZoom::HitTest(nsDisplayListBuilder *aBuilder,
@ -4899,10 +4899,10 @@ void nsDisplayZoom::HitTest(nsDisplayListBuilder *aBuilder,
// A 1x1 rect indicates we are just hit testing a point, so pass down a 1x1
// rect as well instead of possibly rounding the width or height to zero.
if (aRect.width == 1 && aRect.height == 1) {
rect.MoveTo(aRect.TopLeft().ConvertAppUnits(mParentAPD, mAPD));
rect.MoveTo(aRect.TopLeft().ScaleToOtherAppUnits(mParentAPD, mAPD));
rect.width = rect.height = 1;
} else {
rect = aRect.ConvertAppUnitsRoundOut(mParentAPD, mAPD);
rect = aRect.ScaleToOtherAppUnitsRoundOut(mParentAPD, mAPD);
}
mList.HitTest(aBuilder, rect, aState, aOutFrames);
}
@ -4914,11 +4914,11 @@ bool nsDisplayZoom::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion visibleRegion;
// mVisibleRect has been clipped to GetClippedBounds
visibleRegion.And(*aVisibleRegion, mVisibleRect);
visibleRegion = visibleRegion.ConvertAppUnitsRoundOut(mParentAPD, mAPD);
visibleRegion = visibleRegion.ScaleToOtherAppUnitsRoundOut(mParentAPD, mAPD);
nsRegion originalVisibleRegion = visibleRegion;
nsRect transformedVisibleRect =
mVisibleRect.ConvertAppUnitsRoundOut(mParentAPD, mAPD);
mVisibleRect.ScaleToOtherAppUnitsRoundOut(mParentAPD, mAPD);
bool retval;
// If we are to generate a scrollable layer we call
// nsDisplaySubDocument::ComputeVisibility to make the necessary adjustments
@ -4937,7 +4937,7 @@ bool nsDisplayZoom::ComputeVisibility(nsDisplayListBuilder *aBuilder,
// removed = originalVisibleRegion - visibleRegion
removed.Sub(originalVisibleRegion, visibleRegion);
// Convert removed region to parent appunits.
removed = removed.ConvertAppUnitsRoundIn(mAPD, mParentAPD);
removed = removed.ScaleToOtherAppUnitsRoundIn(mAPD, mParentAPD);
// aVisibleRegion = aVisibleRegion - removed (modulo any simplifications
// SubtractFromVisibleRegion does)
aBuilder->SubtractFromVisibleRegion(aVisibleRegion, removed);

View File

@ -2066,7 +2066,7 @@ nsLayoutUtils::GetEventCoordinatesRelativeTo(nsIWidget* aWidget,
// is in.
int32_t rootAPD = rootFrame->PresContext()->AppUnitsPerDevPixel();
int32_t localAPD = aFrame->PresContext()->AppUnitsPerDevPixel();
widgetToView = widgetToView.ConvertAppUnits(rootAPD, localAPD);
widgetToView = widgetToView.ScaleToOtherAppUnits(rootAPD, localAPD);
/* If we encountered a transform, we can't do simple arithmetic to figure
* out how to convert back to aFrame's coordinates and must use the CTM.

View File

@ -3749,7 +3749,7 @@ PresShell::ScrollFrameRectIntoView(nsIFrame* aFrame,
if (parent) {
int32_t APD = container->PresContext()->AppUnitsPerDevPixel();
int32_t parentAPD = parent->PresContext()->AppUnitsPerDevPixel();
rect = rect.ConvertAppUnitsRoundOut(APD, parentAPD);
rect = rect.ScaleToOtherAppUnitsRoundOut(APD, parentAPD);
rect += extraOffset;
}
}
@ -5735,7 +5735,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
nsIFrame* frame = view->GetFrame();
NS_ASSERTION(frame, "floating views can't be anonymous");
viewAPD = frame->PresContext()->AppUnitsPerDevPixel();
refpoint = mMouseLocation.ConvertAppUnits(APD, viewAPD);
refpoint = mMouseLocation.ScaleToOtherAppUnits(APD, viewAPD);
refpoint -= view->GetOffsetTo(rootView);
refpoint += view->ViewToWidgetOffset();
}
@ -5869,7 +5869,7 @@ PresShell::MarkImagesInSubtreeVisible(nsIFrame* aFrame, const nsRect& aRect)
} else {
rect.MoveBy(-aFrame->GetContentRectRelativeToSelf().TopLeft());
}
rect = rect.ConvertAppUnitsRoundOut(
rect = rect.ScaleToOtherAppUnitsRoundOut(
aFrame->PresContext()->AppUnitsPerDevPixel(),
presShell->GetPresContext()->AppUnitsPerDevPixel());
@ -8639,7 +8639,7 @@ PresShell::GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
nsIFrame* f = do_QueryFrame(scrollFrame);
int32_t APD = presContext->AppUnitsPerDevPixel();
int32_t scrollAPD = f->PresContext()->AppUnitsPerDevPixel();
scrollAmount = scrollAmount.ConvertAppUnits(scrollAPD, APD);
scrollAmount = scrollAmount.ScaleToOtherAppUnits(scrollAPD, APD);
if (extra > scrollAmount.height) {
extra = scrollAmount.height;
}

View File

@ -4750,7 +4750,7 @@ nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther, const int32_t aAPD) const
int32_t newAPD = f ? f->PresContext()->AppUnitsPerDevPixel() : 0;
if (!f || newAPD != currAPD) {
// Convert docOffset to the right APD and add it to offset.
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
offset += docOffset.ScaleToOtherAppUnits(currAPD, aAPD);
docOffset.x = docOffset.y = 0;
}
currAPD = newAPD;
@ -4758,7 +4758,7 @@ nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther, const int32_t aAPD) const
}
}
if (f == aOther) {
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
offset += docOffset.ScaleToOtherAppUnits(currAPD, aAPD);
} else {
// Looks like aOther wasn't an ancestor of |this|. So now we have
// the root-document-relative position of |this| in |offset|. Subtract the

View File

@ -411,7 +411,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// get the dirty rect relative to the root frame of the subdoc
dirty = aDirtyRect + GetOffsetToCrossDoc(subdocRootFrame);
// and convert into the appunits of the subdoc
dirty = dirty.ConvertAppUnitsRoundOut(parentAPD, subdocAPD);
dirty = dirty.ScaleToOtherAppUnitsRoundOut(parentAPD, subdocAPD);
if (nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame()) {
if (gfxPrefs::LayoutUseContainersForRootFrames()) {
@ -500,7 +500,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsRect bounds = GetContentRectRelativeToSelf() +
aBuilder->ToReferenceFrame(this);
if (subdocRootFrame) {
bounds = bounds.ConvertAppUnitsRoundOut(parentAPD, subdocAPD);
bounds = bounds.ScaleToOtherAppUnitsRoundOut(parentAPD, subdocAPD);
}
// If we are in print preview/page layout we want to paint the grey

View File

@ -1247,8 +1247,8 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
parentRect.MoveBy(referenceFrame->GetScreenRectInAppUnits().TopLeft());
// In its own app units
parentRect =
parentRect.ConvertAppUnitsRoundOut(rootPresContext->AppUnitsPerDevPixel(),
presContext->AppUnitsPerDevPixel());
parentRect.ScaleToOtherAppUnitsRoundOut(rootPresContext->AppUnitsPerDevPixel(),
presContext->AppUnitsPerDevPixel());
// Set the popup's size to the preferred size. Below, this size will be
// adjusted to fit on the screen or within the content area. If the anchor

View File

@ -819,7 +819,7 @@ nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const
if (newVM != currVM) {
int32_t newAPD = newVM->AppUnitsPerDevPixel();
if (newAPD != currAPD) {
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
offset += docOffset.ScaleToOtherAppUnits(currAPD, aAPD);
docOffset.x = docOffset.y = 0;
currAPD = newAPD;
}
@ -827,7 +827,7 @@ nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const
}
docOffset += v->GetPosition();
}
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
offset += docOffset.ScaleToOtherAppUnits(currAPD, aAPD);
if (v != aOther) {
// Looks like aOther wasn't an ancestor of |this|. So now we have
@ -863,7 +863,7 @@ nsPoint nsView::GetOffsetToWidget(nsIWidget* aWidget) const
// Convert to our appunits.
int32_t widgetAPD = widgetView->GetViewManager()->AppUnitsPerDevPixel();
int32_t ourAPD = GetViewManager()->AppUnitsPerDevPixel();
pt = pt.ConvertAppUnits(widgetAPD, ourAPD);
pt = pt.ScaleToOtherAppUnits(widgetAPD, ourAPD);
return pt;
}
@ -889,7 +889,7 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const
if (newVM != currVM) {
int32_t newAPD = newVM->AppUnitsPerDevPixel();
if (newAPD != currAPD) {
pt += docPt.ConvertAppUnits(currAPD, aAPD);
pt += docPt.ScaleToOtherAppUnits(currAPD, aAPD);
docPt.x = docPt.y = 0;
currAPD = newAPD;
}
@ -899,7 +899,7 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const
}
if (!v) {
if (aOffset) {
pt += docPt.ConvertAppUnits(currAPD, aAPD);
pt += docPt.ScaleToOtherAppUnits(currAPD, aAPD);
*aOffset = pt;
}
return nullptr;
@ -909,7 +909,7 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const
// We add the ViewToWidgetOffset to get the offset to the widget.
if (aOffset) {
docPt += v->ViewToWidgetOffset();
pt += docPt.ConvertAppUnits(currAPD, aAPD);
pt += docPt.ScaleToOtherAppUnits(currAPD, aAPD);
*aOffset = pt;
}
return v->GetWidget();
@ -931,7 +931,7 @@ nsView::GetBoundsInParentUnits() const
}
int32_t ourAPD = VM->AppUnitsPerDevPixel();
int32_t parentAPD = parent->GetViewManager()->AppUnitsPerDevPixel();
return mDimBounds.ConvertAppUnitsRoundOut(ourAPD, parentAPD);
return mDimBounds.ScaleToOtherAppUnitsRoundOut(ourAPD, parentAPD);
}
nsPoint
@ -939,8 +939,9 @@ nsView::ConvertFromParentCoords(nsPoint aPt) const
{
const nsView* parent = GetParent();
if (parent) {
aPt = aPt.ConvertAppUnits(parent->GetViewManager()->AppUnitsPerDevPixel(),
GetViewManager()->AppUnitsPerDevPixel());
aPt = aPt.ScaleToOtherAppUnits(
parent->GetViewManager()->AppUnitsPerDevPixel(),
GetViewManager()->AppUnitsPerDevPixel());
}
aPt -= GetPosition();
return aPt;

View File

@ -243,7 +243,7 @@ static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn,
{
nsRegion out = aIn;
out.MoveBy(aFromView->GetOffsetTo(aToView));
out = out.ConvertAppUnitsRoundOut(
out = out.ScaleToOtherAppUnitsRoundOut(
aFromView->GetViewManager()->AppUnitsPerDevPixel(),
aToView->GetViewManager()->AppUnitsPerDevPixel());
return out;
@ -640,7 +640,7 @@ nsViewManager::InvalidateViewNoSuppression(nsView *aView,
damagedRect.MoveBy(aView->GetOffsetTo(displayRoot));
int32_t rootAPD = displayRootVM->AppUnitsPerDevPixel();
int32_t APD = AppUnitsPerDevPixel();
damagedRect = damagedRect.ConvertAppUnitsRoundOut(APD, rootAPD);
damagedRect = damagedRect.ScaleToOtherAppUnitsRoundOut(APD, rootAPD);
// accumulate this rectangle in the view's dirty region, so we can
// process it later.