Cleanup CFX_SystemHandler.

This CL cleans up signatures and code in CFX_SystemHandler.

Review-Url: https://codereview.chromium.org/2341693003
diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp
index 784ed4e..08d9743 100644
--- a/fpdfsdk/cfx_systemhandler.cpp
+++ b/fpdfsdk/cfx_systemhandler.cpp
@@ -17,6 +17,7 @@
 #include "fpdfsdk/include/cpdfsdk_document.h"
 #include "fpdfsdk/include/cpdfsdk_environment.h"
 #include "fpdfsdk/include/cpdfsdk_pageview.h"
+#include "fpdfsdk/include/cpdfsdk_widget.h"
 
 namespace {
 
@@ -34,42 +35,43 @@
 
 }  // namespace
 
-void CFX_SystemHandler::SetCursor(int32_t nCursorType) {
-  m_pEnv->SetCursor(nCursorType);
-}
-
-void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) {
-  CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
-  CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
-  UnderlyingPageType* pPage = pSDKAnnot->GetUnderlyingPage();
+void CFX_SystemHandler::InvalidateRect(CPDFSDK_Widget* widget, FX_RECT rect) {
+  CPDFSDK_PageView* pPageView = widget->GetPageView();
+  UnderlyingPageType* pPage = widget->GetUnderlyingPage();
   if (!pPage || !pPageView)
     return;
 
   CFX_Matrix page2device;
   pPageView->GetCurrentMatrix(page2device);
+
   CFX_Matrix device2page;
   device2page.SetReverse(page2device);
-  FX_FLOAT left, top, right, bottom;
-  device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
-  device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right,
-                        bottom);
+
+  FX_FLOAT left;
+  FX_FLOAT top;
+  FX_FLOAT right;
+  FX_FLOAT bottom;
+  device2page.Transform(static_cast<FX_FLOAT>(rect.left),
+                        static_cast<FX_FLOAT>(rect.top), left, top);
+  device2page.Transform(static_cast<FX_FLOAT>(rect.right),
+                        static_cast<FX_FLOAT>(rect.bottom), right, bottom);
   CFX_FloatRect rcPDF(left, bottom, right, top);
   rcPDF.Normalize();
 
   m_pEnv->Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, rcPDF.bottom);
 }
 
-void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller,
+void CFX_SystemHandler::OutputSelectedRect(CFFL_FormFiller* pFormFiller,
                                            CFX_FloatRect& rect) {
-  CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller;
-  if (!pFFL)
+  if (!pFormFiller)
     return;
 
   CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom);
   CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top);
-  CFX_FloatPoint ptA = pFFL->PWLtoFFL(leftbottom);
-  CFX_FloatPoint ptB = pFFL->PWLtoFFL(righttop);
-  CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
+  CFX_FloatPoint ptA = pFormFiller->PWLtoFFL(leftbottom);
+  CFX_FloatPoint ptB = pFormFiller->PWLtoFFL(righttop);
+
+  CPDFSDK_Annot* pAnnot = pFormFiller->GetSDKAnnot();
   UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage();
   ASSERT(pPage);
 
@@ -77,12 +79,15 @@
 }
 
 bool CFX_SystemHandler::IsSelectionImplemented() const {
-  if (m_pEnv) {
-    FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
-    if (pInfo && pInfo->FFI_OutputSelectedRect)
-      return true;
-  }
-  return false;
+  if (!m_pEnv)
+    return false;
+
+  FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
+  return pInfo && pInfo->FFI_OutputSelectedRect;
+}
+
+void CFX_SystemHandler::SetCursor(int32_t nCursorType) {
+  m_pEnv->SetCursor(nCursorType);
 }
 
 bool CFX_SystemHandler::FindNativeTrueTypeFont(CFX_ByteString sFontFaceName) {
@@ -101,7 +106,6 @@
     if (font.Compare(sFontFaceName.AsStringC()))
       return true;
   }
-
   return false;
 }
 
@@ -126,10 +130,6 @@
   m_pEnv->KillTimer(nID);
 }
 
-FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() {
-  return m_pEnv->GetLocalTime();
-}
-
 bool CFX_SystemHandler::IsSHIFTKeyDown(uint32_t nFlag) const {
   return !!m_pEnv->IsSHIFTKeyDown(nFlag);
 }
diff --git a/fpdfsdk/cfx_systemhandler.h b/fpdfsdk/cfx_systemhandler.h
index a1c277d..5f8a871 100644
--- a/fpdfsdk/cfx_systemhandler.h
+++ b/fpdfsdk/cfx_systemhandler.h
@@ -10,8 +10,6 @@
 #include "core/fxcrt/include/fx_coordinates.h"
 #include "core/fxcrt/include/fx_system.h"
 
