Simplify CFX_CSSValueList.

Just return its vector member by const-ref, instead of providing an
accessor to individual elements. This way, callers can take advantage
of standard STL operations on vectors.

Change-Id: Ie5e85798f2a4dbc1ee58cc9a743b0808c6360862
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/70792
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/css/cfx_csscomputedstyle.cpp b/core/fxcrt/css/cfx_csscomputedstyle.cpp
index b4a84aa..8c37321 100644
--- a/core/fxcrt/css/cfx_csscomputedstyle.cpp
+++ b/core/fxcrt/css/cfx_csscomputedstyle.cpp
@@ -27,12 +27,12 @@
 
 size_t CFX_CSSComputedStyle::CountFontFamilies() const {
   return m_InheritedData.m_pFontFamily
-             ? m_InheritedData.m_pFontFamily->CountValues()
+             ? m_InheritedData.m_pFontFamily->values().size()
              : 0;
 }
 
 const WideString CFX_CSSComputedStyle::GetFontFamily(size_t index) const {
-  return m_InheritedData.m_pFontFamily->GetValue(index)
+  return m_InheritedData.m_pFontFamily->values()[index]
       .As<CFX_CSSStringValue>()
       ->Value();
 }
diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp
index 74ec374..bf8b3a7 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.cpp
+++ b/core/fxcrt/css/cfx_cssstyleselector.cpp
@@ -392,7 +392,7 @@
     }
   } else if (pValue->GetType() == CFX_CSSPrimitiveType::List) {
     RetainPtr<CFX_CSSValueList> pList = pValue.As<CFX_CSSValueList>();
-    if (pList->CountValues() > 0) {
+    if (!pList->values().empty()) {
       switch (eProperty) {
         case CFX_CSSProperty::FontFamily:
           pComputedStyle->m_InheritedData.m_pFontFamily = pList;
@@ -560,9 +560,9 @@
 uint32_t CFX_CSSStyleSelector::ToTextDecoration(
     const RetainPtr<CFX_CSSValueList>& pValue) {
   uint32_t dwDecoration = 0;
-  size_t count = pValue->CountValues();
-  for (size_t i = 0; i < count; ++i) {
-    const RetainPtr<CFX_CSSValue> pVal = pValue->GetValue(count - i - 1);
+  for (auto it = pValue->values().rbegin(); it != pValue->values().rend();
+       ++it) {
+    const RetainPtr<CFX_CSSValue> pVal = *it;
     if (pVal->GetType() != CFX_CSSPrimitiveType::Enum)
       continue;
 
diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
index 6c9df1f..038495e 100644
--- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
@@ -74,19 +74,20 @@
   }
 
   void VerifyList(CFX_CSSProperty prop,
-                  std::vector<CFX_CSSPropertyValue> values) {
+                  std::vector<CFX_CSSPropertyValue> expected_values) {
     ASSERT(decl_);
 
     bool important;
     RetainPtr<CFX_CSSValueList> list =
         decl_->GetProperty(prop, &important).As<CFX_CSSValueList>();
     ASSERT_TRUE(list);
-    EXPECT_EQ(list->CountValues(), values.size());
+    const std::vector<RetainPtr<CFX_CSSValue>>& values = list->values();
+    ASSERT_EQ(values.size(), expected_values.size());
 
-    for (size_t i = 0; i < values.size(); i++) {
-      RetainPtr<CFX_CSSValue> val = list->GetValue(i);
+    for (size_t i = 0; i < expected_values.size(); ++i) {
+      const auto& val = values[i];
       EXPECT_EQ(val->GetType(), CFX_CSSPrimitiveType::Enum);
-      EXPECT_EQ(val.As<CFX_CSSEnumValue>()->Value(), values[i]);
+      EXPECT_EQ(val.As<CFX_CSSEnumValue>()->Value(), expected_values[i]);
     }
   }
 
diff --git a/core/fxcrt/css/cfx_cssvaluelist.cpp b/core/fxcrt/css/cfx_cssvaluelist.cpp
index 7118fec..529d387 100644
--- a/core/fxcrt/css/cfx_cssvaluelist.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelist.cpp
@@ -11,14 +11,6 @@
 #include "core/fxcrt/css/cfx_css.h"
 
 CFX_CSSValueList::CFX_CSSValueList(std::vector<RetainPtr<CFX_CSSValue>>& list)
-    : CFX_CSSValue(CFX_CSSPrimitiveType::List), m_ppList(std::move(list)) {}
+    : CFX_CSSValue(CFX_CSSPrimitiveType::List), list_(std::move(list)) {}
 
 CFX_CSSValueList::~CFX_CSSValueList() = default;
-
-size_t CFX_CSSValueList::CountValues() const {
-  return m_ppList.size();
-}
-
-RetainPtr<CFX_CSSValue> CFX_CSSValueList::GetValue(size_t index) const {
-  return m_ppList[index];
-}
diff --git a/core/fxcrt/css/cfx_cssvaluelist.h b/core/fxcrt/css/cfx_cssvaluelist.h
index 79de9a4..328b7d2 100644
--- a/core/fxcrt/css/cfx_cssvaluelist.h
+++ b/core/fxcrt/css/cfx_cssvaluelist.h
@@ -16,11 +16,10 @@
   explicit CFX_CSSValueList(std::vector<RetainPtr<CFX_CSSValue>>& list);
   ~CFX_CSSValueList() override;
 
-  size_t CountValues() const;
-  RetainPtr<CFX_CSSValue> GetValue(size_t index) const;
+  const std::vector<RetainPtr<CFX_CSSValue>>& values() const { return list_; }
 
  private:
-  std::vector<RetainPtr<CFX_CSSValue>> m_ppList;
+  std::vector<RetainPtr<CFX_CSSValue>> list_;
 };
 
 #endif  // CORE_FXCRT_CSS_CFX_CSSVALUELIST_H_