From 93dfb4b89f59fd131414152c60a6fa1fc0a68bb3 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Thu, 26 Mar 2015 16:44:40 -0500 Subject: [PATCH] Bug 1144951. Rename ConvertAppUnits to ScaleToOtherAppUnits. r=mats --- dom/events/ContentEventHandler.cpp | 2 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 ++-- gfx/src/nsPoint.h | 4 ++-- gfx/src/nsRect.h | 8 ++++---- gfx/src/nsRegion.cpp | 8 ++++---- gfx/src/nsRegion.h | 6 +++--- gfx/src/nsSize.h | 4 ++-- layout/base/nsDisplayList.cpp | 12 ++++++------ layout/base/nsLayoutUtils.cpp | 2 +- layout/base/nsPresShell.cpp | 8 ++++---- layout/generic/nsFrame.cpp | 4 ++-- layout/generic/nsSubDocumentFrame.cpp | 4 ++-- layout/xul/nsMenuPopupFrame.cpp | 4 ++-- view/nsView.cpp | 19 ++++++++++--------- view/nsViewManager.cpp | 4 ++-- 15 files changed, 47 insertions(+), 46 deletions(-) diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index 063c890b98a..80f581265f6 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -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(targetFrame); nsIFrame::ContentOffsets contentOffsets = diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index c7f99883f5e..8f9534c9f97 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -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; } diff --git a/gfx/src/nsPoint.h b/gfx/src/nsPoint.h index 718db99264a..4a621d4ceda 100644 --- a/gfx/src/nsPoint.h +++ b/gfx/src/nsPoint.h @@ -32,7 +32,7 @@ struct nsPoint : public mozilla::gfx::BasePoint { * @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; diff --git a/gfx/src/nsRect.h b/gfx/src/nsRect.h index 08f555c3ee0..8cbe64add92 100644 --- a/gfx/src/nsRect.h +++ b/gfx/src/nsRect.h @@ -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; diff --git a/gfx/src/nsRegion.cpp b/gfx/src/nsRegion.cpp index e5917c7b818..5c664567610 100644 --- a/gfx/src/nsRegion.cpp +++ b/gfx/src/nsRegion.cpp @@ -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(®ion.mImpl, &n); for (int i=0; i { * @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 { @@ -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)); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index ddf07257fc2..a0058b3607f 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -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); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index f08d9c6d795..2056ce90bc6 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -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. diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 06b146fb640..72e19f283d6 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -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; } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 8afbc6e2169..b881a9a4cfb 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -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 diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 31abff98c13..84b15e07298 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -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 diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index f2be7f808e3..d1a8db4990d 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -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 diff --git a/view/nsView.cpp b/view/nsView.cpp index 6f9c3ea7b7f..74bed3e126e 100644 --- a/view/nsView.cpp +++ b/view/nsView.cpp @@ -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; diff --git a/view/nsViewManager.cpp b/view/nsViewManager.cpp index f2231947aa3..fce226fe627 100644 --- a/view/nsViewManager.cpp +++ b/view/nsViewManager.cpp @@ -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.