Put IsMetricForCID() back in cpdf_cidfont.cpp

A conditional in CPDF_CIDFont::GetVertOrigin() has a typo. Fix this by
restoring IsMetricForCID() and using it where applicable inside
CPDF_CIDFont. To make it work for both struct LowHighVal and
LowHighValXY, change LowHighValXY to inherit from LowHighVal.

Change-Id: I9a512786601d96cd3cb2a7029567e94a3d443223
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/121237
Reviewed-by: Tom Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index da6d0af..86e1954 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -44,14 +44,15 @@
   int val;
 };
 
-struct LowHighValXY {
-  int low;
-  int high;
-  int val;
+struct LowHighValXY : LowHighVal {
   int x;
   int y;
 };
 
+bool IsMetricForCID(const LowHighVal& val, uint16_t cid) {
+  return val.low <= cid && cid <= val.high;
+}
+
 constexpr std::array<FX_CodePage, CIDSET_NUM_SETS> kCharsetCodePages = {
     FX_CodePage::kDefANSI,
     FX_CodePage::kChineseSimplified,
@@ -553,7 +554,7 @@
   auto lhv_span = fxcrt::truncating_reinterpret_span<const LowHighVal>(
       pdfium::make_span(m_WidthList));
   for (const auto& lhv : lhv_span) {
-    if (lhv.low <= cid && cid <= lhv.high) {
+    if (IsMetricForCID(lhv, cid)) {
       return lhv.val;
     }
   }
@@ -564,7 +565,7 @@
   auto lhvxy_span = fxcrt::truncating_reinterpret_span<const LowHighValXY>(
       pdfium::make_span(m_VertMetrics));
   for (const auto& lhvxy : lhvxy_span) {
-    if (lhvxy.low <= cid && cid <= lhvxy.high) {
+    if (IsMetricForCID(lhvxy, cid)) {
       return lhvxy.val;
     }
   }
@@ -575,7 +576,7 @@
   auto lhvxy_span = fxcrt::truncating_reinterpret_span<const LowHighValXY>(
       pdfium::make_span(m_VertMetrics));
   for (const auto& lhvxy : lhvxy_span) {
-    if (lhvxy.low <= cid & cid <= lhvxy.high) {
+    if (IsMetricForCID(lhvxy, cid)) {
       return {static_cast<int16_t>(lhvxy.x), static_cast<int16_t>(lhvxy.y)};
     }
   }
@@ -583,7 +584,7 @@
   auto lhv_span = fxcrt::truncating_reinterpret_span<const LowHighVal>(
       pdfium::make_span(m_WidthList));
   for (const auto& lhv : lhv_span) {
-    if (lhv.low <= cid && cid <= lhv.high) {
+    if (IsMetricForCID(lhv, cid)) {
       width = lhv.val;
       break;
     }