Fix nits in CPDF_Pattern and related code.

- Mention enums are based on values in the PDF spec, so do not change.
- Remove a check that is never true.

Change-Id: I5c4af6a81b4643b62f1f0bf870f96eee405bf4fb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/54210
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 4c2ee21..f8124a8 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -365,10 +365,10 @@
       return nullptr;
 
     int type = pDict->GetIntegerFor("PatternType");
-    if (type == CPDF_Pattern::TILING) {
+    if (type == CPDF_Pattern::kTiling) {
       pPattern = pdfium::MakeUnique<CPDF_TilingPattern>(m_pPDFDoc.Get(),
                                                         pPatternObj, matrix);
-    } else if (type == CPDF_Pattern::SHADING) {
+    } else if (type == CPDF_Pattern::kShading) {
       pPattern = pdfium::MakeUnique<CPDF_ShadingPattern>(
           m_pPDFDoc.Get(), pPatternObj, false, matrix);
     } else {
diff --git a/core/fpdfapi/page/cpdf_pattern.cpp b/core/fpdfapi/page/cpdf_pattern.cpp
index c6d3c54..84e641a 100644
--- a/core/fpdfapi/page/cpdf_pattern.cpp
+++ b/core/fpdfapi/page/cpdf_pattern.cpp
@@ -11,9 +11,12 @@
 CPDF_Pattern::CPDF_Pattern(CPDF_Document* pDoc,
                            CPDF_Object* pObj,
                            const CFX_Matrix& parentMatrix)
-    : m_pDocument(pDoc), m_pPatternObj(pObj), m_ParentMatrix(parentMatrix) {}
+    : m_pDocument(pDoc), m_pPatternObj(pObj), m_ParentMatrix(parentMatrix) {
+  ASSERT(m_pDocument);
+  ASSERT(m_pPatternObj);
+}
 
-CPDF_Pattern::~CPDF_Pattern() {}
+CPDF_Pattern::~CPDF_Pattern() = default;
 
 void CPDF_Pattern::SetPatternToFormMatrix() {
   const CPDF_Dictionary* pDict = pattern_obj()->GetDict();
diff --git a/core/fpdfapi/page/cpdf_pattern.h b/core/fpdfapi/page/cpdf_pattern.h
index 2fc6b8e..474575c 100644
--- a/core/fpdfapi/page/cpdf_pattern.h
+++ b/core/fpdfapi/page/cpdf_pattern.h
@@ -20,7 +20,8 @@
 
 class CPDF_Pattern {
  public:
-  enum PatternType { TILING = 1, SHADING };
+  // Values used in PDFs. Do not change.
+  enum PatternType { kTiling = 1, kShading = 2 };
 
   virtual ~CPDF_Pattern();
 
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h
index a59ee51..cce1e04 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.h
+++ b/core/fpdfapi/page/cpdf_shadingpattern.h
@@ -15,6 +15,8 @@
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/unowned_ptr.h"
 
+// Values used in PDFs except for |kInvalidShading| and |kMaxShading|.
+// Do not change.
 enum ShadingType {
   kInvalidShading = 0,
   kFunctionBasedShading = 1,
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index f6655a6..9bf9a86 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -23,7 +23,7 @@
   SetPatternToFormMatrix();
 }
 
-CPDF_TilingPattern::~CPDF_TilingPattern() {}
+CPDF_TilingPattern::~CPDF_TilingPattern() = default;
 
 CPDF_TilingPattern* CPDF_TilingPattern::AsTilingPattern() {
   return this;
@@ -35,9 +35,6 @@
 
 std::unique_ptr<CPDF_Form> CPDF_TilingPattern::Load(CPDF_PageObject* pPageObj) {
   const CPDF_Dictionary* pDict = pattern_obj()->GetDict();
-  if (!pDict)
-    return nullptr;
-
   m_bColored = pDict->GetIntegerFor("PaintType") == 1;
   m_XStep = static_cast<float>(fabs(pDict->GetNumberFor("XStep")));
   m_YStep = static_cast<float>(fabs(pDict->GetNumberFor("YStep")));