Remove four #defines from cpwl_wnd.h

Replace with static constexprs.

Change-Id: I3890ab4f9fe200ac2900113f84986dfdf0f3e615
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83271
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/cfx_color.h b/core/fxge/cfx_color.h
index 01dd5d7..3ad1bcf 100644
--- a/core/fxge/cfx_color.h
+++ b/core/fxge/cfx_color.h
@@ -21,21 +21,21 @@
     FX_ARGB argb;
   };
 
-  explicit CFX_Color(FX_COLORREF ref)
+  explicit constexpr CFX_Color(FX_COLORREF ref)
       : CFX_Color(FXARGB_R(ref), FXARGB_G(ref), FXARGB_B(ref)) {}
 
-  CFX_Color(Type type = CFX_Color::Type::kTransparent,
-            float color1 = 0.0f,
-            float color2 = 0.0f,
-            float color3 = 0.0f,
-            float color4 = 0.0f)
+  constexpr CFX_Color(Type type = CFX_Color::Type::kTransparent,
+                      float color1 = 0.0f,
+                      float color2 = 0.0f,
+                      float color3 = 0.0f,
+                      float color4 = 0.0f)
       : nColorType(type),
         fColor1(color1),
         fColor2(color2),
         fColor3(color3),
         fColor4(color4) {}
 
-  CFX_Color(int32_t r, int32_t g, int32_t b)
+  constexpr CFX_Color(int32_t r, int32_t g, int32_t b)
       : nColorType(CFX_Color::Type::kRGB),
         fColor1(r / 255.0f),
         fColor2(g / 255.0f),
diff --git a/fpdfsdk/pwl/cpwl_cbbutton.cpp b/fpdfsdk/pwl/cpwl_cbbutton.cpp
index a16b26a..bd72664 100644
--- a/fpdfsdk/pwl/cpwl_cbbutton.cpp
+++ b/fpdfsdk/pwl/cpwl_cbbutton.cpp
@@ -54,7 +54,7 @@
   path.AppendPoint(pt1, CFX_Path::Point::Type::kLine);
 
   pDevice->DrawPath(&path, &mtUser2Device, nullptr,
-                    PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0,
+                    kDefaultBlackColor.ToFXColor(GetTransparency()), 0,
                     CFX_FillRenderOptions::EvenOddOptions());
 }
 
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index f96dbce..8342175 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -161,7 +161,7 @@
   bcp.dwFlags = PWS_VISIBLE | PWS_BORDER | PWS_BACKGROUND;
   bcp.sBackgroundColor = CFX_Color(CFX_Color::Type::kRGB, 220.0f / 255.0f,
                                    220.0f / 255.0f, 220.0f / 255.0f);
-  bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
+  bcp.sBorderColor = kDefaultBlackColor;
   bcp.dwBorderWidth = 2;
   bcp.nBorderStyle = BorderStyle::kBeveled;
   bcp.eCursorType = IPWL_SystemHandler::CursorStyle::kArrow;
@@ -182,15 +182,14 @@
   lcp.dwBorderWidth = 1;
   lcp.eCursorType = IPWL_SystemHandler::CursorStyle::kArrow;
   lcp.rcRectWnd = CFX_FloatRect();
-
   lcp.fFontSize =
       (cp.dwFlags & PWS_AUTOFONTSIZE) ? kComboBoxDefaultFontSize : cp.fFontSize;
 
   if (cp.sBorderColor.nColorType == CFX_Color::Type::kTransparent)
-    lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
+    lcp.sBorderColor = kDefaultBlackColor;
 
   if (cp.sBackgroundColor.nColorType == CFX_Color::Type::kTransparent)
-    lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
+    lcp.sBackgroundColor = kDefaultWhiteColor;
 
   auto pList = std::make_unique<CPWL_CBListBox>(lcp, CloneAttachedData());
   m_pList = pList.get();
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index 9fe729d..23a6e6f 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -50,7 +50,7 @@
     CFX_FloatRect rcWindow = m_rcOldWindow;
     CFX_FloatRect rcVScroll =
         CFX_FloatRect(rcWindow.right, rcWindow.bottom,
-                      rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top);
+                      rcWindow.right + CPWL_ScrollBar::kWidth, rcWindow.top);
 
     ObservedPtr<CPWL_Edit> thisObserved(this);
     pVSB->Move(rcVScroll, true, false);
