Fix retained argument TODOs, part 7.

Update CPDF_ContentMarkItem

Change-Id: I3e902db1a69153f0c59fcda1ca5a8dcac80b216c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/98619
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.cpp b/core/fpdfapi/page/cpdf_contentmarkitem.cpp
index 3d3ff16..296fac4 100644
--- a/core/fpdfapi/page/cpdf_contentmarkitem.cpp
+++ b/core/fpdfapi/page/cpdf_contentmarkitem.cpp
@@ -38,9 +38,9 @@
 }
 
 void CPDF_ContentMarkItem::SetPropertiesHolder(
-    CPDF_Dictionary* pHolder,
+    RetainPtr<CPDF_Dictionary> pHolder,
     const ByteString& property_name) {
   m_ParamType = kPropertiesDict;
-  m_pPropertiesHolder.Reset(pHolder);
+  m_pPropertiesHolder = std::move(pHolder);
   m_PropertyName = property_name;
 }
diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.h b/core/fpdfapi/page/cpdf_contentmarkitem.h
index d00458a..2e851cd 100644
--- a/core/fpdfapi/page/cpdf_contentmarkitem.h
+++ b/core/fpdfapi/page/cpdf_contentmarkitem.h
@@ -26,7 +26,7 @@
   const ByteString& GetPropertyName() const { return m_PropertyName; }
 
   void SetDirectDict(RetainPtr<CPDF_Dictionary> pDict);
-  void SetPropertiesHolder(CPDF_Dictionary* pHolder,
+  void SetPropertiesHolder(RetainPtr<CPDF_Dictionary> pHolder,
                            const ByteString& property_name);
 
  private:
diff --git a/core/fpdfapi/page/cpdf_contentmarks.cpp b/core/fpdfapi/page/cpdf_contentmarks.cpp
index 5ec6c55..c9fe287 100644
--- a/core/fpdfapi/page/cpdf_contentmarks.cpp
+++ b/core/fpdfapi/page/cpdf_contentmarks.cpp
@@ -48,18 +48,20 @@
   m_pMarkData->AddMark(std::move(name));
 }
 
