Chromium Code Reviews| Index: fpdfsdk/src/javascript/Document.cpp |
| diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp |
| index d9ef6af52d4092ded3361d235c1c7c53ddd3ef47..e8dacfc76cfa54c7dcf9d4bc98cb40f2ac747dfe 100644 |
| --- a/fpdfsdk/src/javascript/Document.cpp |
| +++ b/fpdfsdk/src/javascript/Document.cpp |
| @@ -520,35 +520,31 @@ FX_BOOL Document::removeField(IJS_Context* cc, |
| (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); |
| ASSERT(pInterForm != NULL); |
| - CFX_PtrArray widgets; |
| - pInterForm->GetWidgets(sFieldName, widgets); |
| + std::vector<CPDFSDK_Widget*> widgets; |
| + pInterForm->GetWidgets(sFieldName, &widgets); |
| - int nSize = widgets.GetSize(); |
| - |
| - if (nSize > 0) { |
| - for (int i = 0; i < nSize; i++) { |
| - CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widgets[i]; |
| - ASSERT(pWidget != NULL); |
| + if (widgets.empty()) |
| + return TRUE; |
| - CPDF_Rect rcAnnot = pWidget->GetRect(); |
| - rcAnnot.left -= 1; |
| - rcAnnot.bottom -= 1; |
| - rcAnnot.right += 1; |
| - rcAnnot.top += 1; |
| + for (CPDFSDK_Widget* pWidget : widgets) { |
| + CPDF_Rect rcAnnot = pWidget->GetRect(); |
| + rcAnnot.left -= 1; |
|
Tom Sepez
2015/11/09 21:25:32
nit: some would say --.
Lei Zhang
2015/11/09 22:45:28
Done.
|
| + rcAnnot.bottom -= 1; |
| + rcAnnot.right += 1; |
| + rcAnnot.top += 1; |
| - CFX_RectArray aRefresh; |
| - aRefresh.Add(rcAnnot); |
| + CFX_RectArray aRefresh; |
| + aRefresh.Add(rcAnnot); |
| - CPDF_Page* pPage = pWidget->GetPDFPage(); |
| - ASSERT(pPage != NULL); |
| + CPDF_Page* pPage = pWidget->GetPDFPage(); |
| + ASSERT(pPage != NULL); |
|
Tom Sepez
2015/11/09 21:25:32
nit: ASSERT(pPage)
Lei Zhang
2015/11/09 22:45:28
Done.
|
| - CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); |
| - pPageView->DeleteAnnot(pWidget); |
| + CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage); |
| + pPageView->DeleteAnnot(pWidget); |
|
Tom Sepez
2015/11/09 21:25:32
nit: blank line probably not needed here.
Lei Zhang
2015/11/09 22:45:28
Done.
|
| - pPageView->UpdateRects(aRefresh); |
| - } |
| - m_pDocument->SetChangeMark(); |
| + pPageView->UpdateRects(aRefresh); |
| } |
| + m_pDocument->SetChangeMark(); |
| return TRUE; |
| } |
| @@ -582,18 +578,16 @@ FX_BOOL Document::resetForm(IJS_Context* cc, |
| break; |
| } |
| - CFX_PtrArray aFields; |
| - |
| - for (int i = 0, isz = aName.GetLength(); i < isz; i++) { |
| + std::vector<CPDF_FormField*> aFields; |
| + for (int i = 0, isz = aName.GetLength(); i < isz; ++i) { |
| CJS_Value valElement(pRuntime); |
| aName.GetElement(i, valElement); |
| CFX_WideString swVal = valElement.ToCFXWideString(); |
| - for (int j = 0, jsz = pPDFForm->CountFields(swVal); j < jsz; j++) { |
| - aFields.Add((void*)pPDFForm->GetField(j, swVal)); |
| - } |
| + for (int j = 0, jsz = pPDFForm->CountFields(swVal); j < jsz; ++j) |
| + aFields.push_back(pPDFForm->GetField(j, swVal)); |
| } |
| - if (aFields.GetSize() > 0) { |
| + if (!aFields.empty()) { |
| pPDFForm->ResetForm(aFields, TRUE, TRUE); |
| m_pDocument->SetChangeMark(); |
| } |
| @@ -663,7 +657,7 @@ FX_BOOL Document::submitForm(IJS_Context* cc, |
| CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| FX_BOOL bAll = (aFields.GetLength() == 0); |
| if (bAll && bEmpty) { |
| - if (pPDFInterForm->CheckRequiredFields()) { |
| + if (pPDFInterForm->CheckRequiredFields(nullptr, TRUE)) { |
| pRuntime->BeginBlock(); |
| pInterForm->SubmitForm(strURL, FALSE); |
| pRuntime->EndBlock(); |
| @@ -671,8 +665,8 @@ FX_BOOL Document::submitForm(IJS_Context* cc, |
| return TRUE; |
| } |
| - CFX_PtrArray fieldObjects; |
| - for (int i = 0, sz = aFields.GetLength(); i < sz; i++) { |
| + std::vector<CPDF_FormField*> fieldObjects; |
| + for (int i = 0, sz = aFields.GetLength(); i < sz; ++i) { |
| CJS_Value valName(pRuntime); |
| aFields.GetElement(i, valName); |
| @@ -683,7 +677,7 @@ FX_BOOL Document::submitForm(IJS_Context* cc, |
| if (!bEmpty && pField->GetValue().IsEmpty()) |
| continue; |
| - fieldObjects.Add(pField); |
| + fieldObjects.push_back(pField); |
| } |
| } |