diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-26 19:06:06 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-26 19:06:06 +0000 |
commit | 4ef943b992782d930a7550b98e3d0389886a0ba3 (patch) | |
tree | bc063c260a73bc83fbbb77b9bce59d8d97f28965 /fxjs | |
parent | 2daa06ab9596a42c967497c2bae16ddd902dcaf0 (diff) | |
download | pdfium-4ef943b992782d930a7550b98e3d0389886a0ba3.tar.xz |
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 <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r-- | fxjs/cjs_document.cpp | 2 | ||||
-rw-r--r-- | fxjs/cjs_field.cpp | 18 |
2 files changed, 9 insertions, 11 deletions
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index 51e189ec88..4ac2f15abd 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -417,7 +417,7 @@ CJS_Return CJS_Document::removeField( return CJS_Return(); for (const auto& pAnnot : widgets) { - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get()); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get()); if (!pWidget) continue; diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index 6513d4e486..19e6712f2a 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -54,20 +54,18 @@ void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv, for (auto& pObserved : widgets) { if (pObserved) { bool bFormatted = false; - WideString sValue = static_cast<CPDFSDK_Widget*>(pObserved.Get()) - ->OnFormat(bFormatted); + WideString sValue = + ToCPDFSDKWidget(pObserved.Get())->OnFormat(bFormatted); if (pObserved) { // Not redundant, may be clobbered by OnFormat. - static_cast<CPDFSDK_Widget*>(pObserved.Get()) - ->ResetAppearance(bFormatted ? &sValue : nullptr, false); + ToCPDFSDKWidget(pObserved.Get())->ResetAppearance( + bFormatted ? &sValue : nullptr, false); } } } } else { for (auto& pObserved : widgets) { - if (pObserved) { - static_cast<CPDFSDK_Widget*>(pObserved.Get()) - ->ResetAppearance(nullptr, false); - } + if (pObserved) + ToCPDFSDKWidget(pObserved.Get())->ResetAppearance(nullptr, false); } } } @@ -84,7 +82,7 @@ void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv, // |GetFormFillEnv| out of the loop. for (auto& pObserved : widgets) { if (pObserved) { - CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pObserved.Get()); + CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pObserved.Get()); pWidget->GetInterForm()->GetFormFillEnv()->UpdateAllViews(nullptr, pWidget); } @@ -1540,7 +1538,7 @@ CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) { if (!pObserved) return CJS_Return(JSMessage::kBadObjectError); - auto* pWidget = static_cast<CPDFSDK_Widget*>(pObserved.Get()); + auto* pWidget = ToCPDFSDKWidget(pObserved.Get()); CPDFSDK_PageView* pPageView = pWidget->GetPageView(); if (!pPageView) return CJS_Return(JSMessage::kBadObjectError); |