summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-10 21:34:17 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 21:34:17 +0000
commit7db136abc305630fb9ba9754a2c371c0e7ae8237 (patch)
treeb04ed80e31df6677881d1b0b8901d7669c14d7c2 /fxjs
parente2210acfff622ac73b0783e1523615753484073b (diff)
downloadpdfium-7db136abc305630fb9ba9754a2c371c0e7ae8237.tar.xz
Remove more impossible checks in form filler code.
Also fix some nits and inline some calls. Change-Id: Ie962f416b8ecd51ce05341e5511129ea0602fa8e Reviewed-on: https://pdfium-review.googlesource.com/c/43604 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cjs_field.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index ef2a252b42..cffefeb8c7 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -142,13 +142,6 @@ std::vector<CPDF_FormField*> GetFormFieldsForName(
return fields;
}
-CPDFSDK_Widget* GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormControl* pFormControl) {
- CPDFSDK_InterForm* pInterForm =
- static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm());
- return pInterForm ? pInterForm->GetWidget(pFormControl) : nullptr;
-}
-
bool SetWidgetDisplayStatus(CPDFSDK_Widget* pWidget, int value) {
if (!pWidget)
return false;
@@ -209,12 +202,14 @@ void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
std::vector<CPDF_FormField*> FieldArray =
GetFormFieldsForName(pFormFillEnv, swFieldName);
+ auto* pInterForm = pFormFillEnv->GetInterForm();
for (CPDF_FormField* pFormField : FieldArray) {
if (nControlIndex < 0) {
bool bSet = false;
for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
- if (CPDFSDK_Widget* pWidget =
- GetWidget(pFormFillEnv, pFormField->GetControl(i))) {
+ CPDFSDK_Widget* pWidget =
+ pInterForm->GetWidget(pFormField->GetControl(i));
+ if (pWidget) {
if (pWidget->GetBorderStyle() != nBorderStyle) {
pWidget->SetBorderStyle(nBorderStyle);
bSet = true;
@@ -228,7 +223,8 @@ void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
return;
if (CPDF_FormControl* pFormControl =
pFormField->GetControl(nControlIndex)) {
- if (CPDFSDK_Widget* pWidget = GetWidget(pFormFillEnv, pFormControl)) {
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
+ if (pWidget) {
if (pWidget->GetBorderStyle() != nBorderStyle) {
pWidget->SetBorderStyle(nBorderStyle);
UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
@@ -704,8 +700,8 @@ CJS_Result CJS_Field::get_border_style(CJS_Runtime* pRuntime) {
if (!pFormField)
return CJS_Result::Failure(JSMessage::kBadObjectError);
- CPDFSDK_Widget* pWidget =
- GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField));
+ CPDFSDK_Widget* pWidget = m_pFormFillEnv->GetInterForm()->GetWidget(
+ GetSmartFieldControl(pFormField));
if (!pWidget)
return CJS_Result::Failure(JSMessage::kBadObjectError);