-using FX_HWND = void*;
-using FX_HMENU = void*;
 using TimerCallback = void (*)(int32_t idEvent);
 
 struct FX_SYSTEMTIME {
@@ -43,17 +41,19 @@
 #define FXCT_HBEAM 4
 #define FXCT_HAND 5
 
+class CFFL_FormFiller;
 class CPDF_Document;
 class CPDF_Font;
 class CPDFSDK_Environment;
+class CPDFSDK_Widget;
 
 class CFX_SystemHandler {
  public:
   explicit CFX_SystemHandler(CPDFSDK_Environment* pEnv) : m_pEnv(pEnv) {}
   ~CFX_SystemHandler() {}
 
-  void InvalidateRect(FX_HWND hWnd, FX_RECT rect);
-  void OutputSelectedRect(void* pFormFiller, CFX_FloatRect& rect);
+  void InvalidateRect(CPDFSDK_Widget* widget, FX_RECT rect);
+  void OutputSelectedRect(CFFL_FormFiller* pFormFiller, CFX_FloatRect& rect);
   bool IsSelectionImplemented() const;
 
   void SetCursor(int32_t nCursorType);
@@ -62,14 +62,14 @@
   CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc,
                                         CFX_ByteString sFontFaceName,
                                         uint8_t nCharset);
+
   int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc);
   void KillTimer(int32_t nID);
+
   bool IsSHIFTKeyDown(uint32_t nFlag) const;
   bool IsCTRLKeyDown(uint32_t nFlag) const;
   bool IsALTKeyDown(uint32_t nFlag) const;
 
-  FX_SYSTEMTIME GetLocalTime();
-
  private:
   CPDFSDK_Environment* const m_pEnv;
 };
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index f91a1f4..e2f5be1 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -367,7 +367,7 @@
     }
   } else {
     PWL_CREATEPARAM cp = GetCreateParam();
-    cp.hAttachedWnd = (FX_HWND)m_pWidget;
+    cp.pAttachedWidget = m_pWidget;
 
     CFFL_PrivateData* pPrivateData = new CFFL_PrivateData;
     pPrivateData->pWidget = m_pWidget;
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index f4350f3..4967961 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -820,7 +820,7 @@
                         const CFX_FloatPoint& ptOffset,
                         const CPVT_WordRange* pRange,
                         CFX_SystemHandler* pSystemHandler,
-                        void* pFFLData) {
+                        CFFL_FormFiller* pFFLData) {
   const bool bContinuous =
       pEdit->GetCharArray() == 0 && pEdit->GetCharSpace() <= 0.0f;
   uint16_t SubWord = pEdit->GetPasswordChar();
diff --git a/fpdfsdk/fxedit/include/fxet_edit.h b/fpdfsdk/fxedit/include/fxet_edit.h
index c1b0000..22db613 100644
--- a/fpdfsdk/fxedit/include/fxet_edit.h
+++ b/fpdfsdk/fxedit/include/fxet_edit.h
@@ -13,15 +13,17 @@
 #include "core/fpdfdoc/include/cpvt_wordprops.h"
 #include "fpdfsdk/fxedit/include/fx_edit.h"
 
-class CPDF_PageObjectHolder;
-class CPDF_TextObject;
-class CPWL_Edit;
-class CPWL_EditCtrl;
+class CFFL_FormFiller;
 class CFX_Edit;
 class CFX_Edit_Iterator;
 class CFX_Edit_Provider;
 class CFX_RenderDevice;
 class CFX_SystemHandler;
+class CPDF_PageObjectHolder;
+class CPDF_TextObject;
+class CPWL_Edit;
+class CPWL_EditCtrl;
+
 class IFX_Edit_UndoItem;
 
 struct CFX_Edit_LineRect {
@@ -332,7 +334,7 @@
                        const CFX_FloatPoint& ptOffset,
                        const CPVT_WordRange* pRange,
                        CFX_SystemHandler* pSystemHandler,
-                       void* pFFLData);
+                       CFFL_FormFiller* pFFLData);
   static void GeneratePageObjects(
       CPDF_PageObjectHolder* pObjectHolder,
       CFX_Edit* pEdit,
diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.h b/fpdfsdk/pdfwindow/PWL_ComboBox.h
index df9eb55..91b833c 100644
--- a/fpdfsdk/pdfwindow/PWL_ComboBox.h
+++ b/fpdfsdk/pdfwindow/PWL_ComboBox.h
@@ -82,7 +82,7 @@
 
   void SetSelectText();
 
-  void AttachFFLData(void* pData) { m_pFormFiller = pData; }
+  void AttachFFLData(CFFL_FormFiller* pData) { m_pFormFiller = pData; }
 
  private:
   void CreateEdit(const PWL_CREATEPARAM& cp);
@@ -98,8 +98,7 @@
   int32_t m_nPopupWhere;
   int32_t m_nSelectItem;
   IPWL_Filler_Notify* m_pFillerNotify;
-
-  void* m_pFormFiller;
+  CFFL_FormFiller* m_pFormFiller;  // Not owned.
 };
 
 #endif  // FPDFSDK_PDFWINDOW_PWL_COMBOBOX_H_
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.h b/fpdfsdk/pdfwindow/PWL_Edit.h
index 568f480..e6993bd 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.h
+++ b/fpdfsdk/pdfwindow/PWL_Edit.h
@@ -110,7 +110,7 @@
                            const CFX_FloatPoint& ptOffset);
 
   FX_BOOL IsProceedtoOnChar(uint16_t nKeyCode, uint32_t nFlag);
