Bug 1401069 - Part 6. Fine tune ComputeScaleFactor. r=fatseng

Make the implementation of it moew consice.
MozReview-Commit-ID: J7v98HBLhT

--HG--
extra : rebase_source : bc6e55c6cb0833c14eafd18338e79fc1a32c46c1
This commit is contained in:
cku 2017-09-18 23:40:05 +08:00
Родитель daf81c865b
Коммит 87185c9c9e
1 изменённых файлов: 4 добавлений и 10 удалений

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

@ -11,22 +11,16 @@
#include "mozilla/dom/File.h"
#include "mozilla/Unused.h"
/* Scale DC by keeping aspect ratio */
static
float ComputeScaleFactor(int aDCWidth, int aDCHeight,
int aPageWidth, int aPageHeight)
{
MOZ_ASSERT(aPageWidth !=0 && aPageWidth != 0);
float scaleFactor = 1.0;
// If page fits DC - no scaling needed.
if (aDCWidth < aPageWidth || aDCHeight < aPageHeight) {
float xFactor =
static_cast<float>(aDCWidth) / static_cast <float>(aPageWidth);
float yFactor =
static_cast<float>(aDCHeight) / static_cast <float>(aPageHeight);
scaleFactor = std::min(xFactor, yFactor);
}
return scaleFactor;
return (aDCWidth >= aPageWidth && aDCHeight >= aPageHeight)
? 1.0 /* If page fits DC - no scaling needed. */
: std::min(static_cast<float>(aDCWidth) / static_cast<float>(aPageWidth), static_cast<float>(aDCHeight) / static_cast<float>(aPageHeight));
}
PDFViaEMFPrintHelper::PDFViaEMFPrintHelper()