Convert std::vector<v8::Local<T>> to v8::LocalVector<T>.
Bug: pdfium:2090
Change-Id: I9eb02cdd71354b3a60b57bacd924359e8f1636bf
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/113293
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index 5b2358c..d00f8d0 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -220,7 +220,7 @@
CJS_Result CJS_App::alert(CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) {
- std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(
+ v8::LocalVector<v8::Value> newParams = ExpandKeywordParams(
pRuntime, params, 4, "cMsg", "nIcon", "nType", "cTitle");
if (!IsExpandedParamKnown(newParams[0]))
@@ -423,7 +423,7 @@
CJS_Result CJS_App::mailMsg(CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) {
- std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(
+ v8::LocalVector<v8::Value> newParams = ExpandKeywordParams(
pRuntime, params, 6, "bUI", "cTo", "cCc", "cBcc", "cSubject", "cMsg");
if (!IsExpandedParamKnown(newParams[0]))
@@ -519,7 +519,7 @@
CJS_Result CJS_App::response(CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) {
- std::vector<v8::Local<v8::Value>> newParams =
+ v8::LocalVector<v8::Value> newParams =
ExpandKeywordParams(pRuntime, params, 5, "cQuestion", "cTitle",
"cDefault", "bPassword", "cLabel");
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index cbb3598..4336ce2 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -315,7 +315,7 @@
if (!m_pFormFillEnv)
return CJS_Result::Failure(JSMessage::kBadObjectError);
- std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(
+ v8::LocalVector<v8::Value> newParams = ExpandKeywordParams(
pRuntime, params, 6, "bUI", "cTo", "cCc", "cBcc", "cSubject", "cMsg");
bool bUI = true;
@@ -366,7 +366,7 @@
if (sTextBuf.IsEmpty())
return CJS_Result::Failure(L"Bad FDF format.");
- std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(
+ v8::LocalVector<v8::Value> newParams = ExpandKeywordParams(
pRuntime, params, 6, "bUI", "cTo", "cCc", "cBcc", "cSubject", "cMsg");
bool bUI = true;
@@ -402,7 +402,7 @@
CJS_Result CJS_Document::print(CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) {
- std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(
+ v8::LocalVector<v8::Value> newParams = ExpandKeywordParams(
pRuntime, params, 8, "bUI", "nStart", "nEnd", "bSilent", "bShrinkToFit",
"bPrintAsImage", "bReverse", "bAnnotations");
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 9ac0476..0377d93 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -153,7 +153,7 @@
if (!pRuntime)
return;
- std::vector<v8::Local<v8::Value>> parameters;
+ v8::LocalVector<v8::Value> parameters(info.GetIsolate());
for (int i = 0; i < info.Length(); ++i)
parameters.push_back(info[i]);
@@ -993,7 +993,7 @@
int iIndex =
WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kDateFormats));
- std::vector<v8::Local<v8::Value>> newParams;
+ v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate());
newParams.push_back(pRuntime->NewString(kDateFormats[iIndex]));
return AFDate_FormatEx(pRuntime, newParams);
}
@@ -1007,7 +1007,7 @@
int iIndex =
WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kDateFormats));
- std::vector<v8::Local<v8::Value>> newParams;
+ v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate());
newParams.push_back(pRuntime->NewString(kDateFormats[iIndex]));
return AFDate_KeystrokeEx(pRuntime, newParams);
}
@@ -1021,7 +1021,7 @@
int iIndex =
WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kTimeFormats));
- std::vector<v8::Local<v8::Value>> newParams;
+ v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate());
newParams.push_back(pRuntime->NewString(kTimeFormats[iIndex]));
return AFDate_FormatEx(pRuntime, newParams);
}
@@ -1034,7 +1034,7 @@
int iIndex =
WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kTimeFormats));
- std::vector<v8::Local<v8::Value>> newParams;
+ v8::LocalVector<v8::Value> newParams(pRuntime->GetIsolate());
newParams.push_back(pRuntime->NewString(kTimeFormats[iIndex]));
return AFDate_KeystrokeEx(pRuntime, newParams);
}
@@ -1199,7 +1199,7 @@
break;
}
- std::vector<v8::Local<v8::Value>> params2;
+ v8::LocalVector<v8::Value> params2(pRuntime->GetIsolate());
params2.push_back(pRuntime->NewString(cFormat));
return AFSpecial_KeystrokeEx(pRuntime, params2);
}
diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp
index 5a1a6e7..3184a56 100644
--- a/fxjs/cjs_publicmethods_embeddertest.cpp
+++ b/fxjs/cjs_publicmethods_embeddertest.cpp
@@ -203,7 +203,7 @@
runtime.PutArrayElement(ary, 0, runtime.NewString("Calc1_A"));
runtime.PutArrayElement(ary, 1, runtime.NewString("Calc1_B"));
- std::vector<v8::Local<v8::Value>> params;
+ v8::LocalVector<v8::Value> params(runtime.GetIsolate());
params.push_back(runtime.NewString("SUM"));
params.push_back(ary);
@@ -244,7 +244,7 @@
handler->SetSelStart(0);
handler->SetSelEnd(0);
- std::vector<v8::Local<v8::Value>> params;
+ v8::LocalVector<v8::Value> params(runtime.GetIsolate());
params.push_back(runtime.NewString("-10"));
params.push_back(runtime.NewString(""));
diff --git a/fxjs/js_define.cpp b/fxjs/js_define.cpp
index 2664cb8..2e2087a 100644
--- a/fxjs/js_define.cpp
+++ b/fxjs/js_define.cpp
@@ -60,14 +60,14 @@
return isfinite(date) ? FX_LocalTime(date) : date;
}
-std::vector<v8::Local<v8::Value>> ExpandKeywordParams(
+v8::LocalVector<v8::Value> ExpandKeywordParams(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> originals,
size_t nKeywords,
...) {
DCHECK(nKeywords);
- std::vector<v8::Local<v8::Value>> result(nKeywords, v8::Local<v8::Value>());
+ v8::LocalVector<v8::Value> result(pRuntime->GetIsolate(), nKeywords);
size_t size = std::min(originals.size(), nKeywords);
for (size_t i = 0; i < size; ++i)
result[i] = originals[i];
diff --git a/fxjs/js_define.h b/fxjs/js_define.h
index d9264c0..045cce1 100644
--- a/fxjs/js_define.h
+++ b/fxjs/js_define.h
@@ -8,7 +8,6 @@
#define FXJS_JS_DEFINE_H_
#include <memory>
-#include <vector>
#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/cfxjs_engine.h"
@@ -16,6 +15,7 @@
#include "fxjs/cjs_runtime.h"
#include "fxjs/js_resources.h"
#include "third_party/base/containers/span.h"
+#include "v8/include/v8-local-handle.h"
class CJS_Object;
@@ -27,7 +27,7 @@
// names as wchar_t string literals corresponding to each positional argument.
// The result will always contain |nKeywords| value, check for the unspecified
// ones in the result using IsExpandedParamKnown() below.
-std::vector<v8::Local<v8::Value>> ExpandKeywordParams(
+v8::LocalVector<v8::Value> ExpandKeywordParams(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> originals,
size_t nKeywords,
@@ -123,7 +123,7 @@
if (!pRuntime)
return;
- std::vector<v8::Local<v8::Value>> parameters;
+ v8::LocalVector<v8::Value> parameters(info.GetIsolate());
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
parameters.push_back(info[i]);
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index ecb8c96..1d47de6 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -25,6 +25,7 @@
#include "third_party/base/containers/contains.h"
#include "v8/include/v8-function-callback.h"
#include "v8/include/v8-function.h"
+#include "v8/include/v8-local-handle.h"
#include "v8/include/v8-object.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffdoc.h"
@@ -543,7 +544,7 @@
CFXJSE_Engine* pScriptContext = pObject->GetDocument()->GetScriptContext();
pObject = pScriptContext->GetVariablesThis(pObject);
- std::vector<v8::Local<v8::Value>> parameters;
+ v8::LocalVector<v8::Value> parameters(info.GetIsolate());
for (int i = 0; i < info.Length(); i++)
parameters.push_back(info[i]);
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 82a5097..8172b33 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -35,6 +35,7 @@
#include "third_party/base/numerics/safe_conversions.h"
#include "v8/include/v8-container.h"
#include "v8/include/v8-function-callback.h"
+#include "v8/include/v8-local-handle.h"
#include "v8/include/v8-object.h"
#include "v8/include/v8-primitive.h"
#include "xfa/fgas/crt/cfgas_decimal.h"
@@ -1186,9 +1187,9 @@
return fxv8::IsNull(firstValue) && fxv8::IsNull(secondValue);
}
-std::vector<v8::Local<v8::Value>> UnfoldArgs(
+v8::LocalVector<v8::Value> UnfoldArgs(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- std::vector<v8::Local<v8::Value>> results;
+ v8::LocalVector<v8::Value> results(info.GetIsolate());
v8::Isolate* pIsolate = info.GetIsolate();
for (int i = 1; i < info.Length(); ++i) {
v8::Local<v8::Value> arg = info[i];
@@ -1303,14 +1304,14 @@
dwFlags);
}
-std::vector<v8::Local<v8::Value>> ParseResolveResult(
+v8::LocalVector<v8::Value> ParseResolveResult(
CFXJSE_HostObject* pHostObject,
const CFXJSE_Engine::ResolveResult& resolveNodeRS,
v8::Local<v8::Value> pParentValue,
bool* bAttribute) {
- std::vector<v8::Local<v8::Value>> resultValues;
CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pHostObject);
v8::Isolate* pIsolate = pContext->GetIsolate();
+ v8::LocalVector<v8::Value> resultValues(pIsolate);
if (resolveNodeRS.type == CFXJSE_Engine::ResolveResult::Type::kNodes) {
*bAttribute = false;
@@ -3016,7 +3017,7 @@
return;
}
- std::vector<v8::Local<v8::Value>> values(3);
+ v8::LocalVector<v8::Value> values(info.GetIsolate(), 3);
int intVal = 3;
if (fxv8::IsNull(argOne)) {
// TODO(dsinclair): Why is this 4 when the others are all 3?
@@ -4900,7 +4901,7 @@
}
if (iFlags == 4) {
- std::vector<v8::Local<v8::Value>> values(3);
+ v8::LocalVector<v8::Value> values(info.GetIsolate(), 3);
values[0] = fxv8::NewNumberHelper(info.GetIsolate(), 3);
values[1] = fxv8::NewNullHelper(info.GetIsolate());
values[2] = fxv8::NewNullHelper(info.GetIsolate());
@@ -4922,7 +4923,7 @@
CFXJSE_HostObject* pThis,
const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate();
- std::vector<v8::Local<v8::Value>> returnValues;
+ v8::LocalVector<v8::Value> returnValues(pIsolate);
for (int i = 0; i < info.Length(); ++i) {
if (fxv8::IsArray(info[i])) {
v8::Local<v8::Array> arr = info[i].As<v8::Array>();
@@ -5053,7 +5054,10 @@
return;
}
- std::vector<std::vector<v8::Local<v8::Value>>> resolveValues(iLength - 2);
+ // TODO(crbug.com/pdfium/2090) - doublecheck use of std::vector
+ std::vector<v8::LocalVector<v8::Value>> resolveValues(
+ iLength - 2, v8::LocalVector<v8::Value>(info.GetIsolate()));
+
bool bAttribute = false;
bool bAllEmpty = true;
for (uint32_t i = 2; i < iLength; i++) {
@@ -5074,7 +5078,7 @@
return;
}
- std::vector<v8::Local<v8::Value>> values;
+ v8::LocalVector<v8::Value> values(pIsolate);
values.push_back(fxv8::NewNumberHelper(pIsolate, 1));
values.push_back(
bAttribute ? fxv8::NewStringHelper(pIsolate, bsName.AsStringView())
@@ -5111,10 +5115,10 @@
}
bool bAttribute = false;
- std::vector<v8::Local<v8::Value>> resolveValues =
+ v8::LocalVector<v8::Value> resolveValues =
ParseResolveResult(pThis, maybeResult.value(), argAccessor, &bAttribute);
- std::vector<v8::Local<v8::Value>> values(resolveValues.size() + 2);
+ v8::LocalVector<v8::Value> values(pIsolate, resolveValues.size() + 2);
values[0] = fxv8::NewNumberHelper(pIsolate, 1);
values[1] = bAttribute
? fxv8::NewStringHelper(pIsolate, bsName.AsStringView())
diff --git a/fxjs/xfa/cfxjse_value.cpp b/fxjs/xfa/cfxjse_value.cpp
index 112a648..64c2015 100644
--- a/fxjs/xfa/cfxjse_value.cpp
+++ b/fxjs/xfa/cfxjse_value.cpp
@@ -16,6 +16,7 @@
#include "v8/include/v8-container.h"
#include "v8/include/v8-exception.h"
#include "v8/include/v8-function.h"
+#include "v8/include/v8-local-handle.h"
#include "v8/include/v8-primitive.h"
#include "v8/include/v8-script.h"
@@ -97,7 +98,7 @@
v8::Isolate* pIsolate,
const std::vector<std::unique_ptr<CFXJSE_Value>>& values) {
CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
- std::vector<v8::Local<v8::Value>> local_values;
+ v8::LocalVector<v8::Value> local_values(pIsolate);
local_values.reserve(values.size());
for (auto& v : values) {
if (v->IsEmpty())