Bug 1313375 - Fix nsDeviceContext::IsPrinterSurface() to not fail between BeginPage()/EndPage() calls. r=mstange

--HG--
extra : rebase_source : 09104680802a59eb0a909156bea4ab518d571067
This commit is contained in:
Jonathan Watt 2016-10-24 13:58:20 +01:00
Родитель fd5181fc38
Коммит 9afbd0617b
3 изменённых файлов: 12 добавлений и 11 удалений

Просмотреть файл

@ -238,9 +238,13 @@ nsDeviceContext::FontMetricsDeleted(const nsFontMetrics* aFontMetrics)
}
bool
nsDeviceContext::IsPrinterSurface()
nsDeviceContext::IsPrinterContext()
{
return mPrintTarget != nullptr;
return mPrintTarget != nullptr
#ifdef XP_MACOSX
|| mCachedPrintTarget != nullptr
#endif
;
}
void
@ -328,7 +332,7 @@ nsDeviceContext::Init(nsIWidget *aWidget)
already_AddRefed<gfxContext>
nsDeviceContext::CreateRenderingContext()
{
MOZ_ASSERT(IsPrinterSurface());
MOZ_ASSERT(IsPrinterContext());
MOZ_ASSERT(mWidth > 0 && mHeight > 0);
RefPtr<PrintTarget> printingTarget = mPrintTarget;
@ -398,8 +402,7 @@ nsDeviceContext::GetDepth(uint32_t& aDepth)
nsresult
nsDeviceContext::GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHeight)
{
if (mPrintTarget) {
// we have a printer device
if (IsPrinterContext()) {
aWidth = mWidth;
aHeight = mHeight;
} else {
@ -415,8 +418,7 @@ nsDeviceContext::GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHeight)
nsresult
nsDeviceContext::GetRect(nsRect &aRect)
{
if (mPrintTarget) {
// we have a printer device
if (IsPrinterContext()) {
aRect.x = 0;
aRect.y = 0;
aRect.width = mWidth;
@ -430,8 +432,7 @@ nsDeviceContext::GetRect(nsRect &aRect)
nsresult
nsDeviceContext::GetClientRect(nsRect &aRect)
{
if (mPrintTarget) {
// we have a printer device
if (IsPrinterContext()) {
aRect.x = 0;
aRect.y = 0;
aRect.width = mWidth;

Просмотреть файл

@ -254,7 +254,7 @@ public:
/**
* True if this device context was created for printing.
*/
bool IsPrinterSurface();
bool IsPrinterContext();
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale();

Просмотреть файл

@ -129,7 +129,7 @@ nsFontMetrics::nsFontMetrics(const nsFont& aFont, const Params& aParams,
aParams.explicitLanguage,
aFont.sizeAdjust,
aFont.systemFont,
mDeviceContext->IsPrinterSurface(),
mDeviceContext->IsPrinterContext(),
aFont.synthesis & NS_FONT_SYNTHESIS_WEIGHT,
aFont.synthesis & NS_FONT_SYNTHESIS_STYLE,
aFont.languageOverride);