Skip to content

Commit

Permalink
bug 1096132 rename UnscaledAppUnitsPerDevPixel() to AppUnitsPerDevPix…
Browse files Browse the repository at this point in the history
…elAtUnitFullZoom() r=tn

--HG--
extra : rebase_source : 220ede5d449a752c16064bb77905bc68af3df707
  • Loading branch information
karlt committed Nov 13, 2014
1 parent fe82002 commit ed15675
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 30 deletions.
3 changes: 2 additions & 1 deletion dom/events/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,8 @@ Event::GetScreenCoords(nsPresContext* aPresContext,

LayoutDeviceIntPoint offset = aPoint +
LayoutDeviceIntPoint::FromUntyped(guiEvent->widget->WidgetToScreenOffset());
nscoord factor = aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
nscoord factor =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
}
Expand Down
2 changes: 1 addition & 1 deletion dom/events/UIEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class UIEvent : public Event,
LayoutDeviceIntPoint offset = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(event->widget->WidgetToScreenOffset());
nscoord factor =
aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
}
Expand Down
2 changes: 1 addition & 1 deletion dom/plugins/base/nsPluginInstanceOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2820,7 +2820,7 @@ nsPluginInstanceOwner::GetContentsScaleFactor(double *result)
nsIPresShell* presShell = nsContentUtils::FindPresShellForDocument(mContent->OwnerDoc());
if (presShell) {
scaleFactor = double(nsPresContext::AppUnitsPerCSSPixel())/
presShell->GetPresContext()->DeviceContext()->UnscaledAppUnitsPerDevPixel();
presShell->GetPresContext()->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
}
#endif
*result = scaleFactor;
Expand Down
16 changes: 8 additions & 8 deletions gfx/src/nsDeviceContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ nsFontCache::Flush()

nsDeviceContext::nsDeviceContext()
: mWidth(0), mHeight(0), mDepth(0),
mAppUnitsPerDevPixel(-1), mAppUnitsPerDevNotScaledPixel(-1),
mAppUnitsPerDevPixel(-1), mAppUnitsPerDevPixelAtUnitFullZoom(-1),
mAppUnitsPerPhysicalInch(-1),
mPixelScale(1.0f), mPrintingScale(1.0f),
mFontCache(nullptr)
Expand Down Expand Up @@ -333,7 +333,7 @@ nsDeviceContext::SetDPI()
break;
}

mAppUnitsPerDevNotScaledPixel =
mAppUnitsPerDevPixelAtUnitFullZoom =
NS_lround((AppUnitsPerCSSPixel() * 96) / dpi);
} else {
// A value of -1 means use the maximum of 96 and the system DPI.
Expand All @@ -358,13 +358,13 @@ nsDeviceContext::SetDPI()
: CSSToLayoutDeviceScale(1.0);
double devPixelsPerCSSPixel = scale.scale;

mAppUnitsPerDevNotScaledPixel =
mAppUnitsPerDevPixelAtUnitFullZoom =
std::max(1, NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel));
}

NS_ASSERTION(dpi != -1.0, "no dpi set");

mAppUnitsPerPhysicalInch = NS_lround(dpi * mAppUnitsPerDevNotScaledPixel);
mAppUnitsPerPhysicalInch = NS_lround(dpi * mAppUnitsPerDevPixelAtUnitFullZoom);
UpdateScaledAppUnits();
}

Expand Down Expand Up @@ -722,12 +722,12 @@ nsDeviceContext::CalcPrintingSize()
}

bool nsDeviceContext::CheckDPIChange() {
int32_t oldDevPixels = mAppUnitsPerDevNotScaledPixel;
int32_t oldDevPixels = mAppUnitsPerDevPixelAtUnitFullZoom;
int32_t oldInches = mAppUnitsPerPhysicalInch;

SetDPI();

return oldDevPixels != mAppUnitsPerDevNotScaledPixel ||
return oldDevPixels != mAppUnitsPerDevPixelAtUnitFullZoom ||
oldInches != mAppUnitsPerPhysicalInch;
}

Expand All @@ -748,7 +748,7 @@ void
nsDeviceContext::UpdateScaledAppUnits()
{
mAppUnitsPerDevPixel =
std::max(1, NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale));
std::max(1, NSToIntRound(float(mAppUnitsPerDevPixelAtUnitFullZoom) / mPixelScale));
// adjust mPixelScale to reflect appunit rounding
mPixelScale = float(mAppUnitsPerDevNotScaledPixel) / mAppUnitsPerDevPixel;
mPixelScale = float(mAppUnitsPerDevPixelAtUnitFullZoom) / mAppUnitsPerDevPixel;
}
10 changes: 5 additions & 5 deletions gfx/src/nsDeviceContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ class nsDeviceContext MOZ_FINAL
static int32_t AppUnitsPerCSSInch() { return mozilla::AppUnitsPerCSSInch(); }

/**
* Get the unscaled ratio of app units to dev pixels; useful if something
* needs to be converted from to unscaled pixels
* Get the ratio of app units to dev pixels that would be used at unit
* (100%) full zoom.
*/
int32_t UnscaledAppUnitsPerDevPixel() const
{ return mAppUnitsPerDevNotScaledPixel; }
int32_t AppUnitsPerDevPixelAtUnitFullZoom() const
{ return mAppUnitsPerDevPixelAtUnitFullZoom; }

