diff options
author | Lei Zhang <thestig@chromium.org> | 2017-08-01 18:34:43 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-02 19:15:00 +0000 |
commit | b4fee4d5d471475ada1d0d9110e1a534b49477ba (patch) | |
tree | 3f969af1ac350b5c884f44f3f6d755d98d911415 /fpdfsdk/formfiller/cffl_textfield.cpp | |
parent | db14532fb2637b34f0926b6c3a931132854f53bb (diff) | |
download | pdfium-b4fee4d5d471475ada1d0d9110e1a534b49477ba.tar.xz |
Add CFFL_TextField class.chromium/3175
This class implements common code used by several CFFL_FormFiller
sub-classes. Make those sub-classes inherit from CFFL_TextField, instead
of inheriting from CFFL_FormFiller directly and then implementing the
same functionality multiple times.
Change-Id: Iad8a735b6d6e18e89d617636b753805d3f77a286
Reviewed-on: https://pdfium-review.googlesource.com/9850
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/formfiller/cffl_textfield.cpp')
-rw-r--r-- | fpdfsdk/formfiller/cffl_textfield.cpp | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index 0f330b58f1..d26b4a5599 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -14,7 +14,7 @@ CFFL_TextField::CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget) - : CFFL_FormFiller(pApp, pWidget) {} + : CFFL_TextObject(pApp, pWidget) {} CFFL_TextField::~CFFL_TextField() { for (const auto& it : m_Maps) @@ -27,7 +27,7 @@ CFFL_TextField::~CFFL_TextField() { } PWL_CREATEPARAM CFFL_TextField::GetCreateParam() { - PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam(); + PWL_CREATEPARAM cp = CFFL_TextObject::GetCreateParam(); int nFlags = m_pWidget->GetFieldFlags(); if (nFlags & FIELDFLAG_PASSWORD) cp.dwFlags |= PES_PASSWORD; @@ -62,11 +62,7 @@ PWL_CREATEPARAM CFFL_TextField::GetCreateParam() { cp.dwFlags |= PES_RIGHT; break; } - if (!m_pFontMap) { - m_pFontMap = pdfium::MakeUnique<CBA_FontMap>( - m_pWidget.Get(), m_pFormFillEnv->GetSysHandler()); - } - cp.pFontMap = m_pFontMap.get(); + cp.pFontMap = MaybeCreateFontMap(); cp.pFocusHandler = this; return cp; } @@ -127,7 +123,7 @@ bool CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, } } - return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); + return CFFL_TextObject::OnChar(pAnnot, nChar, nFlags); } bool CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView) { @@ -232,20 +228,6 @@ void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) { pWnd->SetSelection(m_State.nStart, m_State.nEnd); } -CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView, - bool bRestoreValue) { - if (bRestoreValue) - SaveState(pPageView); - - DestroyPDFWindow(pPageView); - if (bRestoreValue) - RestoreState(pPageView); - - CPWL_Wnd::ObservedPtr pRet(GetPDFWindow(pPageView, !bRestoreValue)); - m_pWidget->UpdateField(); // May invoke JS, invalidating pRet. - return pRet.Get(); -} - #ifdef PDF_ENABLE_XFA bool CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) { CPWL_Edit* pWnd = GetEdit(pPageView, false); |