Make WindowsPrintMode an enum class.

Rename enum values to remove redundant "Mode" word. Fix an enum to int
comparison.

Change-Id: Icbe48f5b87d34e18da49a930f9a31e845b403baa
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84911
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_windowsrenderdevice.cpp b/core/fxge/cfx_windowsrenderdevice.cpp
index e12958f..0707a7e 100644
--- a/core/fxge/cfx_windowsrenderdevice.cpp
+++ b/core/fxge/cfx_windowsrenderdevice.cpp
@@ -29,12 +29,12 @@
   if (!use_printer)
     return std::make_unique<CGdiDisplayDriver>(hDC);
 
-  if (g_pdfium_print_mode == WindowsPrintMode::kModeEmf ||
-      g_pdfium_print_mode == WindowsPrintMode::kModeEmfImageMasks) {
+  if (g_pdfium_print_mode == WindowsPrintMode::kEmf ||
+      g_pdfium_print_mode == WindowsPrintMode::kEmfImageMasks) {
     return std::make_unique<CGdiPrinterDriver>(hDC);
   }
 
-  if (g_pdfium_print_mode == WindowsPrintMode::kModeTextOnly)
+  if (g_pdfium_print_mode == WindowsPrintMode::kTextOnly)
     return std::make_unique<CTextOnlyPrinterDriver>(hDC);
 
   return std::make_unique<CPSPrinterDriver>(hDC, g_pdfium_print_mode,
@@ -43,7 +43,7 @@
 
 }  // namespace
 
-WindowsPrintMode g_pdfium_print_mode = WindowsPrintMode::kModeEmf;
+WindowsPrintMode g_pdfium_print_mode = WindowsPrintMode::kEmf;
 
 CFX_WindowsRenderDevice::CFX_WindowsRenderDevice(
     HDC hDC,
diff --git a/core/fxge/cfx_windowsrenderdevice.h b/core/fxge/cfx_windowsrenderdevice.h
index 8aa3ca3..55cbb6f 100644
--- a/core/fxge/cfx_windowsrenderdevice.h
+++ b/core/fxge/cfx_windowsrenderdevice.h
@@ -11,16 +11,16 @@
 
 #include "core/fxge/cfx_renderdevice.h"
 
-enum WindowsPrintMode {
-  kModeEmf = 0,
-  kModeTextOnly = 1,
-  kModePostScript2 = 2,
-  kModePostScript3 = 3,
-  kModePostScript2PassThrough = 4,
-  kModePostScript3PassThrough = 5,
-  kModeEmfImageMasks = 6,
-  kModePostScript3Type42 = 7,
-  kModePostScript3Type42PassThrough = 8,
+enum class WindowsPrintMode {
+  kEmf = 0,
+  kTextOnly = 1,
+  kPostScript2 = 2,
+  kPostScript3 = 3,
+  kPostScript2PassThrough = 4,
+  kPostScript3PassThrough = 5,
+  kEmfImageMasks = 6,
+  kPostScript3Type42 = 7,
+  kPostScript3Type42PassThrough = 8,
 };
 
 struct EncoderIface;
diff --git a/core/fxge/win32/cps_printer_driver.cpp b/core/fxge/win32/cps_printer_driver.cpp
index efc65ff..0a95f20 100644
--- a/core/fxge/win32/cps_printer_driver.cpp
+++ b/core/fxge/win32/cps_printer_driver.cpp
@@ -24,14 +24,14 @@
 CFX_PSRenderer::RenderingLevel RenderingLevelFromWindowsPrintMode(
     WindowsPrintMode mode) {
   switch (mode) {
-    case WindowsPrintMode::kModePostScript2:
-    case WindowsPrintMode::kModePostScript2PassThrough:
+    case WindowsPrintMode::kPostScript2:
+    case WindowsPrintMode::kPostScript2PassThrough:
       return CFX_PSRenderer::RenderingLevel::kLevel2;
-    case WindowsPrintMode::kModePostScript3:
-    case WindowsPrintMode::kModePostScript3PassThrough:
+    case WindowsPrintMode::kPostScript3:
+    case WindowsPrintMode::kPostScript3PassThrough:
       return CFX_PSRenderer::RenderingLevel::kLevel3;
-    case WindowsPrintMode::kModePostScript3Type42:
-    case WindowsPrintMode::kModePostScript3Type42PassThrough:
+    case WindowsPrintMode::kPostScript3Type42:
+    case WindowsPrintMode::kPostScript3Type42PassThrough:
       return CFX_PSRenderer::RenderingLevel::kLevel3Type42;
     default:
       // |mode| should be PostScript.
@@ -49,9 +49,9 @@
   CFX_PSRenderer::RenderingLevel level =
       RenderingLevelFromWindowsPrintMode(mode);
   CPSOutput::OutputMode output_mode =
-      (mode == WindowsPrintMode::kModePostScript2 ||
-       mode == WindowsPrintMode::kModePostScript3 ||
-       mode == WindowsPrintMode::kModePostScript3Type42)
+      (mode == WindowsPrintMode::kPostScript2 ||
+       mode == WindowsPrintMode::kPostScript3 ||
+       mode == WindowsPrintMode::kPostScript3Type42)
           ? CPSOutput::OutputMode::kGdiComment
           : CPSOutput::OutputMode::kExtEscape;
 
diff --git a/core/fxge/win32/ctext_only_printer_driver.cpp b/core/fxge/win32/ctext_only_printer_driver.cpp
index 9d8b65f..20ca4ef 100644
--- a/core/fxge/win32/ctext_only_printer_driver.cpp
+++ b/core/fxge/win32/ctext_only_printer_driver.cpp
@@ -128,7 +128,7 @@
     float font_size,
     uint32_t color,
     const CFX_TextRenderOptions& /*options*/) {
-  if (g_pdfium_print_mode != 1)
+  if (g_pdfium_print_mode != WindowsPrintMode::kTextOnly)
     return false;
   if (nChars < 1 || !pFont || !pFont->IsEmbedded() || !pFont->IsTTFont())
     return false;
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 998c127..1bd0573 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -66,30 +66,33 @@
 #include "public/fpdf_edit.h"
 
 // These checks are here because core/ and public/ cannot depend on each other.
-static_assert(WindowsPrintMode::kModeEmf == FPDF_PRINTMODE_EMF,
-              "WindowsPrintMode::kModeEmf value mismatch");
-static_assert(WindowsPrintMode::kModeTextOnly == FPDF_PRINTMODE_TEXTONLY,
-              "WindowsPrintMode::kModeTextOnly value mismatch");
-static_assert(WindowsPrintMode::kModePostScript2 == FPDF_PRINTMODE_POSTSCRIPT2,
-              "WindowsPrintMode::kModePostScript2 value mismatch");
-static_assert(WindowsPrintMode::kModePostScript3 == FPDF_PRINTMODE_POSTSCRIPT3,
-              "WindowsPrintMode::kModePostScript3 value mismatch");
-static_assert(WindowsPrintMode::kModePostScript2PassThrough ==
+static_assert(static_cast<int>(WindowsPrintMode::kEmf) == FPDF_PRINTMODE_EMF,
+              "WindowsPrintMode::kEmf value mismatch");
+static_assert(static_cast<int>(WindowsPrintMode::kTextOnly) ==
+                  FPDF_PRINTMODE_TEXTONLY,
+              "WindowsPrintMode::kTextOnly value mismatch");
+static_assert(static_cast<int>(WindowsPrintMode::kPostScript2) ==
+                  FPDF_PRINTMODE_POSTSCRIPT2,
+              "WindowsPrintMode::kPostScript2 value mismatch");
+static_assert(static_cast<int>(WindowsPrintMode::kPostScript3) ==
+                  FPDF_PRINTMODE_POSTSCRIPT3,
+              "WindowsPrintMode::kPostScript3 value mismatch");
+static_assert(static_cast<int>(WindowsPrintMode::kPostScript2PassThrough) ==
                   FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH,
-              "WindowsPrintMode::kModePostScript2PassThrough value mismatch");
-static_assert(WindowsPrintMode::kModePostScript3PassThrough ==
+              "WindowsPrintMode::kPostScript2PassThrough value mismatch");
+static_assert(static_cast<int>(WindowsPrintMode::kPostScript3PassThrough) ==
                   FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH,
-              "WindowsPrintMode::kModePostScript3PassThrough value mismatch");
-static_assert(WindowsPrintMode::kModeEmfImageMasks ==
+              "WindowsPrintMode::kPostScript3PassThrough value mismatch");
+static_assert(static_cast<int>(WindowsPrintMode::kEmfImageMasks) ==
                   FPDF_PRINTMODE_EMF_IMAGE_MASKS,
-              "WindowsPrintMode::kModeEmfImageMasks value mismatch");
-static_assert(WindowsPrintMode::kModePostScript3Type42 ==
+              "WindowsPrintMode::kEmfImageMasks value mismatch");
+static_assert(static_cast<int>(WindowsPrintMode::kPostScript3Type42) ==
                   FPDF_PRINTMODE_POSTSCRIPT3_TYPE42,
-              "WindowsPrintMode::kModePostScript3Type42 value mismatch");
+              "WindowsPrintMode::kPostScript3Type42 value mismatch");
 static_assert(
-    WindowsPrintMode::kModePostScript3Type42PassThrough ==
+    static_cast<int>(WindowsPrintMode::kPostScript3Type42PassThrough) ==
         FPDF_PRINTMODE_POSTSCRIPT3_TYPE42_PASSTHROUGH,
-    "WindowsPrintMode::kModePostScript3Type42PassThrough value mismatch");
+    "WindowsPrintMode::kPostScript3Type42PassThrough value mismatch");
 #endif  // defined(OS_WIN)
 
 namespace {
@@ -520,7 +523,7 @@
   // individually is inefficient and unlikely to significantly improve spool
   // size.
   const bool bEnableImageMasks =
-      g_pdfium_print_mode == WindowsPrintMode::kModeEmfImageMasks;
+      g_pdfium_print_mode == WindowsPrintMode::kEmfImageMasks;
   const bool bNewBitmap = pPage->BackgroundAlphaNeeded() ||
                           (pPage->HasImageMask() && !bEnableImageMasks) ||
                           pPage->GetMaskBoundingBoxes().size() > 100;