From 4ef943b992782d930a7550b98e3d0389886a0ba3 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 26 Jul 2018 19:06:06 +0000 Subject: Be more careful casting to widget subclasses. Part of the effort to reduce unchecked static casts. Change-Id: I1bff1c53aa7c5804660de4b65cf01523d70fcbb7 Reviewed-on: https://pdfium-review.googlesource.com/38896 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- fpdfsdk/cpdfsdk_interform.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'fpdfsdk/cpdfsdk_interform.cpp') diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 9d646b6574..3cfc84dfd9 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -111,10 +111,8 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, auto pIterator = pdfium::MakeUnique( pWidget->GetPageView(), CPDF_Annot::Subtype::WIDGET); - if (bNext) - return static_cast(pIterator->GetNextAnnot(pWidget)); - - return static_cast(pIterator->GetPrevAnnot(pWidget)); + return ToCPDFSDKWidget(bNext ? pIterator->GetNextAnnot(pWidget) + : pIterator->GetPrevAnnot(pWidget)); } CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { @@ -144,10 +142,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { pPage = m_pFormFillEnv->GetPageView(nPageIndex); } - if (!pPage) - return nullptr; - - return static_cast(pPage->GetAnnotByDict(pControlDict)); + return pPage ? ToCPDFSDKWidget(pPage->GetAnnotByDict(pControlDict)) : nullptr; } void CPDFSDK_InterForm::GetWidgets( -- cgit v1.2.3