Bug 1399787 - Part 2.c. Rename DrawPageToFile to SavePageToFile. draft
authorcku <cku@mozilla.com>
Thu, 02 Nov 2017 20:19:30 +0800
changeset 710598 c31ab60b22833cd992d50a82f894085223c7fa55
parent 710597 0e17c0219f626351fa3c78e53fbaf4840c01d017
child 710599 0f4cbff19ae5cd34f8ab9a0fa8e1fa8b115a3f73
push id92855
push usercku@mozilla.com
push dateMon, 11 Dec 2017 02:44:26 +0000
bugs1399787
milestone59.0a1
Bug 1399787 - Part 2.c. Rename DrawPageToFile to SavePageToFile. This is to make the naming more consistent with SavePageToBuffer. MozReview-Commit-ID: 5miYvv9yFFR
widget/windows/PDFViaEMFPrintHelper.cpp
widget/windows/PDFViaEMFPrintHelper.h
widget/windows/gtest/TestEMFConversion.cpp
--- a/widget/windows/PDFViaEMFPrintHelper.cpp
+++ b/widget/windows/PDFViaEMFPrintHelper.cpp
@@ -178,17 +178,17 @@ PDFViaEMFPrintHelper::DrawPage(HDC aPrin
   NS_ENSURE_TRUE(result, false);
 
   RECT printRect = {0, 0, aPageWidth, aPageHeight};
   result = emf.Playback(aPrinterDC, printRect);
   return result;
 }
 
 bool
-PDFViaEMFPrintHelper::DrawPageToFile(const wchar_t* aFilePath,
+PDFViaEMFPrintHelper::SavePageToFile(const wchar_t* aFilePath,
                                      unsigned int aPageIndex,
                                      int aPageWidth, int aPageHeight)
 {
   MOZ_ASSERT(aFilePath);
 
   // OpenDocument might fail.
   if (!mPDFDoc) {
     MOZ_ASSERT_UNREACHABLE("Make sure OpenDocument return true before"
--- a/widget/windows/PDFViaEMFPrintHelper.h
+++ b/widget/windows/PDFViaEMFPrintHelper.h
@@ -50,17 +50,17 @@ public:
 
   int GetPageCount() const { return mPDFiumEngine->GetPageCount(mPDFDoc); }
 
   /** Convert specified PDF page to EMF and draw the EMF onto the given DC. */
   bool DrawPage(HDC aPrinterDC, unsigned int aPageIndex,
                 int aPageWidth, int aPageHeight);
 
   /** Convert a specified PDF page to EMF and save it to file. */
-  bool DrawPageToFile(const wchar_t* aFilePath, unsigned int aPageIndex,
+  bool SavePageToFile(const wchar_t* aFilePath, unsigned int aPageIndex,
                       int aPageWidth, int aPageHeight);
 
   /** Create a share memory and serialize the EMF content into it. */
   bool SavePageToBuffer(unsigned int aPageIndex, int aPageWidth,
                         int aPageHeight, ipc::Shmem& aMem,
                         mozilla::ipc::IShmemAllocator* aAllocator);
 
 protected:
--- a/widget/windows/gtest/TestEMFConversion.cpp
+++ b/widget/windows/gtest/TestEMFConversion.cpp
@@ -147,31 +147,31 @@ TEST(TestEMFConversion, CompareEMFWithRe
   const int pageWidth = 4961;
   const int pageHeight = 7016;
 
   // Convert a PDF file to an EMF file(PrinterTestPage.pdf -> gtest.emf)
   nsAutoString emfPath;
   ASSERT_TRUE(NS_SUCCEEDED(GetFilePathViaSpecialDirectory(NS_OS_TEMP_DIR,
                                                         "gtest.emf",
                                                         emfPath)));
-  ASSERT_TRUE(PDFHelper->DrawPageToFile(emfPath.get(), 0,
+  ASSERT_TRUE(PDFHelper->SavePageToFile(emfPath.get(), 0,
                                         pageWidth, pageHeight));
   PDFHelper->CloseDocument();
 #ifdef _WIN64
   // Convert a PDF file to an EMF file by external library.
   // (PrinterTestPage.pdf -> gtestRef.emf)
   UniquePtr<EMFViaExtDLLHelper> ExtHelper = MakeUnique<EMFViaExtDLLHelper>();
   ASSERT_TRUE(SetupPrintHelper("PrinterTestPage.pdf", ExtHelper.get()));
 
   nsAutoString emfPathRef;
   ASSERT_TRUE(NS_SUCCEEDED(GetFilePathViaSpecialDirectory(NS_OS_TEMP_DIR,
                                                           "gtestRef.emf",
                                                           emfPathRef)));
 
-  ASSERT_TRUE(ExtHelper->DrawPageToFile(emfPathRef.get(), 0,
+  ASSERT_TRUE(ExtHelper->SavePageToFile(emfPathRef.get(), 0,
                                         pageWidth, pageHeight));
   ExtHelper->CloseDocument();
 
   CompareTwoFiles(emfPath, emfPathRef);
 #endif
 }
 
 // Input a PDF file which does not exist
@@ -189,16 +189,16 @@ TEST(TestEMFConversion, TestInsufficient
     MakeUnique<PDFViaEMFPrintHelper>();
   ASSERT_TRUE(SetupPrintHelper("PrinterTestPage.pdf", PDFHelper.get()));
 
   nsAutoString emfPath;
   ASSERT_TRUE(NS_SUCCEEDED(GetFilePathViaSpecialDirectory(NS_OS_TEMP_DIR,
                                                          "gtest.emf",
                                                           emfPath)));
 
-  ASSERT_FALSE(PDFHelper->DrawPageToFile(emfPath.get(), 0, 0, 0));
-  ASSERT_FALSE(PDFHelper->PageToFile(emfPath.get(), 0, 100, -1));
+  ASSERT_FALSE(PDFHelper->SavePageToFile(emfPath.get(), 0, 0, 0));
+  ASSERT_FALSE(PDFHelper->SavePageToFile(emfPath.get(), 0, 100, -1));
 
   PDFHelper->CloseDocument();
 }
 
 } // namespace widget
 } // namespace mozilla
\ No newline at end of file