Cleanup IOn* methods and CPWL_CBEdit

This CL removes various IOn* methods and consolidates code where
possible. The CPWL_CBEdit class is also removed as it was a subclass
of CPWL_Edit which added no extra functionality.

Change-Id: Ifac579ab252b7ca64f8c9b3caeac443683a39c58
Reviewed-on: https://pdfium-review.googlesource.com/7279
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
index ace59a8..660f8cd 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
@@ -278,7 +278,7 @@
   if (m_pEdit)
     return;
 
-  m_pEdit = new CPWL_CBEdit();
+  m_pEdit = new CPWL_Edit();
   m_pEdit->AttachFFLData(m_pFormFiller.Get());
 
   PWL_CREATEPARAM ecp = cp;
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.h b/fpdfsdk/pdfwindow/cpwl_combo_box.h
index 15915e6..25f0886 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.h
@@ -14,12 +14,6 @@
 #include "fpdfsdk/pdfwindow/cpwl_list_box.h"
 #include "fpdfsdk/pdfwindow/cpwl_wnd.h"
 
-class CPWL_CBEdit : public CPWL_Edit {
- public:
-  CPWL_CBEdit() {}
-  ~CPWL_CBEdit() override {}
-};
-
 class CPWL_CBListBox : public CPWL_ListBox {
  public:
   CPWL_CBListBox() {}
@@ -93,7 +87,7 @@
   void CreateListBox(const PWL_CREATEPARAM& cp);
   void SetPopup(bool bPopup);
 
-  CFX_UnownedPtr<CPWL_CBEdit> m_pEdit;
+  CFX_UnownedPtr<CPWL_Edit> m_pEdit;
   CFX_UnownedPtr<CPWL_CBButton> m_pButton;
   CFX_UnownedPtr<CPWL_CBListBox> m_pList;
   CFX_FloatRect m_rcOldWindow;
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.cpp b/fpdfsdk/pdfwindow/cpwl_edit.cpp
index 4ad1076..de21dac 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit.cpp
@@ -451,7 +451,12 @@
 }
 
 void CPWL_Edit::OnKillFocus() {
-  ShowVScrollBar(false);
+  CPWL_ScrollBar* pScroll = GetVScrollBar();
+  if (pScroll && pScroll->IsVisible()) {
+    pScroll->SetVisible(false);
+    Move(m_rcOldWindow, true, true);
+  }
+
   m_pEdit->SelectNone();
   SetCaret(false, CFX_PointF(), CFX_PointF());
   SetCharSet(FX_CHARSET_ANSI);
@@ -569,30 +574,9 @@
   return CFX_FloatRect();
 }
 
-void CPWL_Edit::ShowVScrollBar(bool bShow) {
-  if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
-    if (bShow) {
-      if (!pScroll->IsVisible()) {
-        pScroll->SetVisible(true);
-        CFX_FloatRect rcWindow = GetWindowRect();
-        m_rcOldWindow = rcWindow;
-        rcWindow.right += PWL_SCROLLBAR_WIDTH;
-        Move(rcWindow, true, true);
-      }
-    } else {
-      if (pScroll->IsVisible()) {
-        pScroll->SetVisible(false);
-        Move(m_rcOldWindow, true, true);
-      }
-    }
-  }
-}
-
 bool CPWL_Edit::IsVScrollBarVisible() const {
-  if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
+  if (CPWL_ScrollBar* pScroll = GetVScrollBar())
     return pScroll->IsVisible();
-  }
-
   return false;
 }
 
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.h b/fpdfsdk/pdfwindow/cpwl_edit.h
index 31296f6..8d549b5 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.h
+++ b/fpdfsdk/pdfwindow/cpwl_edit.h
@@ -113,7 +113,6 @@
 
  private:
   CPVT_WordRange GetSelectWordRange() const;
-  virtual void ShowVScrollBar(bool bShow);
   bool IsVScrollBarVisible() const;
   void SetParamByFlag();
 
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
index 59879bb..ccc214a 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.cpp
@@ -299,8 +299,7 @@
   if (bVisible)
     GetCaretInfo(&ptHead, &ptFoot);
 
