Mark static const class/struct members as constexpr

This change fixes declarations that have initial values but are
technically not definitions by marking them constexpr (which counts as a
definition). This enables, among other things, the modified constants to
be passed into functions and function templates that accept arguments by
reference. Without this change, such functions would cause linker
errors.

PiperOrigin-RevId: 306272137
Change-Id: Ie44890249bb126a56b0ad5383a04b24579faa082
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/68730
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Andrew Weintraub <asweintraub@google.com>
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index db776fd..d504bfe 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -57,7 +57,7 @@
         CPDF_Stream* pFormStream) = 0;
   };
 
-  static const uint32_t kInvalidCharCode = static_cast<uint32_t>(-1);
+  static constexpr uint32_t kInvalidCharCode = static_cast<uint32_t>(-1);
 
   // |pFactory| only required for Type3 fonts.
   static RetainPtr<CPDF_Font> Create(CPDF_Document* pDoc,
diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h
index 939b192..5f93e0d 100644
--- a/core/fpdfapi/page/cpdf_meshstream.h
+++ b/core/fpdfapi/page/cpdf_meshstream.h
@@ -64,7 +64,7 @@
   uint32_t Components() const { return m_nComponents; }
 
  private:
-  static const uint32_t kMaxComponents = 8;
+  static constexpr uint32_t kMaxComponents = 8;
 
   const ShadingType m_type;
   const std::vector<std::unique_ptr<CPDF_Function>>& m_funcs;
diff --git a/core/fpdfapi/page/cpdf_psengine.h b/core/fpdfapi/page/cpdf_psengine.h
index 3db8db7..faf8d94 100644
--- a/core/fpdfapi/page/cpdf_psengine.h
+++ b/core/fpdfapi/page/cpdf_psengine.h
@@ -98,7 +98,7 @@
   }
 
  private:
-  static const int kMaxDepth = 128;
+  static constexpr int kMaxDepth = 128;
 
   void AddOperator(ByteStringView word);
 
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index a270320..f9b4da2 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -76,7 +76,7 @@
     RetainPtr<CPDF_Object> m_pObject;
   };
 
-  static const int kParamBufSize = 16;
+  static constexpr int kParamBufSize = 16;
 
   using OpCodes = std::map<uint32_t, void (CPDF_StreamContentParser::*)()>;
   static OpCodes InitializeOpCodes();
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
index 81a1246..a5ffc77 100644
--- a/core/fpdfapi/page/cpdf_streamparser.h
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -44,7 +44,7 @@
 
  private:
   friend class cpdf_streamparser_ReadHexString_Test;
-  static const uint32_t kMaxWordLength = 255;
+  static constexpr uint32_t kMaxWordLength = 255;
 
   void GetNextWord(bool& bIsNumber);
   ByteString ReadString();
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index 8552980..f9cd981 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -125,7 +125,7 @@
     std::vector<std::unique_ptr<PageNode>> m_ChildNodes;
   };
 
-  static const int kMaxPageRecursionDepth = 1024;
+  static constexpr int kMaxPageRecursionDepth = 1024;
 
   bool CheckDocStatus();
   bool CheckHeader();
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index 3506e59..56168e9 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -74,7 +74,7 @@
     UnownedPtr<CPDF_Document> m_pDoc;
   };
 
-  static const int kPageMaxNum = 0xFFFFF;
+  static constexpr int kPageMaxNum = 0xFFFFF;
 
   static bool IsValidPageObject(const CPDF_Object* obj);
 
