diff options
-rw-r--r-- | fpdfsdk/cpdfsdk_pageview.cpp | 50 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_pageview.h | 9 |
2 files changed, 35 insertions, 24 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, diff --git a/fpdfsdk/cpdfsdk_pageview.h b/fpdfsdk/cpdfsdk_pageview.h index face5072c7..c23aaa7988 100644 --- a/fpdfsdk/cpdfsdk_pageview.h +++ b/fpdfsdk/cpdfsdk_pageview.h @@ -14,6 +14,7 @@ #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" #include "fpdfsdk/cpdfsdk_annot.h" +#include "fpdfsdk/cpdfsdk_annothandlermgr.h" class CFX_RenderDevice; class CPDF_AnnotList; @@ -104,6 +105,13 @@ class CPDFSDK_PageView final : public CPDF_Page::View { int GetPageIndexForStaticPDF() const; + void EnterWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr, + CPDFSDK_Annot::ObservedPtr* pAnnot, + uint32_t nFlag); + void ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr, + bool callExitCallback, + uint32_t nFlag); + CFX_Matrix m_curMatrix; UnderlyingPageType* const m_page; std::unique_ptr<CPDF_AnnotList> m_pAnnotList; @@ -113,7 +121,6 @@ class CPDFSDK_PageView final : public CPDF_Page::View { #ifndef PDF_ENABLE_XFA bool m_bOwnsPage; #endif // PDF_ENABLE_XFA - bool m_bEnterWidget; bool m_bOnWidget; bool m_bValid; bool m_bLocked; |