Remove some redundant assertions in CFFL_ListBox.

Several callers to GetPWLListBox() assert the pointer passed in is
non-null, but internally GetPWLListBox() does that as well. So remove
those assertions and compact the code.

Also rename GetPWLListBox() to GetListBox(), to be consistent with
similar helper methods in other CFFL classes.

Change-Id: I8234fa7cc4fd1cb1b5cf419b71d4950faa0f606d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/60190
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 479d058..3d80255 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -84,7 +84,7 @@
 }
 
 bool CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
-  CPWL_ListBox* pListBox = GetPWLListBox(pPageView);
+  CPWL_ListBox* pListBox = GetListBox(pPageView);
   if (!pListBox)
     return false;
 
@@ -105,7 +105,7 @@
 }
 
 void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) {
-  CPWL_ListBox* pListBox = GetPWLListBox(pPageView);
+  CPWL_ListBox* pListBox = GetListBox(pPageView);
   if (!pListBox)
     return;
 
@@ -147,7 +147,7 @@
       if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceMultiSelect) {
         fa.sValue.clear();
       } else {
-        CPWL_ListBox* pListBox = GetPWLListBox(pPageView);
+        CPWL_ListBox* pListBox = GetListBox(pPageView);
         if (pListBox) {
           int32_t nCurSel = pListBox->GetCurSel();
           if (nCurSel >= 0)
@@ -171,9 +171,7 @@
 }
 
 void CFFL_ListBox::SaveState(CPDFSDK_PageView* pPageView) {
-  ASSERT(pPageView);
-
-  CPWL_ListBox* pListBox = GetPWLListBox(pPageView);
+  CPWL_ListBox* pListBox = GetListBox(pPageView);
   if (!pListBox)
     return;
 
@@ -184,7 +182,7 @@
 }
 
 void CFFL_ListBox::RestoreState(CPDFSDK_PageView* pPageView) {
-  CPWL_ListBox* pListBox = GetPWLListBox(pPageView);
+  CPWL_ListBox* pListBox = GetListBox(pPageView);
   if (!pListBox)
     return;
 
@@ -199,10 +197,7 @@
   if (index < 0 || index >= m_pWidget->CountOptions())
     return false;
 
-  CPDFSDK_PageView* pPageView = GetCurPageView(true);
-  ASSERT(pPageView);
-
-  CPWL_ListBox* pListBox = GetPWLListBox(pPageView);
+  CPWL_ListBox* pListBox = GetListBox(GetCurPageView(true));
   if (!pListBox)
     return false;
 
@@ -224,16 +219,10 @@
   if (index < 0 || index >= m_pWidget->CountOptions())
     return false;
 
-  CPDFSDK_PageView* pPageView = GetCurPageView(true);
-  ASSERT(pPageView);
-
-  CPWL_ListBox* pListBox = GetPWLListBox(pPageView);
-  if (!pListBox)
-    return false;
-
-  return pListBox->IsItemSelected(index);
+  CPWL_ListBox* pListBox = GetListBox(GetCurPageView(true));
+  return pListBox && pListBox->IsItemSelected(index);
 }
 
-CPWL_ListBox* CFFL_ListBox::GetPWLListBox(CPDFSDK_PageView* pPageView) {
+CPWL_ListBox* CFFL_ListBox::GetListBox(CPDFSDK_PageView* pPageView) {
   return static_cast<CPWL_ListBox*>(GetPWLWindow(pPageView, /*bNew=*/false));
 }
diff --git a/fpdfsdk/formfiller/cffl_listbox.h b/fpdfsdk/formfiller/cffl_listbox.h
index 5cc2485..04138e6 100644
--- a/fpdfsdk/formfiller/cffl_listbox.h
+++ b/fpdfsdk/formfiller/cffl_listbox.h
@@ -39,7 +39,7 @@
   bool IsIndexSelected(int index) override;
 
  private:
-  CPWL_ListBox* GetPWLListBox(CPDFSDK_PageView* pPageView);
+  CPWL_ListBox* GetListBox(CPDFSDK_PageView* pPageView);
 
   std::set<int> m_OriginSelections;
   std::vector<int> m_State;