/**
* Get the nsFontMetrics that describe the properties of
Expand Down Expand Up @@ -265,7 +265,7 @@ class nsDeviceContext MOZ_FINAL
nscoord mHeight;
uint32_t mDepth;
int32_t mAppUnitsPerDevPixel;
int32_t mAppUnitsPerDevNotScaledPixel;
int32_t mAppUnitsPerDevPixelAtUnitFullZoom;
int32_t mAppUnitsPerPhysicalInch;
float mPixelScale;
float mPrintingScale;
Expand Down
3 changes: 2 additions & 1 deletion layout/base/nsDocumentViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow)

// Initialize our view manager
int32_t p2a = mPresContext->AppUnitsPerDevPixel();
MOZ_ASSERT(p2a == mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel());
MOZ_ASSERT(p2a ==
mPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
nscoord width = p2a * mBounds.width;
nscoord height = p2a * mBounds.height;

Expand Down
9 changes: 5 additions & 4 deletions layout/style/nsRuleNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3389,7 +3389,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
(LookAndFeel::FontID)systemFontValue->GetIntValue();
float devPerCSS =
(float)nsPresContext::AppUnitsPerCSSPixel() /
aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
nsAutoString systemFontName;
if (LookAndFeel::GetFont(fontID, systemFontName, fontStyle, devPerCSS)) {
systemFontName.Trim("\"'");
Expand All @@ -3400,9 +3400,10 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
systemFont.weight = fontStyle.weight;
systemFont.stretch = fontStyle.stretch;
systemFont.decorations = NS_FONT_DECORATION_NONE;
systemFont.size = NSFloatPixelsToAppUnits(fontStyle.size,
aPresContext->DeviceContext()->
UnscaledAppUnitsPerDevPixel());
systemFont.size =
NSFloatPixelsToAppUnits(fontStyle.size,
aPresContext->DeviceContext()->
AppUnitsPerDevPixelAtUnitFullZoom());
//systemFont.langGroup = fontStyle.langGroup;
systemFont.sizeAdjust = fontStyle.sizeAdjust;

Expand Down
8 changes: 4 additions & 4 deletions layout/xul/nsMenuPopupFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,9 +1300,9 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
else {
// the popup is positioned at a screen coordinate.
// first convert the screen position in mScreenXPos and mScreenYPos from
// CSS pixels into device pixels, ignoring any scaling as mScreenXPos and
// mScreenYPos are unscaled screen coordinates.
int32_t factor = devContext->UnscaledAppUnitsPerDevPixel();
// CSS pixels into device pixels, ignoring any zoom as mScreenXPos and
// mScreenYPos are unzoomed screen coordinates.
int32_t factor = devContext->AppUnitsPerDevPixelAtUnitFullZoom();

// context menus should be offset by two pixels so that they don't appear
// directly where the cursor is. Otherwise, it is too easy to have the
Expand All @@ -1313,7 +1313,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
offsetForContextMenu = presContext->DevPixelsToAppUnits(offsetForContextMenuDev);
}

// next, convert into app units accounting for the scaling
// next, convert into app units accounting for the zoom
screenPoint.x = presContext->DevPixelsToAppUnits(
nsPresContext::CSSPixelsToAppUnits(mScreenXPos) / factor);
screenPoint.y = presContext->DevPixelsToAppUnits(
Expand Down
6 changes: 3 additions & 3 deletions view/nsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
// only two scales are 1.0 or 2.0, and so the quantization doesn't actually
// cause problems anyhow).
// In the case of a mismatch, fall back to scaling based on the dev context's
// unscaledAppUnitsPerDevPixel value. On platforms where the device-pixel
// AppUnitsPerDevPixelAtUnitFullZoom value. On platforms where the device-pixel
// scale is uniform across all displays (currently all except OS X), we'll
// always use the precise value from mWindow->GetDefaultScale here.
CSSToLayoutDeviceScale scale = widget->GetDefaultScale();
if (NSToIntRound(60.0 / scale.scale) == dx->UnscaledAppUnitsPerDevPixel()) {
if (NSToIntRound(60.0 / scale.scale) == dx->AppUnitsPerDevPixelAtUnitFullZoom()) {
invScale = 1.0 / scale.scale;
} else {
invScale = dx->UnscaledAppUnitsPerDevPixel() / 60.0;
invScale = dx->AppUnitsPerDevPixelAtUnitFullZoom() / 60.0;
}

if (changedPos) {
Expand Down
2 changes: 1 addition & 1 deletion widget/cocoa/nsNativeThemeCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2289,7 +2289,7 @@ static float VerticalAlignFactor(nsIFrame *aFrame)
IsHiDPIContext(nsPresContext* aContext)
{
return nsPresContext::AppUnitsPerCSSPixel() >=
2 * aContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
2 * aContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
}

NS_IMETHODIMP
Expand Down
2 changes: 1 addition & 1 deletion widget/nsBaseDragService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void
nsBaseDragService::ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
int32_t* aScreenX, int32_t* aScreenY)
{
int32_t adj = aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
int32_t adj = aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
*aScreenX = nsPresContext::CSSPixelsToAppUnits(*aScreenX) / adj;
*aScreenY = nsPresContext::CSSPixelsToAppUnits(*aScreenY) / adj;
}
Expand Down

0 comments on commit ed15675

Please sign in to comment.