Remove unused IconElement::IconStream.

Follow up to https://pdfium-review.googlesource.com/c/2829/

Change-Id: Ic743a5931f743c3e0e3f24246dca768cec09be4f
Reviewed-on: https://pdfium-review.googlesource.com/2843
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 6928a06..a45b8b9 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -6,6 +6,7 @@
 
 #include "fpdfsdk/javascript/Document.h"
 
+#include <algorithm>
 #include <utility>
 #include <vector>
 
@@ -1215,14 +1216,12 @@
     return false;
   }
 
-  CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject(pRuntime)->GetEmbedObject();
-  if (!pEmbedObj) {
+  if (!params[1].ToCJSObject(pRuntime)->GetEmbedObject()) {
     sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
     return false;
   }
 
-  m_Icons.push_back(pdfium::MakeUnique<IconElement>(
-      swIconName, static_cast<Icon*>(pEmbedObj)));
+  m_IconNames.push_back(swIconName);
   return true;
 }
 
@@ -1233,14 +1232,14 @@
     sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
     return false;
   }
-  if (m_Icons.empty()) {
+  if (m_IconNames.empty()) {
     vp.GetJSValue()->SetNull(pRuntime);
     return true;
   }
 
   CJS_Array Icons;
   int i = 0;
-  for (const auto& pIconElement : m_Icons) {
+  for (const auto& name : m_IconNames) {
     v8::Local<v8::Object> pObj =
         pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
     if (pObj.IsEmpty())
@@ -1249,7 +1248,7 @@
     CJS_Icon* pJS_Icon =
         static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
     Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
-    pIcon->SetIconName(pIconElement->IconName);
+    pIcon->SetIconName(name);
     Icons.SetElement(pRuntime, i++, CJS_Value(pRuntime, pJS_Icon));
   }
 
@@ -1266,28 +1265,21 @@
     return false;
   }
 
-  if (m_Icons.empty())
+  CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime);
+  auto it = std::find(m_IconNames.begin(), m_IconNames.end(), swIconName);
+  if (it == m_IconNames.end())
     return false;
 
-  CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime);
-  for (const auto& pIconElement : m_Icons) {
-    if (pIconElement->IconName != swIconName)
-      continue;
+  v8::Local<v8::Object> pObj =
+      pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
+  if (pObj.IsEmpty())
+    return false;
 
-    v8::Local<v8::Object> pObj =
-        pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
-    if (pObj.IsEmpty())
-      return false;
-
-    CJS_Icon* pJS_Icon =
-        static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
-    Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
-    pIcon->SetIconName(swIconName);
-    vRet = CJS_Value(pRuntime, pJS_Icon);
-    return true;
-  }
-
-  return false;
+  CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
+  Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
+  pIcon->SetIconName(*it);
+  vRet = CJS_Value(pRuntime, pJS_Icon);
+  return true;
 }
 
 bool Document::removeIcon(CJS_Runtime* pRuntime,
diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h
index 661307e..91ca778 100644
--- a/fpdfsdk/javascript/Document.h
+++ b/fpdfsdk/javascript/Document.h
@@ -41,20 +41,9 @@
   DECLARE_JS_CLASS();
 };
 
-class Icon;
-class Field;
-
-struct IconElement {
-  IconElement(const CFX_WideString& name, Icon* stream)
-      : IconName(name), IconStream(stream) {}
-
-  const CFX_WideString IconName;
-  Icon* const IconStream;
-};
-
-struct CJS_DelayData;
-struct CJS_DelayAnnot;
 struct CJS_AnnotObj;
+struct CJS_DelayAnnot;
+struct CJS_DelayData;
 
 class Document : public CJS_EmbedObj {
  public:
@@ -318,7 +307,8 @@
   CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
   CFX_WideString m_cwBaseURL;
   std::list<std::unique_ptr<CJS_DelayData>> m_DelayData;
-  std::list<std::unique_ptr<IconElement>> m_Icons;  // For iterator stability.
+  // Needs to be a std::list for iterator stability.
+  std::list<CFX_WideString> m_IconNames;
   bool m_bDelay;
 };