Remove CFX_PtrArray from xfa's combobox.h.

patch from issue 1665243003 at patchset 1 (http://crrev.com/1665243003#ps1)

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1669313002 .
diff --git a/xfa/include/fwl/lightwidget/combobox.h b/xfa/include/fwl/lightwidget/combobox.h
index 971c64b..db6db39 100644
--- a/xfa/include/fwl/lightwidget/combobox.h
+++ b/xfa/include/fwl/lightwidget/combobox.h
@@ -4,22 +4,28 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef _FWL_COMBOBOX_LIGHT_H
-#define _FWL_COMBOBOX_LIGHT_H
-class CFWL_Widget;
+#ifndef XFA_INCLUDE_FWL_LIGHTWIDGET_COMBOBOX_H_
+#define XFA_INCLUDE_FWL_LIGHTWIDGET_COMBOBOX_H_
+
+#include <memory>
+#include <vector>
+
+#include "xfa/include/fwl/basewidget/fwl_combobox.h"
+#include "xfa/include/fwl/lightwidget/widget.h"
+
 class CFWL_WidgetProperties;
 class IFWL_ComboBoxDP;
-class CFWL_ComboBox;
 class CFWL_ComboBoxDP;
 class CFWL_ComboBoxItem;
+
 class CFWL_ComboBox : public CFWL_Widget {
  public:
   static CFWL_ComboBox* Create();
   FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
   int32_t AddString(const CFX_WideStringC& wsText);
   int32_t AddString(const CFX_WideStringC& wsText, CFX_DIBitmap* pIcon);
-  int32_t RemoveAt(int32_t iIndex);
-  int32_t RemoveAll();
+  bool RemoveAt(int32_t iIndex);  // Returns false iff |iIndex| out of range.
+  void RemoveAll();
   int32_t CountItems();
   FWL_ERR GetTextByIndex(int32_t iIndex, CFX_WideString& wsText);
   int32_t GetCurSel();
@@ -113,12 +119,13 @@
                                       FX_DWORD dwCheckState);
     virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget);
 
-    CFX_PtrArray m_arrItem;
+    std::vector<std::unique_ptr<CFWL_ComboBoxItem>> m_ItemArray;
     FX_FLOAT m_fMaxListHeight;
     FX_FLOAT m_fItemHeight;
   };
   CFWL_ComboBoxDP m_comboBoxData;
 };
+
 class CFWL_ComboBoxItem {
  public:
   CFWL_ComboBoxItem() {
@@ -133,4 +140,5 @@
   CFX_RectF m_rtCheckBox;
   void* m_pData;
 };
-#endif
+
+#endif  // XFA_INCLUDE_FWL_LIGHTWIDGET_COMBOBOX_H_
diff --git a/xfa/src/fwl/src/lightwidget/combobox.cpp b/xfa/src/fwl/src/lightwidget/combobox.cpp
index eb5e12a..07556b7 100644
--- a/xfa/src/fwl/src/lightwidget/combobox.cpp
+++ b/xfa/src/fwl/src/lightwidget/combobox.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include <memory>
+#include <utility>
 
 #include "xfa/src/foxitlib.h"
 
@@ -28,25 +28,30 @@
   return FWL_ERR_Succeeded;
 }
 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
-  CFWL_ComboBoxItem* pItem = new CFWL_ComboBoxItem;
+  std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem);
   pItem->m_wsText = wsText;
   pItem->m_dwStyles = 0;
-  return m_comboBoxData.m_arrItem.Add(pItem);
+  m_comboBoxData.m_ItemArray.push_back(std::move(pItem));
+  return m_comboBoxData.m_ItemArray.size() - 1;
 }
 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText,
                                  CFX_DIBitmap* pIcon) {
-  CFWL_ComboBoxItem* pItem = new CFWL_ComboBoxItem;
+  std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem);
   pItem->m_wsText = wsText;
   pItem->m_dwStyles = 0;
   pItem->m_pDIB = pIcon;
-  return m_comboBoxData.m_arrItem.Add(pItem);
+  m_comboBoxData.m_ItemArray.push_back(std::move(pItem));
+  return m_comboBoxData.m_ItemArray.size() - 1;
 }
-int32_t CFWL_ComboBox::RemoveAt(int32_t iIndex) {
-  return m_comboBoxData.m_arrItem.RemoveAt(iIndex);
+bool CFWL_ComboBox::RemoveAt(int32_t iIndex) {
+  if (iIndex < 0 || iIndex >= m_comboBoxData.m_ItemArray.size())
+    return false;
+
+  m_comboBoxData.m_ItemArray.erase(m_comboBoxData.m_ItemArray.begin() + iIndex);
+  return true;
 }
-int32_t CFWL_ComboBox::RemoveAll() {
-  m_comboBoxData.m_arrItem.RemoveAll();
-  return 0;
+void CFWL_ComboBox::RemoveAll() {
+  m_comboBoxData.m_ItemArray.clear();
 }
 int32_t CFWL_ComboBox::CountItems() {
   return m_comboBoxData.CountItems(GetWidget());
@@ -234,32 +239,33 @@
   m_fItemHeight = 0;
   m_fMaxListHeight = 0;
 }
-CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {
-  int32_t nCount = m_arrItem.GetSize();
-  for (int32_t i = 0; i < nCount; i++) {
-    delete static_cast<CFWL_ComboBoxItem*>(m_arrItem[i]);
-  }
-  m_arrItem.RemoveAll();
-}
+CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {}
 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) {
-  return m_arrItem.GetSize();
+  return m_ItemArray.size();
 }
 FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget,
                                                       int32_t nIndex) {
-  int32_t iCount = m_arrItem.GetSize();
-  if (nIndex >= iCount || nIndex < 0) {
-    return NULL;
-  }
-  return (FWL_HLISTITEM)m_arrItem[nIndex];
+  return nIndex >= 0 && nIndex < m_ItemArray.size()
+             ? reinterpret_cast<FWL_HLISTITEM>(m_ItemArray[nIndex].get())
+             : nullptr;
 }
 int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget,
                                                      FWL_HLISTITEM hItem) {
-  return m_arrItem.Find(hItem);
+  auto it = std::find_if(
+      m_ItemArray.begin(), m_ItemArray.end(),
+      [hItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) {
+        return candidate.get() == reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
+      });
+  return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1;
 }
 FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget,
                                                      FWL_HLISTITEM hItem,
                                                      int32_t nIndex) {
-  return m_arrItem.SetAt(nIndex, hItem);
+  if (nIndex < 0 || nIndex >= m_ItemArray.size())
+    return FALSE;
+
+  m_ItemArray[nIndex].reset(reinterpret_cast<CFWL_ComboBoxItem*>(hItem));
+  return TRUE;
 }
 FX_DWORD CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget,
                                                        FWL_HLISTITEM hItem) {