diff --git a/core/fpdfapi/parser/cpdf_object.h b/core/fpdfapi/parser/cpdf_object.h
index 77810ca..93dbbaa 100644
--- a/core/fpdfapi/parser/cpdf_object.h
+++ b/core/fpdfapi/parser/cpdf_object.h
@@ -29,7 +29,7 @@
 
 class CPDF_Object : public Retainable {
  public:
-  static const uint32_t kInvalidObjNum = static_cast<uint32_t>(-1);
+  static constexpr uint32_t kInvalidObjNum = static_cast<uint32_t>(-1);
   enum Type {
     kBoolean = 1,
     kNumber,
@@ -125,10 +125,10 @@
 
 template <typename T>
 struct CanInternStrings {
-  static const bool value = std::is_same<T, CPDF_Array>::value ||
-                            std::is_same<T, CPDF_Dictionary>::value ||
-                            std::is_same<T, CPDF_Name>::value ||
-                            std::is_same<T, CPDF_String>::value;
+  static constexpr bool value = std::is_same<T, CPDF_Array>::value ||
+                                std::is_same<T, CPDF_Dictionary>::value ||
+                                std::is_same<T, CPDF_Name>::value ||
+                                std::is_same<T, CPDF_String>::value;
 };
 
 #endif  // CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index aa86701..c9b590e 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -53,7 +53,7 @@
   // are non-consecutive.
   static constexpr uint32_t kMaxObjectNumber = 4 * 1024 * 1024;
 
-  static const size_t kInvalidPos = std::numeric_limits<size_t>::max();
+  static constexpr size_t kInvalidPos = std::numeric_limits<size_t>::max();
 
   explicit CPDF_Parser(ParsedObjectsHolder* holder);
   CPDF_Parser();
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
index d29f655..3dba365 100644
--- a/core/fpdfapi/parser/cpdf_stream.h
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -17,7 +17,7 @@
 
 class CPDF_Stream final : public CPDF_Object {
  public:
-  static const int kFileBufSize = 512;
+  static constexpr int kFileBufSize = 512;
 
   template <typename T, typename... Args>
   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h
index d0b8a31..bdcfa44 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.h
@@ -79,7 +79,7 @@
   friend class CPDF_DataAvail;
   friend class cpdf_syntax_parser_ReadHexString_Test;
 
-  static const int kParserMaxRecursionDepth = 64;
+  static constexpr int kParserMaxRecursionDepth = 64;
   static int s_CurrentRecursionDepth;
 
   bool ReadBlockAt(FX_FILESIZE read_pos);
diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.h b/core/fpdfapi/render/cpdf_progressiverenderer.h
index fd399f9..403a577 100644
--- a/core/fpdfapi/render/cpdf_progressiverenderer.h
+++ b/core/fpdfapi/render/cpdf_progressiverenderer.h
@@ -42,7 +42,7 @@
 
  private:
   // Maximum page objects to render before checking for pause.
-  static const int kStepLimit = 100;
+  static constexpr int kStepLimit = 100;
 
   Status m_Status = kReady;
   UnownedPtr<CPDF_RenderContext> const m_pContext;
diff --git a/core/fxcodec/jpeg/jpegmodule.cpp b/core/fxcodec/jpeg/jpegmodule.cpp
index 72925f1..c9b2e79 100644
--- a/core/fxcodec/jpeg/jpegmodule.cpp
+++ b/core/fxcodec/jpeg/jpegmodule.cpp
@@ -264,7 +264,7 @@
   // For a given invalid height byte offset in
   // |kKnownBadHeaderWithInvalidHeightByteOffsetStarts|, the SOFn marker should
   // be this many bytes before that.
-  static const size_t kSofMarkerByteOffset = 5;
+  static constexpr size_t kSofMarkerByteOffset = 5;
 
   uint32_t m_nDefaultScaleDenom = 1;
 };
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index ead60f7..9658ac2 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -107,9 +107,9 @@
   void SetPlatformFont(void* font) { m_pPlatformFont = font; }
 #endif
 
-  static const size_t kAngleSkewArraySize = 30;
+  static constexpr size_t kAngleSkewArraySize = 30;
   static const char s_AngleSkew[kAngleSkewArraySize];
-  static const size_t kWeightPowArraySize = 100;
+  static constexpr size_t kWeightPowArraySize = 100;
   static const uint8_t s_WeightPow[kWeightPowArraySize];
   static const uint8_t s_WeightPow_11[kWeightPowArraySize];
   static const uint8_t s_WeightPow_SHIFTJIS[kWeightPowArraySize];
diff --git a/core/fxge/cfx_fontmapper.h b/core/fxge/cfx_fontmapper.h
index c21c6cb..d063adf 100644
--- a/core/fxge/cfx_fontmapper.h
+++ b/core/fxge/cfx_fontmapper.h
@@ -76,8 +76,8 @@
   std::vector<std::pair<ByteString, ByteString>> m_LocalizedTTFonts;
 
  private:
-  static const size_t MM_FACE_COUNT = 2;
-  static const size_t FOXIT_FACE_COUNT = 14;
+  static constexpr size_t MM_FACE_COUNT = 2;
+  static constexpr size_t FOXIT_FACE_COUNT = 14;
 
   uint32_t GetChecksumFromTT(void* hFont);
   ByteString GetPSNameFromTT(void* hFont);