-  void AttachFFLData(void* pData) { m_pFormFiller = pData; }
+  void AttachFFLData(CFFL_FormFiller* pData) { m_pFormFiller = pData; }
 
   void OnInsertWord(const CPVT_WordPlace& place,
                     const CPVT_WordPlace& oldplace);
@@ -142,7 +142,7 @@
   IPWL_Filler_Notify* m_pFillerNotify;
   FX_BOOL m_bFocus;
   CFX_FloatRect m_rcOldWindow;
-  void* m_pFormFiller;
+  CFFL_FormFiller* m_pFormFiller;  // Not owned.
 };
 
 #endif  // FPDFSDK_PDFWINDOW_PWL_EDIT_H_
diff --git a/fpdfsdk/pdfwindow/PWL_ListBox.h b/fpdfsdk/pdfwindow/PWL_ListBox.h
index e42ca24..294414a 100644
--- a/fpdfsdk/pdfwindow/PWL_ListBox.h
+++ b/fpdfsdk/pdfwindow/PWL_ListBox.h
@@ -99,6 +99,8 @@
     m_pFillerNotify = pNotify;
   }
 
+  void AttachFFLData(CFFL_FormFiller* pData) { m_pFormFiller = pData; }
+
  protected:
   std::unique_ptr<CFX_ListCtrl> m_pList;
   std::unique_ptr<CPWL_List_Notify> m_pListNotify;
@@ -106,11 +108,8 @@
   FX_BOOL m_bHoverSel;
   IPWL_Filler_Notify* m_pFillerNotify;
 
- public:
-  void AttachFFLData(void* pData) { m_pFormFiller = pData; }
-
  private:
-  void* m_pFormFiller;
+  CFFL_FormFiller* m_pFormFiller;  // Not owned.
 };
 
 #endif  // FPDFSDK_PDFWINDOW_PWL_LISTBOX_H_
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp
index 4a479de..adda0bb 100644
--- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp
@@ -24,7 +24,7 @@
       pFocusHandler(nullptr),
       dwFlags(0),
       sBackgroundColor(),
-      hAttachedWnd(nullptr),
+      pAttachedWidget(nullptr),
       nBorderStyle(BorderStyle::SOLID),
       dwBorderWidth(1),
       sBorderColor(),
@@ -422,9 +422,8 @@
     rcWin.bottom += PWL_INVALIDATE_INFLATE;
 
     if (CFX_SystemHandler* pSH = GetSystemHandler()) {
-      if (FX_HWND hWnd = GetAttachedHWnd()) {
-        pSH->InvalidateRect(hWnd, rcWin);
-      }
+      if (CPDFSDK_Widget* widget = m_sPrivateParam.pAttachedWidget)
+        pSH->InvalidateRect(widget, rcWin);
     }
   }
 }
@@ -907,10 +906,6 @@
                  (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5));
 }
 
-FX_HWND CPWL_Wnd::GetAttachedHWnd() const {
-  return m_sPrivateParam.hAttachedWnd;
-}
-
 CFX_FloatPoint CPWL_Wnd::ChildToParent(const CFX_FloatPoint& point) const {
   CFX_Matrix mt = GetChildMatrix();
   if (mt.IsIdentity())
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h
index de48a8c..ca2b4c7 100644
--- a/fpdfsdk/pdfwindow/PWL_Wnd.h
+++ b/fpdfsdk/pdfwindow/PWL_Wnd.h
@@ -14,6 +14,7 @@
 #include "core/fxcrt/include/fx_basic.h"
 #include "fpdfsdk/cfx_systemhandler.h"
 
+class CPDFSDK_Widget;
 class CPWL_MsgControl;
 class CPWL_ScrollBar;
 class CPWL_Timer;
@@ -197,7 +198,7 @@
   IPWL_FocusHandler* pFocusHandler;   // optional
   uint32_t dwFlags;                   // optional
   CPWL_Color sBackgroundColor;        // optional
-  FX_HWND hAttachedWnd;               // required for no-reader framework
+  CPDFSDK_Widget* pAttachedWidget;    // required for no-reader framework
   BorderStyle nBorderStyle;           // optional
   int32_t dwBorderWidth;              // optional
   CPWL_Color sBorderColor;            // optional
@@ -389,7 +390,6 @@
 
   void PWLtoWnd(const CFX_FloatPoint& point, int32_t& x, int32_t& y) const;
   FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const;
-  FX_HWND GetAttachedHWnd() const;
 
   FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const;
   FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const;