-void CPDF_ContentMarks::AddMarkWithDirectDict(ByteString name,
-                                              CPDF_Dictionary* pDict) {
+void CPDF_ContentMarks::AddMarkWithDirectDict(
+    ByteString name,
+    RetainPtr<CPDF_Dictionary> pDict) {
   EnsureMarkDataExists();
-  m_pMarkData->AddMarkWithDirectDict(std::move(name), pDict);
+  m_pMarkData->AddMarkWithDirectDict(std::move(name), std::move(pDict));
 }
 
 void CPDF_ContentMarks::AddMarkWithPropertiesHolder(
     const ByteString& name,
-    CPDF_Dictionary* pDict,
+    RetainPtr<CPDF_Dictionary> pDict,
     const ByteString& property_name) {
   EnsureMarkDataExists();
-  m_pMarkData->AddMarkWithPropertiesHolder(name, pDict, property_name);
+  m_pMarkData->AddMarkWithPropertiesHolder(name, std::move(pDict),
+                                           property_name);
 }
 
 bool CPDF_ContentMarks::RemoveMark(CPDF_ContentMarkItem* pMarkItem) {
@@ -132,7 +134,7 @@
 
 void CPDF_ContentMarks::MarkData::AddMarkWithDirectDict(
     ByteString name,
-    CPDF_Dictionary* pDict) {
+    RetainPtr<CPDF_Dictionary> pDict) {
   auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(std::move(name));
   pItem->SetDirectDict(ToDictionary(pDict->Clone()));
   m_Marks.push_back(pItem);
@@ -140,10 +142,10 @@
 
 void CPDF_ContentMarks::MarkData::AddMarkWithPropertiesHolder(
     const ByteString& name,
-    CPDF_Dictionary* pDict,
+    RetainPtr<CPDF_Dictionary> pDict,
     const ByteString& property_name) {
   auto pItem = pdfium::MakeRetain<CPDF_ContentMarkItem>(name);
-  pItem->SetPropertiesHolder(pDict, property_name);
+  pItem->SetPropertiesHolder(std::move(pDict), property_name);
   m_Marks.push_back(pItem);
 }
 
diff --git a/core/fpdfapi/page/cpdf_contentmarks.h b/core/fpdfapi/page/cpdf_contentmarks.h
index 2715b85..cb56d4a 100644
--- a/core/fpdfapi/page/cpdf_contentmarks.h
+++ b/core/fpdfapi/page/cpdf_contentmarks.h
@@ -32,9 +32,9 @@
   const CPDF_ContentMarkItem* GetItem(size_t index) const;
 
   void AddMark(ByteString name);
-  void AddMarkWithDirectDict(ByteString name, CPDF_Dictionary* pDict);
+  void AddMarkWithDirectDict(ByteString name, RetainPtr<CPDF_Dictionary> pDict);
   void AddMarkWithPropertiesHolder(const ByteString& name,
-                                   CPDF_Dictionary* pDict,
+                                   RetainPtr<CPDF_Dictionary> pDict,
                                    const ByteString& property_name);
   bool RemoveMark(CPDF_ContentMarkItem* pMarkItem);
   size_t FindFirstDifference(const CPDF_ContentMarks* other) const;
@@ -53,9 +53,10 @@
 
     int GetMarkedContentID() const;
     void AddMark(ByteString name);
-    void AddMarkWithDirectDict(ByteString name, CPDF_Dictionary* pDict);
+    void AddMarkWithDirectDict(ByteString name,
+                               RetainPtr<CPDF_Dictionary> pDict);
     void AddMarkWithPropertiesHolder(const ByteString& name,
-                                     CPDF_Dictionary* pDict,
+                                     RetainPtr<CPDF_Dictionary> pDict,
                                      const ByteString& property_name);
     bool RemoveMark(CPDF_ContentMarkItem* pMarkItem);
 
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 89e8692..c55f124 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -328,7 +328,7 @@
   m_ParamCount = 0;
 }
 
-CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) {
+RetainPtr<CPDF_Object> CPDF_StreamContentParser::GetObject(uint32_t index) {
   if (index >= m_ParamCount) {
     return nullptr;
   }
@@ -343,15 +343,15 @@
         param.m_Number.IsInteger()
             ? pdfium::MakeRetain<CPDF_Number>(param.m_Number.GetSigned())
             : pdfium::MakeRetain<CPDF_Number>(param.m_Number.GetFloat());
-    return param.m_pObject.Get();
+    return param.m_pObject;
   }
   if (param.m_Type == ContentParam::Type::kName) {
     param.m_Type = ContentParam::Type::kObject;
     param.m_pObject = m_pDocument->New<CPDF_Name>(param.m_Name);
-    return param.m_pObject.Get();
+    return param.m_pObject;
   }
   if (param.m_Type == ContentParam::Type::kObject)
-    return param.m_pObject.Get();
+    return param.m_pObject;
 
   NOTREACHED();
   return nullptr;
@@ -576,7 +576,7 @@
 }
 
 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
-  CPDF_Object* pProperty = GetObject(0);
+  RetainPtr<CPDF_Object> pProperty = GetObject(0);
   if (!pProperty)
     return;
 
@@ -589,10 +589,11 @@
     RetainPtr<CPDF_Dictionary> pHolder = FindResourceHolder("Properties");
     if (!pHolder || !pHolder->GetDictFor(property_name))
       return;
-    // TODO(tsepez): pass retained argument.
-    new_marks->AddMarkWithPropertiesHolder(tag, pHolder.Get(), property_name);
+
+    new_marks->AddMarkWithPropertiesHolder(tag, std::move(pHolder),
+                                           property_name);
   } else if (pProperty->IsDictionary()) {
-    new_marks->AddMarkWithDirectDict(tag, pProperty->AsMutableDictionary());
+    new_marks->AddMarkWithDirectDict(tag, ToDictionary(pProperty));
   } else {
     return;
   }
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 5409163..b97bfc0 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -92,7 +92,7 @@
   void AddObjectParam(RetainPtr<CPDF_Object> pObj);
   int GetNextParamPos();
   void ClearAllParams();
-  CPDF_Object* GetObject(uint32_t index);
+  RetainPtr<CPDF_Object> GetObject(uint32_t index);
   ByteString GetString(uint32_t index) const;
   float GetNumber(uint32_t index) const;
   // Calls GetNumber() |count| times and returns the values in reverse order.