From 6eec1c45c9c6e0812950d55ae88340cf41bc243a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 21 Feb 2017 17:20:43 -0500 Subject: Update Invalidate to take a rect This Cl updates the various Invalidate methods to take a rect when possible. Change-Id: I5359f4d8118f822347414ccb8d261aeef2ac35e0 Reviewed-on: https://pdfium-review.googlesource.com/2814 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- fpdfsdk/formfiller/cffl_formfiller.cpp | 35 +++++++++++----------------------- fpdfsdk/formfiller/cffl_formfiller.h | 5 +---- fpdfsdk/formfiller/cffl_textfield.cpp | 5 ++--- 3 files changed, 14 insertions(+), 31 deletions(-) (limited to 'fpdfsdk/formfiller') diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 36aaae0f29..44df8dd770 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -123,9 +123,8 @@ bool CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true)) { m_bValid = true; FX_RECT rect = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); - - if (!rect.Contains((int)point.x, (int)point.y)) + InvalidateRect(rect); + if (!rect.Contains(static_cast(point.x), static_cast(point.y))) return false; return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); @@ -142,8 +141,7 @@ bool CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, if (!pWnd) return false; - FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); + InvalidateRect(GetViewBBox(pPageView, pAnnot)); pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); return true; } @@ -249,8 +247,7 @@ void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { pWnd->SetFocus(); m_bValid = true; - FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); + InvalidateRect(GetViewBBox(pPageView, pAnnot)); } void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { @@ -592,19 +589,13 @@ void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, bool bDestroyPDFWindow) { m_bValid = false; - FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); - InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); - + InvalidateRect(GetViewBBox(pPageView, m_pWidget)); if (bDestroyPDFWindow) DestroyPDFWindow(pPageView); } -void CFFL_FormFiller::InvalidateRect(double left, - double top, - double right, - double bottom) { - UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); - m_pFormFillEnv->Invalidate(pPage, left, top, right, bottom); +void CFFL_FormFiller::InvalidateRect(const FX_RECT& rect) { + m_pFormFillEnv->Invalidate(m_pWidget->GetUnderlyingPage(), rect); } CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp, @@ -616,16 +607,14 @@ CFFL_Button::~CFFL_Button() {} void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { m_bMouseIn = true; - FX_RECT rect = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); + InvalidateRect(GetViewBBox(pPageView, pAnnot)); } void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { m_bMouseIn = false; - FX_RECT rect = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); + InvalidateRect(GetViewBBox(pPageView, pAnnot)); EndTimer(); ASSERT(m_pWidget); } @@ -639,8 +628,7 @@ bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, m_bMouseDown = true; m_bValid = true; - FX_RECT rect = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); + InvalidateRect(GetViewBBox(pPageView, pAnnot)); return true; } @@ -654,8 +642,7 @@ bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, m_bMouseDown = false; m_pWidget->GetPDFPage(); - FX_RECT rect = GetViewBBox(pPageView, pAnnot); - InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); + InvalidateRect(GetViewBBox(pPageView, pAnnot)); return true; } diff --git a/fpdfsdk/formfiller/cffl_formfiller.h b/fpdfsdk/formfiller/cffl_formfiller.h index 7462b40e97..c6b1e59786 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.h +++ b/fpdfsdk/formfiller/cffl_formfiller.h @@ -138,10 +138,7 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler { CPDFSDK_PageView* GetCurPageView(bool renew); void SetChangeMark(); - virtual void InvalidateRect(double left, - double top, - double right, - double bottom); + virtual void InvalidateRect(const FX_RECT& rect); CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot; } protected: diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp index c1cd7868c8..91db0959db 100644 --- a/fpdfsdk/formfiller/cffl_textfield.cpp +++ b/fpdfsdk/formfiller/cffl_textfield.cpp @@ -114,9 +114,8 @@ bool CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, CPDFSDK_PageView* pPageView = GetCurPageView(true); ASSERT(pPageView); m_bValid = !m_bValid; - CFX_FloatRect rcAnnot = pAnnot->GetRect(); - m_pFormFillEnv->Invalidate(pAnnot->GetUnderlyingPage(), rcAnnot.left, - rcAnnot.top, rcAnnot.right, rcAnnot.bottom); + m_pFormFillEnv->Invalidate(pAnnot->GetUnderlyingPage(), + pAnnot->GetRect().ToFxRect()); if (m_bValid) { if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true)) -- cgit v1.2.3