diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-08-22 10:59:49 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-22 17:46:46 +0000 |
commit | 4a6525492593866be3653a8a37923fe876b5171e (patch) | |
tree | b8c919b47c6cc2ea8f5aa67b2c257e6e8b3a371e /fpdfsdk/cpdfsdk_pageview.cpp | |
parent | 300bb27bf4a9a84fcd3f1348a4c0076d68a305ce (diff) | |
download | pdfium-4a6525492593866be3653a8a37923fe876b5171e.tar.xz |
Simplifying state of CPDFSDK_PageView.
Change-Id: Ic0849cce80e1797637fd875bdedd7cc560b98f22
Reviewed-on: https://pdfium-review.googlesource.com/11210
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_pageview.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_pageview.cpp | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index 516e0641da..c69f0990b1 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -14,7 +14,6 @@ #include "core/fpdfdoc/cpdf_annotlist.h" #include "core/fpdfdoc/cpdf_interform.h" #include "fpdfsdk/cpdfsdk_annot.h" -#include "fpdfsdk/cpdfsdk_annothandlermgr.h" #include "fpdfsdk/cpdfsdk_annotiteration.h" #include "fpdfsdk/cpdfsdk_formfillenvironment.h" #include "fpdfsdk/cpdfsdk_interform.h" @@ -36,7 +35,6 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, #ifndef PDF_ENABLE_XFA m_bOwnsPage(false), #endif // PDF_ENABLE_XFA - m_bEnterWidget(false), m_bOnWidget(false), m_bValid(false), m_bLocked(false), @@ -329,40 +327,46 @@ bool CPDFSDK_PageView::OnMouseMove(const CFX_PointF& point, int nFlag) { CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = m_pFormFillEnv->GetAnnotHandlerMgr(); CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point)); - if (pFXAnnot) { - if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { - m_bEnterWidget = false; - pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); - } - m_bOnWidget = true; - m_pCaptureWidget.Reset(pFXAnnot.Get()); - if (!m_bEnterWidget) { - m_bEnterWidget = true; - pAnnotHandlerMgr->Annot_OnMouseEnter(this, &pFXAnnot, nFlag); + if (m_bOnWidget && m_pCaptureWidget != pFXAnnot) + ExitWidget(pAnnotHandlerMgr, true, nFlag); + + if (pFXAnnot) { + if (!m_bOnWidget) { + EnterWidget(pAnnotHandlerMgr, &pFXAnnot, nFlag); // Annot_OnMouseEnter may have invalidated pFXAnnot. if (!pFXAnnot) { - m_bOnWidget = false; - m_bEnterWidget = false; - m_pCaptureWidget.Reset(); + ExitWidget(pAnnotHandlerMgr, false, nFlag); return true; } } + pAnnotHandlerMgr->Annot_OnMouseMove(this, &pFXAnnot, nFlag, point); return true; } - if (m_bOnWidget) { - m_bOnWidget = false; - m_bEnterWidget = false; - if (m_pCaptureWidget) { + return false; +} + +void CPDFSDK_PageView::EnterWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr, + CPDFSDK_Annot::ObservedPtr* pAnnot, + uint32_t nFlag) { + m_bOnWidget = true; + m_pCaptureWidget.Reset(pAnnot->Get()); + pAnnotHandlerMgr->Annot_OnMouseEnter(this, pAnnot, nFlag); +} + +void CPDFSDK_PageView::ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr, + bool callExitCallback, + uint32_t nFlag) { + m_bOnWidget = false; + if (m_pCaptureWidget) { + if (callExitCallback) pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); - m_pCaptureWidget.Reset(); - } - } - return false; + m_pCaptureWidget.Reset(); + } } bool CPDFSDK_PageView::OnMouseWheel(double deltaX, |