From 696d9faba208b0233cdfe0a43f3c6e5c90935843 Mon Sep 17 00:00:00 2001 From: Jun Fang Date: Wed, 25 Nov 2015 10:54:46 +0800 Subject: Refactor CXFA_FFPageView::GetWidgetByPos BUG=pdfium:276 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1438333005 . --- xfa/include/fwl/core/fwl_widgetdef.h | 2 +- xfa/src/fxfa/src/app/xfa_ffpageview.cpp | 18 +++++++++--------- xfa/src/fxfa/src/app/xfa_fftext.cpp | 5 ++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/xfa/include/fwl/core/fwl_widgetdef.h b/xfa/include/fwl/core/fwl_widgetdef.h index 1cdcc36522..6bb63b56c4 100644 --- a/xfa/include/fwl/core/fwl_widgetdef.h +++ b/xfa/include/fwl/core/fwl_widgetdef.h @@ -69,7 +69,7 @@ #define FWL_WGTHITTEST_Border 17 #define FWL_WGTHITTEST_Edge 18 #define FWL_WGTHITTEST_Edit 19 -#define FWL_WGTHITTEST_Transparent 20 +#define FWL_WGTHITTEST_HyperLink 20 #define FWL_WGTHITTEST_MAX 21 #define FWL_VKEY_LButton 0x01 #define FWL_VKEY_RButton 0x02 diff --git a/xfa/src/fxfa/src/app/xfa_ffpageview.cpp b/xfa/src/fxfa/src/app/xfa_ffpageview.cpp index 68e4b6b505..c083c2b141 100644 --- a/xfa/src/fxfa/src/app/xfa_ffpageview.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffpageview.cpp @@ -20,8 +20,7 @@ CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView), - m_bLoaded(FALSE) { -} + m_bLoaded(FALSE) {} CXFA_FFPageView::~CXFA_FFPageView() {} IXFA_DocView* CXFA_FFPageView::GetDocView() { return m_pDocView; @@ -60,10 +59,11 @@ FX_BOOL CXFA_FFPageView::IsPageViewLoaded() { } IXFA_Widget* CXFA_FFPageView::GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) { if (!m_bLoaded) { - return NULL; + return nullptr; } IXFA_WidgetIterator* pIterator = CreateWidgetIterator(); - while (CXFA_FFWidget* pWidget = (CXFA_FFWidget*)pIterator->MoveToNext()) { + CXFA_FFWidget* pWidget = nullptr; + while (pWidget = static_cast(pIterator->MoveToNext())) { if (!(pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { continue; } @@ -72,17 +72,17 @@ IXFA_Widget* CXFA_FFPageView::GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) { if (type != XFA_ELEMENT_Field && type != XFA_ELEMENT_Draw) { continue; } - FX_FLOAT fWidgetx = fx, fWidgety = fy; + FX_FLOAT fWidgetx = fx; + FX_FLOAT fWidgety = fy; pWidget->Rotate2Normal(fWidgetx, fWidgety); FX_DWORD dwFlag = pWidget->OnHitTest(fWidgetx, fWidgety); if ((FWL_WGTHITTEST_Client == dwFlag || - FWL_WGTHITTEST_Transparent == dwFlag)) { - pIterator->Release(); - return pWidget; + FWL_WGTHITTEST_HyperLink == dwFlag)) { + break; } } pIterator->Release(); - return NULL; + return pWidget; } IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( FX_DWORD dwTraverseWay, diff --git a/xfa/src/fxfa/src/app/xfa_fftext.cpp b/xfa/src/fxfa/src/app/xfa_fftext.cpp index e02b1f614f..15719190ca 100644 --- a/xfa/src/fxfa/src/app/xfa_fftext.cpp +++ b/xfa/src/fxfa/src/app/xfa_fftext.cpp @@ -143,11 +143,10 @@ FX_DWORD CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { if (!rtBox.Contains(fx, fy)) { return FWL_WGTHITTEST_Unknown; } - const FX_WCHAR* wsURLContent = GetLinkURLAtPoint(fx, fy); - if (NULL == wsURLContent) { + if (!GetLinkURLAtPoint(fx, fy)) { return FWL_WGTHITTEST_Unknown; } - return FWL_WGTHITTEST_Transparent; + return FWL_WGTHITTEST_HyperLink; } const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); -- cgit v1.2.3