diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-15 12:41:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-15 12:41:50 -0700 |
commit | 8faac627c4562098c62f8497e56a44500c3c199b (patch) | |
tree | 1eeca4146f5376e4416b39c52a091a6d60d93d54 | |
parent | 4935e606c632e38af8fca1729f8688fa0d152b90 (diff) | |
download | pdfium-8faac627c4562098c62f8497e56a44500c3c199b.tar.xz |
Cleanup CFX_SystemHandler.
This CL cleans up signatures and code in CFX_SystemHandler.
Review-Url: https://codereview.chromium.org/2341693003
-rw-r--r-- | fpdfsdk/cfx_systemhandler.cpp | 58 | ||||
-rw-r--r-- | fpdfsdk/cfx_systemhandler.h | 12 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fxedit/fxet_edit.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fxedit/include/fxet_edit.h | 12 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ComboBox.h | 5 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Edit.h | 4 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ListBox.h | 7 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.cpp | 11 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.h | 4 |
10 files changed, 56 insertions, 61 deletions
diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp index 784ed4ebd9..08d9743993 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 @@ int CharSet2CP(int charset) { } // 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 @@ void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, } 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 @@ bool CFX_SystemHandler::FindNativeTrueTypeFont(CFX_ByteString sFontFaceName) { if (font.Compare(sFontFaceName.AsStringC())) return true; } - return false; } @@ -126,10 +130,6 @@ void CFX_SystemHandler::KillTimer(int32_t nID) { 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 a1c277d04b..5f8a871f05 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 @@ struct FX_SYSTEMTIME { #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 @@ class CFX_SystemHandler { 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 f91a1f4141..e2f5be197f 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -367,7 +367,7 @@ CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, } } 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 f4350f310e..4967961cfa 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -820,7 +820,7 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, 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 c1b000012f..22db613d57 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 @@ class CFX_Edit { 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 df9eb5546e..91b833c77f 100644 --- a/fpdfsdk/pdfwindow/PWL_ComboBox.h +++ b/fpdfsdk/pdfwindow/PWL_ComboBox.h @@ -82,7 +82,7 @@ class CPWL_ComboBox : public CPWL_Wnd { 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 @@ class CPWL_ComboBox : public CPWL_Wnd { 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 568f4805a9..e6993bd16b 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.h +++ b/fpdfsdk/pdfwindow/PWL_Edit.h @@ -110,7 +110,7 @@ class CPWL_Edit : public CPWL_EditCtrl { 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 @@ class CPWL_Edit : public CPWL_EditCtrl { 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 e42ca24ab4..294414a85f 100644 --- a/fpdfsdk/pdfwindow/PWL_ListBox.h +++ b/fpdfsdk/pdfwindow/PWL_ListBox.h @@ -99,6 +99,8 @@ class CPWL_ListBox : public CPWL_Wnd { 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 @@ class CPWL_ListBox : public CPWL_Wnd { 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 4a479de0dc..adda0bbbc9 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -24,7 +24,7 @@ PWL_CREATEPARAM::PWL_CREATEPARAM() pFocusHandler(nullptr), dwFlags(0), sBackgroundColor(), - hAttachedWnd(nullptr), + pAttachedWidget(nullptr), nBorderStyle(BorderStyle::SOLID), dwBorderWidth(1), sBorderColor(), @@ -422,9 +422,8 @@ void CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) { 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 @@ FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const { (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 de48a8c82d..ca2b4c77da 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 @@ struct PWL_CREATEPARAM { 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 @@ class CPWL_Wnd : public CPWL_TimerHandler { 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; |