-  CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
-  IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp);
+  SetCaret(bVisible, ptHead, ptFoot);
 }
 
 void CPWL_EditCtrl::GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const {
@@ -367,8 +366,6 @@
 
 void CPWL_EditCtrl::CutText() {}
 
-void CPWL_EditCtrl::ShowVScrollBar(bool bShow) {}
-
 void CPWL_EditCtrl::InsertWord(uint16_t word, int32_t nCharset) {
   if (!IsReadOnly())
     m_pEdit->InsertWord(word, nCharset);
@@ -407,43 +404,6 @@
     m_pEdit->Undo();
 }
 
-void CPWL_EditCtrl::IOnSetScrollInfoY(float fPlateMin,
-                                      float fPlateMax,
-                                      float fContentMin,
-                                      float fContentMax,
-                                      float fSmallStep,
-                                      float fBigStep) {
-  PWL_SCROLL_INFO Info;
-  Info.fPlateWidth = fPlateMax - fPlateMin;
-  Info.fContentMin = fContentMin;
-  Info.fContentMax = fContentMax;
-  Info.fSmallStep = fSmallStep;
-  Info.fBigStep = fBigStep;
-  SetScrollInfo(Info);
-
-  if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
-      IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
-    ShowVScrollBar(false);
-  } else {
-    ShowVScrollBar(true);
-  }
-}
-
-void CPWL_EditCtrl::IOnSetScrollPosY(float fy) {
-  SetScrollPosition(fy);
-}
-
-void CPWL_EditCtrl::IOnSetCaret(bool bVisible,
-                                const CFX_PointF& ptHead,
-                                const CFX_PointF& ptFoot,
-                                const CPVT_WordPlace& place) {
-  SetCaret(bVisible, ptHead, ptFoot);
-}
-
-void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) {
-  InvalidateRect(pRect);
-}
-
 int32_t CPWL_EditCtrl::GetCharSet() const {
   return m_nCharSet < 0 ? FX_CHARSET_Default : m_nCharSet;
 }
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
index f81def6..454e579 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
+++ b/fpdfsdk/pdfwindow/cpwl_edit_ctrl.h
@@ -62,24 +62,14 @@
   void SetCursor() override;
   CFX_WideString GetSelectedText() override;
 
-  void IOnSetScrollInfoY(float fPlateMin,
-                         float fPlateMax,
-                         float fContentMin,
-                         float fContentMax,
-                         float fSmallStep,
-                         float fBigStep);
-  void IOnSetScrollPosY(float fy);
-  void IOnSetCaret(bool bVisible,
-                   const CFX_PointF& ptHead,
-                   const CFX_PointF& ptFoot,
-                   const CPVT_WordPlace& place);
-  void IOnInvalidateRect(CFX_FloatRect* pRect);
+  void SetCaret(bool bVisible,
+                const CFX_PointF& ptHead,
+                const CFX_PointF& ptFoot);
 
  protected:
   void CopyText();
   void PasteText();
   void CutText();
-  void ShowVScrollBar(bool bShow);
   void InsertWord(uint16_t word, int32_t nCharset);
   void InsertReturn();
 
@@ -89,9 +79,6 @@
   void Backspace();
 
   void GetCaretInfo(CFX_PointF* ptHead, CFX_PointF* ptFoot) const;
-  void SetCaret(bool bVisible,
-                const CFX_PointF& ptHead,
-                const CFX_PointF& ptFoot);
 
   void SetEditCaret(bool bVisible);
 
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.h b/fpdfsdk/pdfwindow/cpwl_list_box.h
index f1bfea7..d97f5ae 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.h
@@ -35,11 +35,6 @@
   void IOnSetScrollPosY(float fy);
   void IOnInvalidateRect(CFX_FloatRect* pRect);
 
-  void IOnSetCaret(bool bVisible,
-                   const CFX_PointF& ptHead,
-                   const CFX_PointF& ptFoot,
-                   const CPVT_WordPlace& place);
-
  private:
   CFX_UnownedPtr<CPWL_ListBox> m_pList;
 };