backout bug 1096132 for Mac build failure

--HG--
extra : rebase_source : 6994fe50e8fb1a4f89298e1b9ad1c714acdfe39e
This commit is contained in:
Karl Tomlinson 2014-11-12 16:02:34 +13:00
parent 964b06d63d
commit a3ba9b4cb5
11 changed files with 46 additions and 49 deletions

View File

@ -2068,7 +2068,7 @@ nsDOMWindowUtils::GetFullZoom(float* aFullZoom)
return NS_OK;
}
*aFullZoom = presContext->DeviceContext()->GetFullZoom();
*aFullZoom = presContext->DeviceContext()->GetPixelScale();
return NS_OK;
}

View File

@ -886,8 +886,7 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
LayoutDeviceIntPoint offset = aPoint +
LayoutDeviceIntPoint::FromUntyped(guiEvent->widget->WidgetToScreenOffset());
nscoord factor =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
nscoord factor = aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
}

View File

@ -60,7 +60,7 @@ public:
LayoutDeviceIntPoint offset = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(event->widget->WidgetToScreenOffset());
nscoord factor =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
}

View File

@ -244,9 +244,9 @@ nsFontCache::Flush()
nsDeviceContext::nsDeviceContext()
: mWidth(0), mHeight(0), mDepth(0),
mAppUnitsPerDevPixel(-1), mAppUnitsPerDevPixelAtUnitFullZoom(-1),
mAppUnitsPerDevPixel(-1), mAppUnitsPerDevNotScaledPixel(-1),
mAppUnitsPerPhysicalInch(-1),
mFullZoom(1.0f), mPrintingScale(1.0f),
mPixelScale(1.0f), mPrintingScale(1.0f),
mFontCache(nullptr)
{
MOZ_ASSERT(NS_IsMainThread(), "nsDeviceContext created off main thread");
@ -333,7 +333,7 @@ nsDeviceContext::SetDPI()
break;
}
mAppUnitsPerDevPixelAtUnitFullZoom =
mAppUnitsPerDevNotScaledPixel =
NS_lround((AppUnitsPerCSSPixel() * 96) / dpi);
} else {
// A value of -1 means use the maximum of 96 and the system DPI.
@ -358,14 +358,14 @@ nsDeviceContext::SetDPI()
: CSSToLayoutDeviceScale(1.0);
double devPixelsPerCSSPixel = scale.scale;
mAppUnitsPerDevPixelAtUnitFullZoom =
mAppUnitsPerDevNotScaledPixel =
std::max(1, NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel));
}
NS_ASSERTION(dpi != -1.0, "no dpi set");
mAppUnitsPerPhysicalInch = NS_lround(dpi * mAppUnitsPerDevPixelAtUnitFullZoom);
UpdateAppUnitsForFullZoom();
mAppUnitsPerPhysicalInch = NS_lround(dpi * mAppUnitsPerDevNotScaledPixel);
UpdateScaledAppUnits();
}
nsresult
@ -722,33 +722,33 @@ nsDeviceContext::CalcPrintingSize()
}
bool nsDeviceContext::CheckDPIChange() {
int32_t oldDevPixels = mAppUnitsPerDevPixelAtUnitFullZoom;
int32_t oldDevPixels = mAppUnitsPerDevNotScaledPixel;
int32_t oldInches = mAppUnitsPerPhysicalInch;
SetDPI();
return oldDevPixels != mAppUnitsPerDevPixelAtUnitFullZoom ||
return oldDevPixels != mAppUnitsPerDevNotScaledPixel ||
oldInches != mAppUnitsPerPhysicalInch;
}
bool
nsDeviceContext::SetFullZoom(float aScale)
nsDeviceContext::SetPixelScale(float aScale)
{
if (aScale <= 0) {
NS_NOTREACHED("Invalid full zoom value");
NS_NOTREACHED("Invalid pixel scale value");
return false;
}
int32_t oldAppUnitsPerDevPixel = mAppUnitsPerDevPixel;
mFullZoom = aScale;
UpdateAppUnitsForFullZoom();
mPixelScale = aScale;
UpdateScaledAppUnits();
return oldAppUnitsPerDevPixel != mAppUnitsPerDevPixel;
}
void
nsDeviceContext::UpdateAppUnitsForFullZoom()
nsDeviceContext::UpdateScaledAppUnits()
{
mAppUnitsPerDevPixel =
std::max(1, NSToIntRound(float(mAppUnitsPerDevPixelAtUnitFullZoom) / mFullZoom));
// adjust mFullZoom to reflect appunit rounding
mFullZoom = float(mAppUnitsPerDevPixelAtUnitFullZoom) / mAppUnitsPerDevPixel;
std::max(1, NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale));
// adjust mPixelScale to reflect appunit rounding
mPixelScale = float(mAppUnitsPerDevNotScaledPixel) / mAppUnitsPerDevPixel;
}

View File