@@ -76,12 +76,9 @@
 CFX_FloatRect CPWL_Edit::GetClientRect() const {
   float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
   CFX_FloatRect rcClient = GetWindowRect().GetDeflated(width, width);
-  if (CPWL_ScrollBar* pVSB = GetVScrollBar()) {
-    if (pVSB->IsVisible()) {
-      rcClient.right -= PWL_SCROLLBAR_WIDTH;
-    }
-  }
-
+  CPWL_ScrollBar* pVSB = GetVScrollBar();
+  if (pVSB && pVSB->IsVisible())
+    rcClient.right -= CPWL_ScrollBar::kWidth;
   return rcClient;
 }
 
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
index 17ebec8..bd4a033 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp
@@ -228,8 +228,8 @@
   CPWL_Wnd::OnLButtonUp(nFlag, point);
 
   if (HasFlag(PWS_AUTOTRANSPARENT)) {
-    if (GetTransparency() != PWL_SCROLLBAR_TRANSPARENCY) {
-      SetTransparency(PWL_SCROLLBAR_TRANSPARENCY);
+    if (GetTransparency() != kTransparency) {
+      SetTransparency(kTransparency);
       if (!InvalidateRect(nullptr))
         return true;
     }
@@ -318,10 +318,7 @@
 }
 
 float CPWL_ScrollBar::GetScrollBarWidth() const {
-  if (!IsVisible())
-    return 0;
-
-  return PWL_SCROLLBAR_WIDTH;
+  return IsVisible() ? kWidth : 0.0f;
 }
 
 void CPWL_ScrollBar::SetScrollRange(float fMin,
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.h b/fpdfsdk/pwl/cpwl_scroll_bar.h
index ec8d367..4e6df62 100644
--- a/fpdfsdk/pwl/cpwl_scroll_bar.h
+++ b/fpdfsdk/pwl/cpwl_scroll_bar.h
@@ -91,6 +91,9 @@
 
 class CPWL_ScrollBar final : public CPWL_Wnd, public CFX_Timer::CallbackIface {
  public:
+  static constexpr float kWidth = 12.0f;
+  static constexpr uint8_t kTransparency = 150;
+
   CPWL_ScrollBar(
       const CreateParams& cp,
       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData);
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index a4eda99..7d63b9b 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -25,6 +25,14 @@
 
 }  // namespace
 
+// static
+const CFX_Color CPWL_Wnd::kDefaultBlackColor =
+    CFX_Color(CFX_Color::Type::kGray, 0);
+
+// static
+const CFX_Color CPWL_Wnd::kDefaultWhiteColor =
+    CFX_Color(CFX_Color::Type::kGray, 1);
+
 CPWL_Wnd::CreateParams::CreateParams()
     : fFontSize(kDefaultFontSize), sDash(3, 0, 0) {}
 
@@ -491,9 +499,9 @@
 
   CreateParams scp = cp;
   scp.dwFlags = PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP;
-  scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
+  scp.sBackgroundColor = kDefaultWhiteColor;
   scp.eCursorType = IPWL_SystemHandler::CursorStyle::kArrow;
-  scp.nTransparency = PWL_SCROLLBAR_TRANSPARENCY;
+  scp.nTransparency = CPWL_ScrollBar::kTransparency;
 
   auto pBar = std::make_unique<CPWL_ScrollBar>(scp, CloneAttachedData());
   m_pVScrollBar = pBar.get();
@@ -593,7 +601,7 @@
     rcContent.Normalize();
   }
   CFX_FloatRect rcVScroll =
-      CFX_FloatRect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom,
+      CFX_FloatRect(rcContent.right - CPWL_ScrollBar::kWidth, rcContent.bottom,
                     rcContent.right - 1.0f, rcContent.top);
 
   ObservedPtr<CPWL_Wnd> thisObserved(this);
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index e293a2b..60afe1d 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -72,13 +72,11 @@
   int32_t nPhase;
 };
 
-#define PWL_SCROLLBAR_WIDTH 12.0f
-#define PWL_SCROLLBAR_TRANSPARENCY 150
-#define PWL_DEFAULT_BLACKCOLOR CFX_Color(CFX_Color::Type::kGray, 0)
-#define PWL_DEFAULT_WHITECOLOR CFX_Color(CFX_Color::Type::kGray, 1)
-
 class CPWL_Wnd : public Observable {
  public:
+  static const CFX_Color kDefaultBlackColor;
+  static const CFX_Color kDefaultWhiteColor;
+
   class ProviderIface : public Observable {
    public:
     virtual ~ProviderIface() = default;