Replace extern const with inline constexpr in //constants

Follow modern practices and move a bunch of constants out of foo.cpp and
into foo.h.

Change-Id: I49fab670e64ac82ff15761cf81d7789671aeb811
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/131310
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/constants/BUILD.gn b/constants/BUILD.gn
index 3424743..536e34c 100644
--- a/constants/BUILD.gn
+++ b/constants/BUILD.gn
@@ -7,22 +7,15 @@
 source_set("constants") {
   sources = [
     "access_permissions.h",
-    "annotation_common.cpp",
     "annotation_common.h",
     "annotation_flags.h",
-    "appearance.cpp",
     "appearance.h",
     "ascii.h",
-    "font_encodings.cpp",
     "font_encodings.h",
-    "form_fields.cpp",
     "form_fields.h",
     "form_flags.h",
-    "page_object.cpp",
     "page_object.h",
-    "stream_dict_common.cpp",
     "stream_dict_common.h",
-    "transparency.cpp",
     "transparency.h",
   ]
   configs += [
diff --git a/constants/annotation_common.cpp b/constants/annotation_common.cpp
deleted file mode 100644
index 396e655..0000000
--- a/constants/annotation_common.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2021 The PDFium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "constants/annotation_common.h"
-
-namespace pdfium::annotation {
-
-// PDF 1.7 spec, table 8.15.
-// Entries common to all annotation dictionaries.
-const char kType[] = "Type";
-const char kSubtype[] = "Subtype";
-const char kRect[] = "Rect";
-const char kContents[] = "Contents";
-const char kP[] = "P";
-const char kNM[] = "NM";
-const char kM[] = "M";
-const char kF[] = "F";
-const char kAP[] = "AP";
-const char kAS[] = "AS";
-const char kBorder[] = "Border";
-const char kC[] = "C";
-const char kStructParent[] = "StructParent";
-const char kOC[] = "OC";
-
-// Entries for polygon and polyline annotations.
-const char kVertices[] = "Vertices";
-
-// Entries for ink annotations
-const char kInkList[] = "InkList";
-
-// Entries for line annotations
-const char kL[] = "L";
-
-}  // namespace pdfium::annotation
diff --git a/constants/annotation_common.h b/constants/annotation_common.h
index baf0677..b1bf878 100644
--- a/constants/annotation_common.h
+++ b/constants/annotation_common.h
@@ -8,26 +8,31 @@
 namespace pdfium {
 namespace annotation {
 
-extern const char kType[];
-extern const char kSubtype[];
-extern const char kRect[];
-extern const char kContents[];
-extern const char kP[];
-extern const char kNM[];
-extern const char kM[];
-extern const char kF[];
-extern const char kAP[];
-extern const char kAS[];
-extern const char kBorder[];
-extern const char kC[];
-extern const char kStructParent[];
-extern const char kOC[];
+// PDF 1.7 spec, table 8.15.
+// Entries common to all annotation dictionaries.
+inline constexpr char kType[] = "Type";
+inline constexpr char kSubtype[] = "Subtype";
+inline constexpr char kRect[] = "Rect";
+inline constexpr char kContents[] = "Contents";
+inline constexpr char kP[] = "P";
+inline constexpr char kNM[] = "NM";
+inline constexpr char kM[] = "M";
+inline constexpr char kF[] = "F";
+inline constexpr char kAP[] = "AP";
+inline constexpr char kAS[] = "AS";
+inline constexpr char kBorder[] = "Border";
+inline constexpr char kC[] = "C";
+inline constexpr char kStructParent[] = "StructParent";
+inline constexpr char kOC[] = "OC";
 
-extern const char kVertices[];
+// Entries for polygon and polyline annotations.
+inline constexpr char kVertices[] = "Vertices";
 
-extern const char kInkList[];
+// Entries for ink annotations
+inline constexpr char kInkList[] = "InkList";
 
-extern const char kL[];
+// Entries for line annotations
+inline constexpr char kL[] = "L";
 
 }  // namespace annotation
 }  // namespace pdfium
diff --git a/constants/appearance.cpp b/constants/appearance.cpp
deleted file mode 100644
index d8fdb93..0000000
--- a/constants/appearance.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2021 The PDFium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "constants/appearance.h"
-
-namespace pdfium::appearance {
-
-// ISO 32000-1:2008 spec, table 189.
-// Entries in an appearance characteristics dictionary.
-const char kR[] = "R";
-const char kBC[] = "BC";
-const char kBG[] = "BG";
-const char kCA[] = "CA";
-const char kRC[] = "RC";
-const char kAC[] = "AC";
-const char kI[] = "I";
-const char kRI[] = "RI";
-const char kIX[] = "IX";
-
-}  // namespace pdfium::appearance
diff --git a/constants/appearance.h b/constants/appearance.h
index 2a5b752..9eb45c6 100644
--- a/constants/appearance.h
+++ b/constants/appearance.h
@@ -8,15 +8,17 @@
 namespace pdfium {
 namespace appearance {
 
-extern const char kR[];
-extern const char kBC[];
-extern const char kBG[];
-extern const char kCA[];
-extern const char kRC[];
-extern const char kAC[];
-extern const char kI[];
-extern const char kRI[];
-extern const char kIX[];
+// ISO 32000-1:2008 spec, table 189.
+// Entries in an appearance characteristics dictionary.
+inline constexpr char kR[] = "R";
+inline constexpr char kBC[] = "BC";
+inline constexpr char kBG[] = "BG";
+inline constexpr char kCA[] = "CA";
+inline constexpr char kRC[] = "RC";
+inline constexpr char kAC[] = "AC";
+inline constexpr char kI[] = "I";
+inline constexpr char kRI[] = "RI";
+inline constexpr char kIX[] = "IX";
 
 }  // namespace appearance
 }  // namespace pdfium
diff --git a/constants/font_encodings.cpp b/constants/font_encodings.cpp
deleted file mode 100644
index 9b2d09f..0000000
--- a/constants/font_encodings.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2022 The PDFium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "constants/font_encodings.h"
-
-namespace pdfium::font_encodings {
-
-// ISO 32000-1:2008 spec, table D1.
-const char kMacRomanEncoding[] = "MacRomanEncoding";
-const char kWinAnsiEncoding[] = "WinAnsiEncoding";
-const char kPDFDocEncoding[] = "PDFDocEncoding";
-const char kMacExpertEncoding[] = "MacExpertEncoding";
-
-}  // namespace pdfium::font_encodings
diff --git a/constants/font_encodings.h b/constants/font_encodings.h
index aefd9f1..fe4657b 100644
--- a/constants/font_encodings.h
+++ b/constants/font_encodings.h
@@ -8,10 +8,11 @@
 namespace pdfium {
 namespace font_encodings {
 
-extern const char kMacRomanEncoding[];
-extern const char kWinAnsiEncoding[];
-extern const char kPDFDocEncoding[];
-extern const char kMacExpertEncoding[];
+// ISO 32000-1:2008 spec, table D1.
+inline constexpr char kMacRomanEncoding[] = "MacRomanEncoding";
+inline constexpr char kWinAnsiEncoding[] = "WinAnsiEncoding";
+inline constexpr char kPDFDocEncoding[] = "PDFDocEncoding";
+inline constexpr char kMacExpertEncoding[] = "MacExpertEncoding";
 
 }  // namespace font_encodings
 }  // namespace pdfium
diff --git a/constants/form_fields.cpp b/constants/form_fields.cpp
deleted file mode 100644
index 84531fb..0000000
--- a/constants/form_fields.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2021 The PDFium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "constants/form_fields.h"
-
-namespace pdfium::form_fields {
-
-// ISO 32000-1:2008 table 220.
-// Entries common to all field dictionaries.
-const char kFT[] = "FT";
-const char kParent[] = "Parent";
-const char kKids[] = "Kids";
-const char kT[] = "T";
-const char kTU[] = "TU";
-const char kTM[] = "TM";
-const char kFf[] = "Ff";
-const char kV[] = "V";
-const char kDV[] = "DV";
-const char kAA[] = "AA";
-
-// ISO 32000-1:2008 table 220.
-// Values for FT keyword.
-const char kBtn[] = "Btn";
-const char kTx[] = "Tx";
-const char kCh[] = "Ch";
-const char kSig[] = "Sig";
-
-// ISO 32000-1:2008 table 222.
-// Entries common to fields containing variable text.
-const char kDA[] = "DA";
-const char kQ[] = "Q";
-const char kDS[] = "DS";
-const char kRV[] = "RV";
-
-}  // namespace pdfium::form_fields
diff --git a/constants/form_fields.h b/constants/form_fields.h
index 129bbd3..2977b6d 100644
--- a/constants/form_fields.h
+++ b/constants/form_fields.h
@@ -8,26 +8,32 @@
 namespace pdfium {
 namespace form_fields {
 
-extern const char kFT[];
-extern const char kParent[];
-extern const char kKids[];
-extern const char kT[];
-extern const char kTU[];
-extern const char kTM[];
-extern const char kFf[];
-extern const char kV[];
-extern const char kDV[];
-extern const char kAA[];
+// ISO 32000-1:2008 table 220.
+// Entries common to all field dictionaries.
+inline constexpr char kFT[] = "FT";
+inline constexpr char kParent[] = "Parent";
+inline constexpr char kKids[] = "Kids";
+inline constexpr char kT[] = "T";
+inline constexpr char kTU[] = "TU";
+inline constexpr char kTM[] = "TM";
+inline constexpr char kFf[] = "Ff";
+inline constexpr char kV[] = "V";
+inline constexpr char kDV[] = "DV";
+inline constexpr char kAA[] = "AA";
 
-extern const char kBtn[];
-extern const char kTx[];
-extern const char kCh[];
-extern const char kSig[];
+// ISO 32000-1:2008 table 220.
+// Values for FT keyword.
+inline constexpr char kBtn[] = "Btn";
+inline constexpr char kTx[] = "Tx";
+inline constexpr char kCh[] = "Ch";
+inline constexpr char kSig[] = "Sig";
 
-extern const char kDA[];
-extern const char kQ[];
-extern const char kDS[];
-extern const char kRV[];
+// ISO 32000-1:2008 table 222.
+// Entries common to fields containing variable text.
+inline constexpr char kDA[] = "DA";
+inline constexpr char kQ[] = "Q";
+inline constexpr char kDS[] = "DS";
+inline constexpr char kRV[] = "RV";
 
 }  // namespace form_fields
 }  // namespace pdfium
diff --git a/constants/page_object.cpp b/constants/page_object.cpp
deleted file mode 100644
index 45d3020..0000000
--- a/constants/page_object.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2021 The PDFium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "constants/page_object.h"
-
-namespace pdfium::page_object {
-
-// PDF 1.7 spec, table 3.27.
-// Entries in a page object.
-const char kType[] = "Type";
-const char kParent[] = "Parent";
-const char kResources[] = "Resources";
-const char kMediaBox[] = "MediaBox";
-const char kCropBox[] = "CropBox";
-const char kBleedBox[] = "BleedBox";
-const char kTrimBox[] = "TrimBox";
-const char kArtBox[] = "ArtBox";
-const char kContents[] = "Contents";
-const char kRotate[] = "Rotate";
-
-}  // namespace pdfium::page_object
diff --git a/constants/page_object.h b/constants/page_object.h
index 6fb7d68..f5a7799 100644
--- a/constants/page_object.h
+++ b/constants/page_object.h
@@ -8,16 +8,18 @@
 namespace pdfium {
 namespace page_object {
 
-extern const char kType[];
-extern const char kParent[];
-extern const char kResources[];
-extern const char kMediaBox[];
-extern const char kCropBox[];
-extern const char kBleedBox[];
-extern const char kTrimBox[];
-extern const char kArtBox[];
-extern const char kContents[];
-extern const char kRotate[];
+// PDF 1.7 spec, table 3.27.
+// Entries in a page object.
+const char kType[] = "Type";
+const char kParent[] = "Parent";
+const char kResources[] = "Resources";
+const char kMediaBox[] = "MediaBox";
+const char kCropBox[] = "CropBox";
+const char kBleedBox[] = "BleedBox";
+const char kTrimBox[] = "TrimBox";
+const char kArtBox[] = "ArtBox";
+const char kContents[] = "Contents";
+const char kRotate[] = "Rotate";
 
 }  // namespace page_object
 }  // namespace pdfium
diff --git a/constants/stream_dict_common.cpp b/constants/stream_dict_common.cpp
deleted file mode 100644
index 42b0fd9..0000000
--- a/constants/stream_dict_common.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2021 The PDFium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "constants/stream_dict_common.h"
-
-namespace pdfium::stream {
-
-// PDF 1.7 spec, table 3.4.
-// Entries common to all stream dictionaries.
-//
-// TODO(https://crbug.com/pdfium/1049): Examine all usages of "Length",
-// "Filter", and "F".
-const char kLength[] = "Length";
-const char kFilter[] = "Filter";
-const char kDecodeParms[] = "DecodeParms";
-const char kF[] = "F";
-const char kDL[] = "DL";
-
-}  // namespace pdfium::stream
diff --git a/constants/stream_dict_common.h b/constants/stream_dict_common.h
index feb887a..87c7ad1 100644
--- a/constants/stream_dict_common.h
+++ b/constants/stream_dict_common.h
@@ -8,11 +8,16 @@
 namespace pdfium {
 namespace stream {
 
-extern const char kLength[];
-extern const char kFilter[];
-extern const char kDecodeParms[];
-extern const char kF[];
-extern const char kDL[];
+// PDF 1.7 spec, table 3.4.
+// Entries common to all stream dictionaries.
+//
+// TODO(https://crbug.com/pdfium/1049): Examine all usages of "Length",
+// "Filter", and "F".
+inline constexpr char kLength[] = "Length";
+inline constexpr char kFilter[] = "Filter";
+inline constexpr char kDecodeParms[] = "DecodeParms";
+inline constexpr char kF[] = "F";
+inline constexpr char kDL[] = "DL";
 
 }  // namespace stream
 }  // namespace pdfium
diff --git a/constants/transparency.cpp b/constants/transparency.cpp
deleted file mode 100644
index c25ae6f..0000000
--- a/constants/transparency.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2021 The PDFium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "constants/transparency.h"
-
-namespace pdfium::transparency {
-
-// PDF 1.7 spec, table 7.2.
-// Standard separable blend modes.
-const char kNormal[] = "Normal";
-const char kMultiply[] = "Multiply";
-const char kScreen[] = "Screen";
-const char kOverlay[] = "Overlay";
-const char kDarken[] = "Darken";
-const char kLighten[] = "Lighten";
-const char kColorDodge[] = "ColorDodge";
-const char kColorBurn[] = "ColorBurn";
-const char kHardLight[] = "HardLight";
-const char kSoftLight[] = "SoftLight";
-const char kDifference[] = "Difference";
-const char kExclusion[] = "Exclusion";
-
-// PDF 1.7 spec, table 7.3.
-// Standard nonseparable blend modes.
-const char kHue[] = "Hue";
-const char kSaturation[] = "Saturation";
-const char kColor[] = "Color";
-const char kLuminosity[] = "Luminosity";
-
-// PDF 1.7 spec, table 7.10.
-// Entries in a soft-mask dictionary.
-const char kSoftMaskSubType[] = "S";
-const char kAlpha[] = "Alpha";
-const char kG[] = "G";
-const char kBC[] = "BC";
-const char kTR[] = "TR";
-
-// PDF 1.7 spec, table 7.13.
-// Additional entries specific to a transparency group attributes dictionary.
-const char kGroupSubType[] = "S";
-const char kTransparency[] = "Transparency";
-const char kCS[] = "CS";
-const char kI[] = "I";
-
-}  // namespace pdfium::transparency
diff --git a/constants/transparency.h b/constants/transparency.h
index 21b22c4..86d2d45 100644
--- a/constants/transparency.h
+++ b/constants/transparency.h
@@ -8,34 +8,42 @@
 namespace pdfium {
 namespace transparency {
 
-extern const char kNormal[];
-extern const char kMultiply[];
-extern const char kScreen[];
-extern const char kOverlay[];
-extern const char kDarken[];
-extern const char kLighten[];
-extern const char kColorDodge[];
-extern const char kColorBurn[];
-extern const char kHardLight[];
-extern const char kSoftLight[];
-extern const char kDifference[];
-extern const char kExclusion[];
+// PDF 1.7 spec, table 7.2.
+// Standard separable blend modes.
+inline constexpr char kNormal[] = "Normal";
+inline constexpr char kMultiply[] = "Multiply";
+inline constexpr char kScreen[] = "Screen";
+inline constexpr char kOverlay[] = "Overlay";
+inline constexpr char kDarken[] = "Darken";
+inline constexpr char kLighten[] = "Lighten";
+inline constexpr char kColorDodge[] = "ColorDodge";
+inline constexpr char kColorBurn[] = "ColorBurn";
+inline constexpr char kHardLight[] = "HardLight";
+inline constexpr char kSoftLight[] = "SoftLight";
+inline constexpr char kDifference[] = "Difference";
+inline constexpr char kExclusion[] = "Exclusion";
 
-extern const char kHue[];
-extern const char kSaturation[];
-extern const char kColor[];
-extern const char kLuminosity[];
+// PDF 1.7 spec, table 7.3.
+// Standard nonseparable blend modes.
+inline constexpr char kHue[] = "Hue";
+inline constexpr char kSaturation[] = "Saturation";
+inline constexpr char kColor[] = "Color";
+inline constexpr char kLuminosity[] = "Luminosity";
 
-extern const char kSoftMaskSubType[];
-extern const char kAlpha[];
-extern const char kG[];
-extern const char kBC[];
-extern const char kTR[];
+// PDF 1.7 spec, table 7.10.
+// Entries in a soft-mask dictionary.
+inline constexpr char kSoftMaskSubType[] = "S";
+inline constexpr char kAlpha[] = "Alpha";
+inline constexpr char kG[] = "G";
+inline constexpr char kBC[] = "BC";
+inline constexpr char kTR[] = "TR";
 
-extern const char kGroupSubType[];
-extern const char kTransparency[];
-extern const char kCS[];
-extern const char kI[];
+// PDF 1.7 spec, table 7.13.
+// Additional entries specific to a transparency group attributes dictionary.
+inline constexpr char kGroupSubType[] = "S";
+inline constexpr char kTransparency[] = "Transparency";
+inline constexpr char kCS[] = "CS";
+inline constexpr char kI[] = "I";
 
 }  // namespace transparency
 }  // namespace pdfium