Nest enum FXCODEC_RESUNIT in CFX_DIBAttribute.

It is only used with respect to one field in the dib attribute, and use
it in place of the uint16_t type. Convert to k-style naming to avoid a
collision once the FXCODEC_ prefix is stripped.

Change-Id: I62b37a12f8bf490224f4f019aa9df1fde17fb8f2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/90050
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/bmp/bmp_decoder.cpp b/core/fxcodec/bmp/bmp_decoder.cpp
index 1948737..bde32fb 100644
--- a/core/fxcodec/bmp/bmp_decoder.cpp
+++ b/core/fxcodec/bmp/bmp_decoder.cpp
@@ -46,7 +46,7 @@
   *components = ctx->m_Bmp.components();
   *pal_num = ctx->m_Bmp.pal_num();
   *palette = ctx->m_Bmp.palette();
-  pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER;
+  pAttribute->m_wDPIUnit = CFX_DIBAttribute::kResUnitMeter;
   pAttribute->m_nXDPI = ctx->m_Bmp.dpi_x();
   pAttribute->m_nYDPI = ctx->m_Bmp.dpi_y();
   return Status::kSuccess;
diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h
index 4849908..c0724cf 100644
--- a/core/fxcodec/fx_codec.h
+++ b/core/fxcodec/fx_codec.h
@@ -16,12 +16,21 @@
 #ifdef PDF_ENABLE_XFA
 class CFX_DIBAttribute {
  public:
+  // Not an enum class yet because we still blindly cast integer results
+  // from third-party libraries to this type.
+  enum ResUnit : uint16_t {
+    kResUnitNone = 0,
+    kResUnitInch,
+    kResUnitCentimeter,
+    kResUnitMeter
+  };
+
   CFX_DIBAttribute();
   ~CFX_DIBAttribute();
 
   int32_t m_nXDPI = -1;
   int32_t m_nYDPI = -1;
-  uint16_t m_wDPIUnit = 0;
+  ResUnit m_wDPIUnit = kResUnitNone;
 };
 #endif  // PDF_ENABLE_XFA
 
diff --git a/core/fxcodec/fx_codec_def.h b/core/fxcodec/fx_codec_def.h
index 247bf3c..42f1c7a 100644
--- a/core/fxcodec/fx_codec_def.h
+++ b/core/fxcodec/fx_codec_def.h
@@ -34,13 +34,6 @@
 #endif  // PDF_ENABLE_XFA_TIFF
   FXCODEC_IMAGE_MAX
 };
-
-enum FXCODEC_RESUNIT {
-  FXCODEC_RESUNIT_NONE = 0,
-  FXCODEC_RESUNIT_INCH,
-  FXCODEC_RESUNIT_CENTIMETER,
-  FXCODEC_RESUNIT_METER
-};
 #endif  // PDF_ENABLE_XFA
 
 #endif  // CORE_FXCODEC_FX_CODEC_DEF_H_
diff --git a/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp b/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp
index c4baedc..db61d34 100644
--- a/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp
+++ b/core/fxcodec/jpeg/jpeg_progressive_decoder.cpp
@@ -58,7 +58,8 @@
                               CFX_DIBAttribute* pAttribute) {
   pAttribute->m_nXDPI = info.X_density;
   pAttribute->m_nYDPI = info.Y_density;
-  pAttribute->m_wDPIUnit = info.density_unit;
+  pAttribute->m_wDPIUnit =
+      static_cast<CFX_DIBAttribute::ResUnit>(info.density_unit);
 }
 
 CJpegContext::CJpegContext() {
diff --git a/core/fxcodec/tiff/tiff_decoder.cpp b/core/fxcodec/tiff/tiff_decoder.cpp
index 835b25a..e4dc603 100644
--- a/core/fxcodec/tiff/tiff_decoder.cpp
+++ b/core/fxcodec/tiff/tiff_decoder.cpp
@@ -235,9 +235,10 @@
 
   uint16_t tif_resunit = 0;
   if (TIFFGetField(m_tif_ctx.get(), TIFFTAG_RESOLUTIONUNIT, &tif_resunit)) {
-    pAttribute->m_wDPIUnit = tif_resunit - 1;
+    pAttribute->m_wDPIUnit =
+        static_cast<CFX_DIBAttribute::ResUnit>(tif_resunit - 1);
   } else {
-    pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_INCH;
+    pAttribute->m_wDPIUnit = CFX_DIBAttribute::kResUnitInch;
   }
 
   float tif_xdpi = 0.0f;
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index aa757c3..f070c7c 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -153,11 +153,11 @@
   CFX_DIBAttribute dibAttr;
   pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false);
   switch (dibAttr.m_wDPIUnit) {
-    case FXCODEC_RESUNIT_CENTIMETER:
+    case CFX_DIBAttribute::kResUnitCentimeter:
       dibAttr.m_nXDPI = static_cast<int32_t>(dibAttr.m_nXDPI * 2.54f);
       dibAttr.m_nYDPI = static_cast<int32_t>(dibAttr.m_nYDPI * 2.54f);
       break;
-    case FXCODEC_RESUNIT_METER:
+    case CFX_DIBAttribute::kResUnitMeter:
       dibAttr.m_nXDPI =
           static_cast<int32_t>(dibAttr.m_nXDPI / (float)100 * 2.54f);
       dibAttr.m_nYDPI =