@ -103,11 +103,11 @@ public:
static int32_t AppUnitsPerCSSInch() { return mozilla::AppUnitsPerCSSInch(); }
/**
* Get the ratio of app units to dev pixels that would be used at unit
* (100%) full zoom.
* Get the unscaled ratio of app units to dev pixels; useful if something
* needs to be converted from to unscaled pixels
*/
int32_t AppUnitsPerDevPixelAtUnitFullZoom() const
{ return mAppUnitsPerDevPixelAtUnitFullZoom; }
int32_t UnscaledAppUnitsPerDevPixel() const
{ return mAppUnitsPerDevNotScaledPixel; }
/**
* Get the nsFontMetrics that describe the properties of
@ -234,16 +234,16 @@ public:
bool CheckDPIChange();
/**
* Set the full zoom factor: all lengths are multiplied by this factor
* Set the pixel scaling factor: all lengths are multiplied by this factor
* when we convert them to device pixels. Returns whether the ratio of
* app units to dev pixels changed because of the zoom factor.
* app units to dev pixels changed because of the scale factor.
*/
bool SetFullZoom(float aScale);
bool SetPixelScale(float aScale);
/**
* Returns the page full zoom factor applied.
* Returns the pixel scaling factor (page zoom factor) applied.
*/
float GetFullZoom() const { return mFullZoom; }
float GetPixelScale() const { return mPixelScale; }
/**
* True if this device context was created for printing.
@ -259,15 +259,15 @@ private:
void ComputeFullAreaUsingScreen(nsRect *outRect);
void FindScreen(nsIScreen **outScreen);
void CalcPrintingSize();
void UpdateAppUnitsForFullZoom();
void UpdateScaledAppUnits();
nscoord mWidth;
nscoord mHeight;
uint32_t mDepth;
int32_t mAppUnitsPerDevPixel;
int32_t mAppUnitsPerDevPixelAtUnitFullZoom;
int32_t mAppUnitsPerDevNotScaledPixel;
int32_t mAppUnitsPerPhysicalInch;
float mFullZoom;
float mPixelScale;
float mPrintingScale;
nsFontCache* mFontCache;

View File

@ -665,8 +665,7 @@ nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow)
// Initialize our view manager
int32_t p2a = mPresContext->AppUnitsPerDevPixel();
MOZ_ASSERT(p2a ==
mPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
MOZ_ASSERT(p2a == mPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel());
nscoord width = p2a * mBounds.width;
nscoord height = p2a * mBounds.height;

View File

@ -957,7 +957,7 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
mDeviceContext = aDeviceContext;
if (mDeviceContext->SetFullZoom(mFullZoom))
if (mDeviceContext->SetPixelScale(mFullZoom))
mDeviceContext->FlushFontCache();
mCurAppUnitsPerDevPixel = AppUnitsPerDevPixel();
@ -1475,7 +1475,7 @@ nsPresContext::SetFullZoom(float aZoom)
mShell->GetViewManager()->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits);
float oldWidthDevPixels = oldWidthAppUnits / float(mCurAppUnitsPerDevPixel);
float oldHeightDevPixels = oldHeightAppUnits / float(mCurAppUnitsPerDevPixel);
mDeviceContext->SetFullZoom(aZoom);
mDeviceContext->SetPixelScale(aZoom);
NS_ASSERTION(!mSupressResizeReflow, "two zooms happening at the same time? impossible!");
mSupressResizeReflow = true;

View File

@ -3387,7 +3387,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
(LookAndFeel::FontID)systemFontValue->GetIntValue();
float devPerCSS =
(float)nsPresContext::AppUnitsPerCSSPixel() /
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
nsAutoString systemFontName;
if (LookAndFeel::GetFont(fontID, systemFontName, fontStyle, devPerCSS)) {
systemFontName.Trim("\"'");
@ -3398,10 +3398,9 @@ 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()->
AppUnitsPerDevPixelAtUnitFullZoom());
systemFont.size = NSFloatPixelsToAppUnits(fontStyle.size,
aPresContext->DeviceContext()->
UnscaledAppUnitsPerDevPixel());
//systemFont.langGroup = fontStyle.langGroup;
systemFont.sizeAdjust = fontStyle.sizeAdjust;

View File

@ -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 zoom as mScreenXPos and
// mScreenYPos are unzoomed screen coordinates.
int32_t factor = devContext->AppUnitsPerDevPixelAtUnitFullZoom();
// CSS pixels into device pixels, ignoring any scaling as mScreenXPos and
// mScreenYPos are unscaled screen coordinates.
int32_t factor = devContext->UnscaledAppUnitsPerDevPixel();
// 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
@ -1313,7 +1313,7 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove, bool aS
offsetForContextMenu = presContext->DevPixelsToAppUnits(offsetForContextMenuDev);
}
// next, convert into app units accounting for the zoom
// next, convert into app units accounting for the scaling
screenPoint.x = presContext->DevPixelsToAppUnits(
nsPresContext::CSSPixelsToAppUnits(mScreenXPos) / factor);
screenPoint.y = presContext->DevPixelsToAppUnits(

View File

@ -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
// AppUnitsPerDevPixelAtUnitFullZoom value. On platforms where the device-pixel
// unscaledAppUnitsPerDevPixel 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->AppUnitsPerDevPixelAtUnitFullZoom()) {
if (NSToIntRound(60.0 / scale.scale) == dx->UnscaledAppUnitsPerDevPixel()) {
invScale = 1.0 / scale.scale;
} else {
invScale = dx->AppUnitsPerDevPixelAtUnitFullZoom() / 60.0;
invScale = dx->UnscaledAppUnitsPerDevPixel() / 60.0;
}
if (changedPos) {

View File

@ -648,7 +648,7 @@ void
nsBaseDragService::ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
int32_t* aScreenX, int32_t* aScreenY)
{
int32_t adj = aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
int32_t adj = aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
*aScreenX = nsPresContext::CSSPixelsToAppUnits(*aScreenX) / adj;
*aScreenY = nsPresContext::CSSPixelsToAppUnits(*aScreenY) / adj;
}