diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-30 13:06:11 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-30 13:06:11 -0700 |
commit | 0bafcbed84d2f1d7e17cd1adfd15a2a019756ee4 (patch) | |
tree | 177ad8948051caa03d7c22f4472b0cb491510e56 /fpdfsdk | |
parent | a548b1d3e2444f256bcbf6c2fa2165798e33ba8d (diff) | |
download | pdfium-0bafcbed84d2f1d7e17cd1adfd15a2a019756ee4.tar.xz |
CPDFDoc_Environment::GetAnnotHandlerMgr() never returns nullptr.
Remove checks for its return value.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1424233003 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp index 7dba8d22b8..60fd0eff0b 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -562,8 +562,7 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); if (pAnnot && pPageView->IsValid()) { CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); - - if (pAnnotHandler && !m_pFocusAnnot) { + if (!m_pFocusAnnot) { if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) return FALSE; if (!m_pFocusAnnot) { @@ -578,23 +577,22 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) { if (m_pFocusAnnot) { CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); - if (pAnnotHandler) { - CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; - m_pFocusAnnot = NULL; - if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { - if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) { - CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; - int nFieldType = pWidget->GetFieldType(); - if (FIELDTYPE_TEXTFIELD == nFieldType || - FIELDTYPE_COMBOBOX == nFieldType) - m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); + CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; + m_pFocusAnnot = nullptr; + if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { + if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) { + CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; + int nFieldType = pWidget->GetFieldType(); + if (FIELDTYPE_TEXTFIELD == nFieldType || + FIELDTYPE_COMBOBOX == nFieldType) { + m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); } - - if (!m_pFocusAnnot) - return TRUE; - } else { - m_pFocusAnnot = pFocusAnnot; } + + if (!m_pFocusAnnot) + return TRUE; + } else { + m_pFocusAnnot = pFocusAnnot; } } return FALSE; @@ -745,9 +743,6 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); ASSERT(pEnv); CPDFSDK_AnnotHandlerMgr* pAnnotHandler = pEnv->GetAnnotHandlerMgr(); - if (!pAnnotHandler) - return nullptr; - CPDFSDK_Annot* pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); if (!pSDKAnnot) return nullptr; @@ -800,25 +795,21 @@ FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); if (!pFXAnnot) { KillFocusAnnot(nFlag); - } else { - CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); - ASSERT(pAnnotHandlerMgr); - - FX_BOOL bRet = - pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); - if (bRet) { - SetFocusAnnot(pFXAnnot); - } - return bRet; + return FALSE; } - return FALSE; + + CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); + FX_BOOL bRet = + pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); + if (bRet) + SetFocusAnnot(pFXAnnot); + return bRet; } FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); ASSERT(pEnv); CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); - ASSERT(pAnnotHandlerMgr); CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); FX_BOOL bRet = FALSE; @@ -826,17 +817,14 @@ FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { // Last focus Annot gets a chance to handle the event. bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); } - if (pFXAnnot && !bRet) { + if (pFXAnnot && !bRet) bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag, point); - return bRet; - } return bRet; } FX_BOOL CPDFSDK_PageView::OnMouseMove(const CPDF_Point& point, int nFlag) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); - ASSERT(pAnnotHandlerMgr); if (CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y)) { if (m_CaptureWidget && m_CaptureWidget != pFXAnnot) { m_bExitWidget = TRUE; @@ -872,7 +860,6 @@ FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, if (CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); - ASSERT(pAnnotHandlerMgr); return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)deltaY, point); } @@ -883,7 +870,6 @@ FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) { if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); - ASSERT(pAnnotHandlerMgr); return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); } @@ -894,7 +880,6 @@ FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); - ASSERT(pAnnotHandlerMgr); return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); } return FALSE; |