From c970895f94cf76eb738d0a583ae139fecdd85268 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 23 Oct 2017 09:40:59 -0400 Subject: Cleanup CJS_Value This CL removes unused methods; renames Attach to Set and generally cleans up the CJS_Value classes. Change-Id: I858082100908f3bc51f4b58c11ceda3357fadc70 Reviewed-on: https://pdfium-review.googlesource.com/16430 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/javascript/Field.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'fpdfsdk/javascript/Field.cpp') diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 0eaad73346..d3923141da 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -874,11 +874,8 @@ bool Field::set_current_value_indices(CJS_Runtime* pRuntime, array.push_back(vp.ToInt()); } else if (vp.GetJSValue()->IsArrayObject()) { CJS_Array SelArray = vp.ToArray(); - CJS_Value SelValue(pRuntime); - for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++) { - SelArray.GetElement(pRuntime, i, SelValue); - array.push_back(SelValue.ToInt(pRuntime)); - } + for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++) + array.push_back(SelArray.GetElement(pRuntime, i).ToInt(pRuntime)); } if (m_bDelay) { @@ -1771,16 +1768,11 @@ bool Field::set_rect(CJS_Runtime* pRuntime, if (!vp.GetJSValue()->IsArrayObject()) return false; - CJS_Value Upper_Leftx(pRuntime); - CJS_Value Upper_Lefty(pRuntime); - CJS_Value Lower_Rightx(pRuntime); - CJS_Value Lower_Righty(pRuntime); - CJS_Array rcArray = vp.ToArray(); - rcArray.GetElement(pRuntime, 0, Upper_Leftx); - rcArray.GetElement(pRuntime, 1, Upper_Lefty); - rcArray.GetElement(pRuntime, 2, Lower_Rightx); - rcArray.GetElement(pRuntime, 3, Lower_Righty); + CJS_Value Upper_Leftx = rcArray.GetElement(pRuntime, 0); + CJS_Value Upper_Lefty = rcArray.GetElement(pRuntime, 1); + CJS_Value Lower_Rightx = rcArray.GetElement(pRuntime, 2); + CJS_Value Lower_Righty = rcArray.GetElement(pRuntime, 3); float pArray[4]; pArray[0] = static_cast(Upper_Leftx.ToInt(pRuntime)); @@ -2263,7 +2255,7 @@ bool Field::get_value(CJS_Runtime* pRuntime, iIndex = pFormField->GetSelectedIndex(i); ElementValue = CJS_Value(pRuntime, pFormField->GetOptionValue(iIndex).c_str()); - if (wcslen(ElementValue.ToCFXWideString(pRuntime).c_str()) == 0) { + if (wcslen(ElementValue.ToWideString(pRuntime).c_str()) == 0) { ElementValue = CJS_Value(pRuntime, pFormField->GetOptionLabel(iIndex).c_str()); } @@ -2308,9 +2300,8 @@ bool Field::set_value(CJS_Runtime* pRuntime, if (vp.GetJSValue()->IsArrayObject()) { CJS_Array ValueArray = vp.ToArray(); for (int i = 0, sz = ValueArray.GetLength(pRuntime); i < sz; i++) { - CJS_Value ElementValue(pRuntime); - ValueArray.GetElement(pRuntime, i, ElementValue); - strArray.push_back(ElementValue.ToCFXWideString(pRuntime)); + CJS_Value ElementValue = ValueArray.GetElement(pRuntime, i); + strArray.push_back(ElementValue.ToWideString(pRuntime)); } } else { strArray.push_back(vp.ToWideString()); -- cgit v1.2.3