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/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 863486b..82f8247 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -30,6 +30,7 @@
 #include "fpdfsdk/fxedit/fx_edit.h"
 #include "fpdfsdk/pdfwindow/cpwl_edit.h"
 #include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h"
+#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
 #include "third_party/base/ptr_util.h"
 #include "third_party/base/stl_util.h"
 
@@ -1226,18 +1227,24 @@
 }
 
 void CFX_Edit::SetScrollInfo() {
-  if (m_pNotify) {
-    CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
-    CFX_FloatRect rcContent = m_pVT->GetContentRect();
+  if (!m_pNotify)
+    return;
 
-    if (!m_bNotifyFlag) {
-      CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
-      m_bNotifyFlag = true;
-      m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
-                                   rcContent.bottom, rcContent.top,
-                                   rcPlate.Height() / 3, rcPlate.Height());
-    }
-  }
+  CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
+  CFX_FloatRect rcContent = m_pVT->GetContentRect();
+  if (m_bNotifyFlag)
+    return;
+
+  CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
+  m_bNotifyFlag = true;
+
+  PWL_SCROLL_INFO Info;
+  Info.fPlateWidth = rcPlate.top - rcPlate.bottom;
+  Info.fContentMin = rcContent.bottom;
+  Info.fContentMax = rcContent.top;
+  Info.fSmallStep = rcPlate.Height() / 3;
+  Info.fBigStep = rcPlate.Height();
+  m_pNotify->SetScrollInfo(Info);
 }
 
 void CFX_Edit::SetScrollPosX(float fx) {
@@ -1265,7 +1272,7 @@
         if (!m_bNotifyFlag) {
           CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
           m_bNotifyFlag = true;
-          m_pNotify->IOnSetScrollPosY(fy);
+          m_pNotify->SetScrollPosition(fy);
         }
       }
     }
@@ -1377,7 +1384,7 @@
         m_bNotifyFlag = true;
         if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) {
           for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++)
-            m_pNotify->IOnInvalidateRect(pRects->GetAt(i));
+            m_pNotify->InvalidateRect(pRects->GetAt(i));
         }
       }
     }
@@ -1445,7 +1452,7 @@
           CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
           m_bNotifyFlag = true;
           CFX_FloatRect rcRefresh = VTToEdit(rcWord);
-          m_pNotify->IOnInvalidateRect(&rcRefresh);
+          m_pNotify->InvalidateRect(&rcRefresh);
         }
       }
     } else {
@@ -1459,7 +1466,7 @@
           CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
           m_bNotifyFlag = true;
           CFX_FloatRect rcRefresh = VTToEdit(rcLine);
-          m_pNotify->IOnInvalidateRect(&rcRefresh);
+          m_pNotify->InvalidateRect(&rcRefresh);
         }
       }
 
@@ -1497,8 +1504,8 @@
 
       CFX_AutoRestorer<bool> restorer(&m_bNotifyFlag);
       m_bNotifyFlag = true;
-      m_pNotify->IOnSetCaret(m_SelState.IsEmpty(), VTToEdit(ptHead),
-                             VTToEdit(ptFoot), m_wpCaret);
+      m_pNotify->SetCaret(m_SelState.IsEmpty(), VTToEdit(ptHead),
+                          VTToEdit(ptFoot));
     }
   }
 }
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;
 };