diff options
author | Lei Zhang <thestig@chromium.org> | 2017-06-29 18:28:05 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-30 18:35:55 +0000 |
commit | f552ccab1d3ca232f9d2b4770ec40726e5047093 (patch) | |
tree | 22740907cf72eaf5d4d4bf5ee014948566bf6744 /fpdfsdk/formfiller | |
parent | dfcb8af6f7c67f1bb2e349baada6afd2f54a2340 (diff) | |
download | pdfium-f552ccab1d3ca232f9d2b4770ec40726e5047093.tar.xz |
Use early returns in CFFL_FormFiller.
Change-Id: Ib7062d46c74d1e2fcfa3699a9db50bc3c930b674
Reviewed-on: https://pdfium-review.googlesource.com/7192
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/formfiller')
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.cpp | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 565d2babdd..80f725ba1a 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -120,17 +120,16 @@ bool CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, uint32_t nFlags, const CFX_PointF& point) { - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true)) { - m_bValid = true; - FX_RECT rect = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rect); - if (!rect.Contains(static_cast<int>(point.x), static_cast<int>(point.y))) - return false; - - return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); - } + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true); + if (!pWnd) + return false; - return false; + m_bValid = true; + FX_RECT rect = GetViewBBox(pPageView, pAnnot); + InvalidateRect(rect); + if (!rect.Contains(static_cast<int>(point.x), static_cast<int>(point.y))) + return false; + return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); } bool CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, @@ -212,31 +211,27 @@ bool CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, bool CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, uint32_t nKeyCode, uint32_t nFlags) { - if (IsValid()) { - CPDFSDK_PageView* pPageView = GetCurPageView(true); - ASSERT(pPageView); + if (!IsValid()) + return false; - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { - return pWnd->OnKeyDown(nKeyCode, nFlags); - } - } + CPDFSDK_PageView* pPageView = GetCurPageView(true); + ASSERT(pPageView); - return false; + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false); + return pWnd && pWnd->OnKeyDown(nKeyCode, nFlags); } bool CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) { - if (IsValid()) { - CPDFSDK_PageView* pPageView = GetCurPageView(true); - ASSERT(pPageView); + if (!IsValid()) + return false; - if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) { - return pWnd->OnChar(nChar, nFlags); - } - } + CPDFSDK_PageView* pPageView = GetCurPageView(true); + ASSERT(pPageView); - return false; + CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false); + return pWnd && pWnd->OnChar(nChar, nFlags); } CFX_WideString CFFL_FormFiller::GetSelectedText(CPDFSDK_Annot* pAnnot) { @@ -358,13 +353,7 @@ CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, if (!bNew) return pWnd; - if (found) { - CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pWnd->GetAttachedData(); - if (pPrivateData->nWidgetAge != m_pWidget->GetAppearanceAge()) { - return ResetPDFWindow( - pPageView, m_pWidget->GetValueAge() == pPrivateData->nValueAge); - } - } else { + if (!found) { PWL_CREATEPARAM cp = GetCreateParam(); cp.pAttachedWidget.Reset(m_pWidget.Get()); @@ -374,11 +363,17 @@ CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, pPrivateData->nWidgetAge = m_pWidget->GetAppearanceAge(); pPrivateData->nValueAge = 0; cp.pAttachedData = pPrivateData; - pWnd = NewPDFWindow(cp); - m_Maps[pPageView] = pWnd; + CPWL_Wnd* pNewWnd = NewPDFWindow(cp); + m_Maps[pPageView] = pNewWnd; + return pNewWnd; } - return pWnd; + auto* pPrivateData = static_cast<CFFL_PrivateData*>(pWnd->GetAttachedData()); + if (pPrivateData->nWidgetAge == m_pWidget->GetAppearanceAge()) + return pWnd; + + return ResetPDFWindow(pPageView, + m_pWidget->GetValueAge() == pPrivateData->nValueAge); } void CFFL_FormFiller::DestroyPDFWindow(CPDFSDK_PageView* pPageView) { |