Skip to content

Commit

Permalink
Bug 1144951. Rename ConvertAppUnits to ScaleToOtherAppUnits. r=mats
Browse files Browse the repository at this point in the history
  • Loading branch information
tnikkel committed Mar 26, 2015
1 parent c0256d8 commit 09f076e
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion dom/events/ContentEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions dom/plugins/base/nsPluginInstanceOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,15 +1307,15 @@ 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;
docOffset += newOffset;
}
}

offset += docOffset.ConvertAppUnits(currAPD, apd);
offset += docOffset.ScaleToOtherAppUnits(currAPD, apd);

return offset;
}
Expand Down
4 changes: 2 additions & 2 deletions gfx/src/nsPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions gfx/src/nsRect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions gfx/src/nsRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand All @@ -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;
Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions gfx/src/nsRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,15 @@ class nsRegion

/**
* 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);
Expand Down
4 changes: 2 additions & 2 deletions gfx/src/nsSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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));
Expand Down
12 changes: 6 additions & 6 deletions layout/base/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand All @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion layout/base/nsLayoutUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions layout/base/nsPresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4750,15 +4750,15 @@ 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;
docOffset += newOffset;
}
}
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
Expand Down
4 changes: 2 additions & 2 deletions layout/generic/nsSubDocumentFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions layout/xul/nsMenuPopupFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions view/nsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,15 +819,15 @@ 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;
}
currVM = newVM;
}
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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -931,16 +931,17 @@ 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
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;
Expand Down
4 changes: 2 additions & 2 deletions view/nsViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 09f076e

Please sign in to comment.