summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-24 09:36:16 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-24 17:17:03 +0000
commite49749265c4e503c37a316e4ca6eeff430d13b87 (patch)
treed75c0b641618e66477b2e992ae146f30a3e2dd9f /fpdfsdk
parent826480cf599f61fe0366ab2bd5803dd53c9d0562 (diff)
downloadpdfium-e49749265c4e503c37a316e4ca6eeff430d13b87.tar.xz
Remove most CJS_Value Set methods
This CL removes all of the Set(*) methods from CJS_Value except for Set(v8::Local<v8::Value>). All uses of Set are changed to convert to a v8::Value before setting. Change-Id: I6e4d2cebec42fce5c039dc0a3abe46086cfdd34f Reviewed-on: https://pdfium-review.googlesource.com/16610 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/javascript/Annot.cpp13
-rw-r--r--fpdfsdk/javascript/Document.cpp82
-rw-r--r--fpdfsdk/javascript/Field.cpp226
-rw-r--r--fpdfsdk/javascript/Icon.cpp2
-rw-r--r--fpdfsdk/javascript/JS_Define.h18
-rw-r--r--fpdfsdk/javascript/JS_Value.cpp89
-rw-r--r--fpdfsdk/javascript/JS_Value.h28
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp16
-rw-r--r--fpdfsdk/javascript/app.cpp32
-rw-r--r--fpdfsdk/javascript/color.cpp2
-rw-r--r--fpdfsdk/javascript/event.cpp34
-rw-r--r--fpdfsdk/javascript/global.cpp24
-rw-r--r--fpdfsdk/javascript/util.cpp6
13 files changed, 270 insertions, 302 deletions
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp
index 19e94f3e46..c9fbaaf76f 100644
--- a/fpdfsdk/javascript/Annot.cpp
+++ b/fpdfsdk/javascript/Annot.cpp
@@ -44,7 +44,8 @@ bool Annot::get_hidden(CJS_Runtime* pRuntime,
}
CPDF_Annot* pPDFAnnot = ToBAAnnot(m_pAnnot.Get())->GetPDFAnnot();
- vp->Set(pRuntime, CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()));
+ vp->Set(pRuntime->NewBoolean(
+ CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())));
return true;
}
@@ -80,7 +81,8 @@ bool Annot::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
return false;
}
- vp->Set(pRuntime, ToBAAnnot(m_pAnnot.Get())->GetAnnotName());
+ vp->Set(
+ pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str()));
return true;
}
@@ -103,8 +105,11 @@ bool Annot::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
return false;
}
- vp->Set(pRuntime, CPDF_Annot::AnnotSubtypeToString(
- ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype()));
+ vp->Set(pRuntime->NewString(
+ WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString(
+ ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype())
+ .c_str())
+ .c_str()));
return true;
}
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 1f023fbf49..a47deea790 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -172,7 +172,8 @@ bool Document::get_num_fields(CJS_Runtime* pRuntime,
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- vp->Set(pRuntime, static_cast<int>(pPDFForm->CountFields(WideString())));
+ vp->Set(pRuntime->NewNumber(
+ static_cast<int>(pPDFForm->CountFields(WideString()))));
return true;
}
@@ -191,7 +192,7 @@ bool Document::get_dirty(CJS_Runtime* pRuntime,
return false;
}
- vp->Set(pRuntime, !!m_pFormFillEnv->GetChangeMark());
+ vp->Set(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
return true;
}
@@ -212,7 +213,7 @@ bool Document::set_dirty(CJS_Runtime* pRuntime,
bool Document::get_ADBE(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->SetNull(pRuntime);
+ vp->Set(pRuntime->NewNull());
return true;
}
@@ -231,7 +232,7 @@ bool Document::get_page_num(CJS_Runtime* pRuntime,
}
if (CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView())
- vp->Set(pRuntime, pPageView->GetPageIndex());
+ vp->Set(pRuntime->NewNumber(pPageView->GetPageIndex()));
return true;
}
@@ -311,7 +312,7 @@ bool Document::getField(CJS_Runtime* pRuntime,
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
if (pPDFForm->CountFields(wideName) <= 0) {
- vRet.SetNull(pRuntime);
+ vRet.Set(pRuntime->NewNull());
return true;
}
@@ -324,7 +325,7 @@ bool Document::getField(CJS_Runtime* pRuntime,
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
pField->AttachField(this, wideName);
- vRet = CJS_Value(pRuntime, pJSField);
+ vRet = CJS_Value(pJSField);
return true;
}
@@ -584,7 +585,7 @@ bool Document::resetForm(CJS_Runtime* pRuntime,
std::vector<CPDF_FormField*> aFields;
for (int i = 0, isz = aName.GetLength(pRuntime); i < isz; ++i) {
- CJS_Value valElement = aName.GetElement(pRuntime, i);
+ CJS_Value valElement(aName.GetElement(pRuntime, i));
WideString swVal = valElement.ToWideString(pRuntime);
for (int j = 0, jsz = pPDFForm->CountFields(swVal); j < jsz; ++j)
aFields.push_back(pPDFForm->GetField(j, swVal));
@@ -631,7 +632,7 @@ bool Document::submitForm(CJS_Runtime* pRuntime,
WideString strURL;
bool bFDF = true;
bool bEmpty = false;
- CJS_Value v = params[0];
+ CJS_Value v(params[0]);
if (v.GetType() == CJS_Value::VT_string) {
strURL = params[0].ToWideString(pRuntime);
if (nSize > 1)
@@ -644,16 +645,16 @@ bool Document::submitForm(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pObj = params[0].ToV8Object(pRuntime);
v8::Local<v8::Value> pValue = pRuntime->GetObjectProperty(pObj, L"cURL");
if (!pValue.IsEmpty())
- strURL = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+ strURL = CJS_Value(pValue).ToWideString(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"bFDF");
- bFDF = CJS_Value(pRuntime, pValue).ToBool(pRuntime);
+ bFDF = CJS_Value(pValue).ToBool(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"bEmpty");
- bEmpty = CJS_Value(pRuntime, pValue).ToBool(pRuntime);
+ bEmpty = CJS_Value(pValue).ToBool(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"aFields");
- aFields = CJS_Array(CJS_Value(pRuntime, pValue).ToV8Array(pRuntime));
+ aFields = CJS_Array(CJS_Value(pValue).ToV8Array(pRuntime));
}
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -669,7 +670,7 @@ bool Document::submitForm(CJS_Runtime* pRuntime,
std::vector<CPDF_FormField*> fieldObjects;
for (int i = 0, sz = aFields.GetLength(pRuntime); i < sz; ++i) {
- CJS_Value valName = aFields.GetElement(pRuntime, i);
+ CJS_Value valName(aFields.GetElement(pRuntime, i));
WideString sName = valName.ToWideString(pRuntime);
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j) {
@@ -734,22 +735,22 @@ bool Document::mailDoc(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pObj = params[0].ToV8Object(pRuntime);
v8::Local<v8::Value> pValue = pRuntime->GetObjectProperty(pObj, L"bUI");
- bUI = CJS_Value(pRuntime, pValue).ToBool(pRuntime);
+ bUI = CJS_Value(pValue).ToBool(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"cTo");
- cTo = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+ cTo = CJS_Value(pValue).ToWideString(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"cCc");
- cCc = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+ cCc = CJS_Value(pValue).ToWideString(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"cBcc");
- cBcc = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+ cBcc = CJS_Value(pValue).ToWideString(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"cSubject");
- cSubject = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+ cSubject = CJS_Value(pValue).ToWideString(pRuntime);
pValue = pRuntime->GetObjectProperty(pObj, L"cMsg");
- cMsg = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+ cMsg = CJS_Value(pValue).ToWideString(pRuntime);
}
pRuntime->BeginBlock();
@@ -832,7 +833,7 @@ bool Document::get_info(CJS_Runtime* pRuntime,
pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger()));
}
}
- vp->Set(pRuntime, pObj);
+ vp->Set(pObj);
return true;
}
@@ -856,7 +857,8 @@ bool Document::getPropertyInternal(CJS_Runtime* pRuntime,
if (!pDictionary)
return false;
- vp->Set(pRuntime, pDictionary->GetUnicodeTextFor(propName));
+ vp->Set(
+ pRuntime->NewString(pDictionary->GetUnicodeTextFor(propName).c_str()));
return true;
}
@@ -915,7 +917,7 @@ bool Document::get_delay(CJS_Runtime* pRuntime,
*sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- vp->Set(pRuntime, m_bDelay);
+ vp->Set(pRuntime->NewBoolean(m_bDelay));
return true;
}
@@ -1021,7 +1023,7 @@ bool Document::get_num_pages(CJS_Runtime* pRuntime,
*sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- vp->Set(pRuntime, m_pFormFillEnv->GetPageCount());
+ vp->Set(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
return true;
}
@@ -1036,7 +1038,7 @@ bool Document::get_external(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
// In Chrome case, should always return true.
- vp->Set(pRuntime, true);
+ vp->Set(pRuntime->NewBoolean(true));
return true;
}
@@ -1049,7 +1051,7 @@ bool Document::set_external(CJS_Runtime* pRuntime,
bool Document::get_filesize(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, 0);
+ vp->Set(pRuntime->NewNumber(0));
return true;
}
@@ -1091,7 +1093,7 @@ bool Document::get_URL(CJS_Runtime* pRuntime,
*sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- vp->Set(pRuntime, m_pFormFillEnv->JS_docGetFilePath());
+ vp->Set(pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
return true;
}
@@ -1105,7 +1107,7 @@ bool Document::set_URL(CJS_Runtime* pRuntime,
bool Document::get_base_URL(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, m_cwBaseURL);
+ vp->Set(pRuntime->NewString(m_cwBaseURL.c_str()));
return true;
}
@@ -1125,7 +1127,7 @@ bool Document::get_calculate(CJS_Runtime* pRuntime,
}
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
- vp->Set(pRuntime, !!pInterForm->IsCalculateEnabled());
+ vp->Set(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
return true;
}
@@ -1158,9 +1160,10 @@ bool Document::get_document_file_name(CJS_Runtime* pRuntime,
}
if (i > 0 && i < wsFilePath.GetLength())
- vp->Set(pRuntime, wsFilePath.GetBuffer(wsFilePath.GetLength()) + i);
+ vp->Set(
+ pRuntime->NewString(wsFilePath.GetBuffer(wsFilePath.GetLength()) + i));
else
- vp->Set(pRuntime, L"");
+ vp->Set(pRuntime->NewString(L""));
return true;
}
@@ -1179,7 +1182,8 @@ bool Document::get_path(CJS_Runtime* pRuntime,
*sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- vp->Set(pRuntime, app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()));
+ vp->Set(pRuntime->NewString(
+ app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
return true;
}
@@ -1275,7 +1279,7 @@ bool Document::getAnnot(CJS_Runtime* pRuntime,
static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
pAnnot->SetSDKAnnot(pSDKBAAnnot);
- vRet = CJS_Value(pRuntime, pJS_Annot);
+ vRet = CJS_Value(pJS_Annot);
return true;
}
@@ -1313,7 +1317,7 @@ bool Document::getAnnots(CJS_Runtime* pRuntime,
static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
pAnnot->SetSDKAnnot(static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur.Get()));
- annots.SetElement(pRuntime, i, CJS_Value(pRuntime, pJS_Annot));
+ annots.SetElement(pRuntime, i, CJS_Value(pJS_Annot));
}
}
vRet = CJS_Value(pRuntime, annots);
@@ -1324,7 +1328,7 @@ bool Document::getAnnot3D(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
WideString& sError) {
- vRet.SetNull(pRuntime);
+ vRet.Set(pRuntime->NewNull());
return true;
}
@@ -1388,7 +1392,7 @@ bool Document::get_icons(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
if (m_IconNames.empty()) {
- vp->SetNull(pRuntime);
+ vp->Set(pRuntime->NewNull());
return true;
}
@@ -1404,10 +1408,10 @@ bool Document::get_icons(CJS_Runtime* pRuntime,
static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
pIcon->SetIconName(name);
- Icons.SetElement(pRuntime, i++, CJS_Value(pRuntime, pJS_Icon));
+ Icons.SetElement(pRuntime, i++, CJS_Value(pJS_Icon));
}
- vp->Set(pRuntime, Icons);
+ vp->Set(Icons.ToV8Array(pRuntime));
return true;
}
@@ -1440,7 +1444,7 @@ bool Document::getIcon(CJS_Runtime* pRuntime,
CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
pIcon->SetIconName(*it);
- vRet = CJS_Value(pRuntime, pJS_Icon);
+ vRet = CJS_Value(pJS_Icon);
return true;
}
@@ -1622,7 +1626,7 @@ bool Document::getPrintParams(CJS_Runtime* pRuntime,
// Not implemented yet.
- vRet = CJS_Value(pRuntime, pRetObj);
+ vRet = CJS_Value(pRetObj);
return true;
}
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 155e7cea43..ce94fd869a 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -400,16 +400,16 @@ bool Field::get_alignment(CJS_Runtime* pRuntime,
switch (pFormControl->GetControlAlignment()) {
case 1:
- vp->Set(pRuntime, L"center");
+ vp->Set(pRuntime->NewString(L"center"));
break;
case 0:
- vp->Set(pRuntime, L"left");
+ vp->Set(pRuntime->NewString(L"left"));
break;
case 2:
- vp->Set(pRuntime, L"right");
+ vp->Set(pRuntime->NewString(L"right"));
break;
default:
- vp->Set(pRuntime, L"");
+ vp->Set(pRuntime->NewString(L""));
}
return true;
@@ -442,22 +442,22 @@ bool Field::get_border_style(CJS_Runtime* pRuntime,
switch (pWidget->GetBorderStyle()) {
case BorderStyle::SOLID:
- vp->Set(pRuntime, L"solid");
+ vp->Set(pRuntime->NewString(L"solid"));
break;
case BorderStyle::DASH:
- vp->Set(pRuntime, L"dashed");
+ vp->Set(pRuntime->NewString(L"dashed"));
break;
case BorderStyle::BEVELED:
- vp->Set(pRuntime, L"beveled");
+ vp->Set(pRuntime->NewString(L"beveled"));
break;
case BorderStyle::INSET:
- vp->Set(pRuntime, L"inset");
+ vp->Set(pRuntime->NewString(L"inset"));
break;
case BorderStyle::UNDERLINE:
- vp->Set(pRuntime, L"underline");
+ vp->Set(pRuntime->NewString(L"underline"));
break;
default:
- vp->Set(pRuntime, L"");
+ vp->Set(pRuntime->NewString(L""));
break;
}
return true;
@@ -555,7 +555,7 @@ bool Field::get_button_align_x(CJS_Runtime* pRuntime,
float fBottom;
IconFit.GetIconPosition(fLeft, fBottom);
- vp->Set(pRuntime, static_cast<int32_t>(fLeft));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
return true;
}
@@ -589,7 +589,7 @@ bool Field::get_button_align_y(CJS_Runtime* pRuntime,
float fBottom;
IconFit.GetIconPosition(fLeft, fBottom);
- vp->Set(pRuntime, static_cast<int32_t>(fBottom));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
return true;
}
@@ -617,7 +617,7 @@ bool Field::get_button_fit_bounds(CJS_Runtime* pRuntime,
if (!pFormControl)
return false;
- vp->Set(pRuntime, pFormControl->GetIconFit().GetFittingBounds());
+ vp->Set(pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds()));
return true;
}
@@ -645,7 +645,7 @@ bool Field::get_button_position(CJS_Runtime* pRuntime,
if (!pFormControl)
return false;
- vp->Set(pRuntime, pFormControl->GetTextPosition());
+ vp->Set(pRuntime->NewNumber(pFormControl->GetTextPosition()));
return true;
}
@@ -673,7 +673,8 @@ bool Field::get_button_scale_how(CJS_Runtime* pRuntime,
if (!pFormControl)
return false;
- vp->Set(pRuntime, pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1);
+ vp->Set(pRuntime->NewBoolean(
+ pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1));
return true;
}
@@ -705,16 +706,16 @@ bool Field::get_button_scale_when(CJS_Runtime* pRuntime,
int ScaleM = IconFit.GetScaleMethod();
switch (ScaleM) {
case CPDF_IconFit::Always:
- vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Always));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Always)));
break;
case CPDF_IconFit::Bigger:
- vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Bigger));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Bigger)));
break;
case CPDF_IconFit::Never:
- vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Never));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Never)));
break;
case CPDF_IconFit::Smaller:
- vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Smaller));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller)));
break;
}
return true;
@@ -744,8 +745,8 @@ bool Field::get_calc_order_index(CJS_Runtime* pRuntime,
CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
- vp->Set(pRuntime, static_cast<int32_t>(
- pInterForm->FindFieldInCalculationOrder(pFormField)));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(
+ pInterForm->FindFieldInCalculationOrder(pFormField))));
return true;
}
@@ -769,7 +770,7 @@ bool Field::get_char_limit(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
return false;
- vp->Set(pRuntime, static_cast<int32_t>(pFormField->GetMaxLen()));
+ vp->Set(pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen())));
return true;
}
@@ -791,7 +792,8 @@ bool Field::get_comb(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_COMB));
+ vp->Set(
+ pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)));
return true;
}
@@ -817,8 +819,8 @@ bool Field::get_commit_on_sel_change(CJS_Runtime* pRuntime,
return false;
}
- vp->Set(pRuntime,
- !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)));
return true;
}
@@ -844,11 +846,11 @@ bool Field::get_current_value_indices(CJS_Runtime* pRuntime,
int count = pFormField->CountSelectedItems();
if (count <= 0) {
- vp->Set(pRuntime, -1);
+ vp->Set(pRuntime->NewNumber(-1));
return true;
}
if (count == 1) {
- vp->Set(pRuntime, pFormField->GetSelectedIndex(0));
+ vp->Set(pRuntime->NewNumber(pFormField->GetSelectedIndex(0)));
return true;
}
@@ -857,7 +859,7 @@ bool Field::get_current_value_indices(CJS_Runtime* pRuntime,
SelArray.SetElement(pRuntime, i,
CJS_Value(pRuntime, pFormField->GetSelectedIndex(i)));
}
- vp->Set(pRuntime, SelArray);
+ vp->Set(SelArray.ToV8Array(pRuntime));
return true;
}
@@ -939,7 +941,7 @@ bool Field::get_default_value(CJS_Runtime* pRuntime,
return false;
}
- vp->Set(pRuntime, pFormField->GetDefaultValue());
+ vp->Set(pRuntime->NewString(pFormField->GetDefaultValue().c_str()));
return true;
}
@@ -963,7 +965,8 @@ bool Field::get_do_not_scroll(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)));
return true;
}
@@ -989,8 +992,8 @@ bool Field::get_do_not_spell_check(CJS_Runtime* pRuntime,
return false;
}
- vp->Set(pRuntime,
- !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)));
return true;
}
@@ -1013,7 +1016,7 @@ void Field::SetDelay(bool bDelay) {
bool Field::get_delay(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, m_bDelay);
+ vp->Set(pRuntime->NewBoolean(m_bDelay));
return true;
}
@@ -1045,16 +1048,16 @@ bool Field::get_display(CJS_Runtime* pRuntime,
uint32_t dwFlag = pWidget->GetFlags();
if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
- vp->Set(pRuntime, 1);
+ vp->Set(pRuntime->NewNumber(1));
return true;
}
if (ANNOTFLAG_PRINT & dwFlag) {
if (ANNOTFLAG_NOVIEW & dwFlag)
- vp->Set(pRuntime, 3);
+ vp->Set(pRuntime->NewNumber(3));
else
- vp->Set(pRuntime, 0);
+ vp->Set(pRuntime->NewNumber(0));
} else {
- vp->Set(pRuntime, 2);
+ vp->Set(pRuntime->NewNumber(2));
}
return true;
}
@@ -1111,7 +1114,7 @@ void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
bool Field::get_doc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- vp->Set(pRuntime, m_pJSDoc->GetCJSDoc());
+ vp->Set(m_pJSDoc->GetCJSDoc()->ToV8Object());
return true;
}
@@ -1132,7 +1135,8 @@ bool Field::get_editable(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT));
+ vp->Set(
+ pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)));
return true;
}
@@ -1177,7 +1181,7 @@ bool Field::get_export_values(CJS_Runtime* pRuntime,
CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
}
- vp->Set(pRuntime, ExportValusArray);
+ vp->Set(ExportValusArray.ToV8Array(pRuntime));
return true;
}
@@ -1208,7 +1212,8 @@ bool Field::get_file_select(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)));
return true;
}
@@ -1263,7 +1268,7 @@ bool Field::get_fill_color(CJS_Runtime* pRuntime,
return false;
}
- vp->Set(pRuntime, color::ConvertPWLColorToArray(pRuntime, color));
+ vp->Set(color::ConvertPWLColorToArray(pRuntime, color).ToV8Array(pRuntime));
return true;
}
@@ -1297,8 +1302,8 @@ bool Field::get_hidden(CJS_Runtime* pRuntime,
return false;
uint32_t dwFlags = pWidget->GetFlags();
- vp->Set(pRuntime,
- ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags);
+ vp->Set(pRuntime->NewBoolean(ANNOTFLAG_INVISIBLE & dwFlags ||
+ ANNOTFLAG_HIDDEN & dwFlags));
return true;
}
@@ -1345,19 +1350,19 @@ bool Field::get_highlight(CJS_Runtime* pRuntime,
int eHM = pFormControl->GetHighlightingMode();
switch (eHM) {
case CPDF_FormControl::None:
- vp->Set(pRuntime, L"none");
+ vp->Set(pRuntime->NewString(L"none"));
break;
case CPDF_FormControl::Push:
- vp->Set(pRuntime, L"push");
+ vp->Set(pRuntime->NewString(L"push"));
break;
case CPDF_FormControl::Invert:
- vp->Set(pRuntime, L"invert");
+ vp->Set(pRuntime->NewString(L"invert"));
break;
case CPDF_FormControl::Outline:
- vp->Set(pRuntime, L"outline");
+ vp->Set(pRuntime->NewString(L"outline"));
break;
case CPDF_FormControl::Toggle:
- vp->Set(pRuntime, L"toggle");
+ vp->Set(pRuntime->NewString(L"toggle"));
break;
}
return true;
@@ -1392,7 +1397,7 @@ bool Field::get_line_width(CJS_Runtime* pRuntime,
if (!pWidget)
return false;
- vp->Set(pRuntime, pWidget->GetBorderWidth());
+ vp->Set(pRuntime->NewNumber(pWidget->GetBorderWidth()));
return true;
}
@@ -1463,7 +1468,8 @@ bool Field::get_multiline(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)));
return true;
}
@@ -1486,7 +1492,8 @@ bool Field::get_multiple_selection(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)));
return true;
}
@@ -1502,7 +1509,7 @@ bool Field::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
if (FieldArray.empty())
return false;
- vp->Set(pRuntime, m_FieldName);
+ vp->Set(pRuntime->NewString(m_FieldName.c_str()));
return true;
}
@@ -1525,7 +1532,7 @@ bool Field::get_num_items(CJS_Runtime* pRuntime,
return false;
}
- vp->Set(pRuntime, pFormField->CountOptions());
+ vp->Set(pRuntime->NewNumber(pFormField->CountOptions()));
return true;
}
@@ -1547,7 +1554,7 @@ bool Field::get_page(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets);
if (widgets.empty()) {
- vp->Set(pRuntime, -1);
+ vp->Set(pRuntime->NewNumber(-1));
return true;
}
@@ -1569,7 +1576,7 @@ bool Field::get_page(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
++i;
}
- vp->Set(pRuntime, PageArray);
+ vp->Set(PageArray.ToV8Array(pRuntime));
return true;
}
@@ -1593,7 +1600,8 @@ bool Field::get_password(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)));
return true;
}
@@ -1618,7 +1626,7 @@ bool Field::get_print(CJS_Runtime* pRuntime,
if (!pWidget)
return false;
- vp->Set(pRuntime, !!(pWidget->GetFlags() & ANNOTFLAG_PRINT));
+ vp->Set(pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT)));
return true;
}
@@ -1692,7 +1700,8 @@ bool Field::get_radios_in_unison(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)));
return true;
}
@@ -1712,7 +1721,8 @@ bool Field::get_readonly(CJS_Runtime* pRuntime,
if (FieldArray.empty())
return false;
- vp->Set(pRuntime, !!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY));
+ vp->Set(pRuntime->NewBoolean(
+ !!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY)));
return true;
}
@@ -1747,7 +1757,7 @@ bool Field::get_rect(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)));
rcArray.SetElement(pRuntime, 3,
CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)));
- vp->Set(pRuntime, rcArray);
+ vp->Set(rcArray.ToV8Array(pRuntime));
return true;
}
@@ -1760,16 +1770,15 @@ bool Field::set_rect(CJS_Runtime* pRuntime,
return false;
CJS_Array rcArray = vp.ToArray(pRuntime);
- 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<float>(Upper_Leftx.ToInt(pRuntime));
- pArray[1] = static_cast<float>(Lower_Righty.ToInt(pRuntime));
- pArray[2] = static_cast<float>(Lower_Rightx.ToInt(pRuntime));
- pArray[3] = static_cast<float>(Upper_Lefty.ToInt(pRuntime));
+ pArray[0] =
+ static_cast<float>(rcArray.GetElement(pRuntime, 0).ToInt(pRuntime));
+ pArray[1] =
+ static_cast<float>(rcArray.GetElement(pRuntime, 1).ToInt(pRuntime));
+ pArray[2] =
+ static_cast<float>(rcArray.GetElement(pRuntime, 2).ToInt(pRuntime));
+ pArray[3] =
+ static_cast<float>(rcArray.GetElement(pRuntime, 3).ToInt(pRuntime));
CFX_FloatRect crRect(pArray);
if (m_bDelay) {
@@ -1852,7 +1861,8 @@ bool Field::get_required(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)));
return true;
}
@@ -1879,7 +1889,8 @@ bool Field::get_rich_text(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
return false;
- vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT));
+ vp->Set(pRuntime->NewBoolean(
+ !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)));
return true;
}
@@ -1916,7 +1927,7 @@ bool Field::get_rotation(CJS_Runtime* pRuntime,
if (!pFormControl)
return false;
- vp->Set(pRuntime, pFormControl->GetRotation());
+ vp->Set(pRuntime->NewNumber(pFormControl->GetRotation()));
return true;
}
@@ -1961,7 +1972,7 @@ bool Field::get_stroke_color(CJS_Runtime* pRuntime,
return false;
}
- vp->Set(pRuntime, color::ConvertPWLColorToArray(pRuntime, color));
+ vp->Set(color::ConvertPWLColorToArray(pRuntime, color).ToV8Array(pRuntime));
return true;
}
@@ -2017,7 +2028,8 @@ bool Field::get_style(CJS_Runtime* pRuntime,
csBCaption = "check";
break;
}
- vp->Set(pRuntime, csBCaption);
+ vp->Set(
+ pRuntime->NewString(WideString::FromLocal(csBCaption.c_str()).c_str()));
return true;
}
@@ -2069,7 +2081,7 @@ bool Field::get_text_color(CJS_Runtime* pRuntime,
if (iColorType == CFX_Color::kTransparent)
crRet = CFX_Color(CFX_Color::kTransparent);
- vp->Set(pRuntime, color::ConvertPWLColorToArray(pRuntime, crRet));
+ vp->Set(color::ConvertPWLColorToArray(pRuntime, crRet).ToV8Array(pRuntime));
return true;
}
@@ -2107,7 +2119,8 @@ bool Field::get_text_font(CJS_Runtime* pRuntime,
if (!pFont)
return false;
- vp->Set(pRuntime, pFont->GetBaseFont());
+ vp->Set(pRuntime->NewString(
+ WideString::FromLocal(pFont->GetBaseFont().c_str()).c_str()));
return true;
}
@@ -2141,7 +2154,7 @@ bool Field::get_text_size(CJS_Runtime* pRuntime,
float fFontSize;
CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
FieldAppearance.GetFont(&fFontSize);
- vp->Set(pRuntime, static_cast<int>(fFontSize));
+ vp->Set(pRuntime->NewNumber(static_cast<int>(fFontSize)));
return true;
}
@@ -2160,31 +2173,31 @@ bool Field::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
CPDF_FormField* pFormField = FieldArray[0];
switch (pFormField->GetFieldType()) {
case FIELDTYPE_UNKNOWN:
- vp->Set(pRuntime, L"unknown");
+ vp->Set(pRuntime->NewString(L"unknown"));
break;
case FIELDTYPE_PUSHBUTTON:
- vp->Set(pRuntime, L"button");
+ vp->Set(pRuntime->NewString(L"button"));
break;
case FIELDTYPE_CHECKBOX:
- vp->Set(pRuntime, L"checkbox");
+ vp->Set(pRuntime->NewString(L"checkbox"));
break;
case FIELDTYPE_RADIOBUTTON:
- vp->Set(pRuntime, L"radiobutton");
+ vp->Set(pRuntime->NewString(L"radiobutton"));
break;
case FIELDTYPE_COMBOBOX:
- vp->Set(pRuntime, L"combobox");
+ vp->Set(pRuntime->NewString(L"combobox"));
break;
case FIELDTYPE_LISTBOX:
- vp->Set(pRuntime, L"listbox");
+ vp->Set(pRuntime->NewString(L"listbox"));
break;
case FIELDTYPE_TEXTFIELD:
- vp->Set(pRuntime, L"text");
+ vp->Set(pRuntime->NewString(L"text"));
break;
case FIELDTYPE_SIGNATURE:
- vp->Set(pRuntime, L"signature");
+ vp->Set(pRuntime->NewString(L"signature"));
break;
default:
- vp->Set(pRuntime, L"unknown");
+ vp->Set(pRuntime->NewString(L"unknown"));
break;
}
return true;
@@ -2205,7 +2218,7 @@ bool Field::get_user_name(CJS_Runtime* pRuntime,
if (FieldArray.empty())
return false;
- vp->Set(pRuntime, FieldArray[0]->GetAlternateName());
+ vp->Set(pRuntime->NewString(FieldArray[0]->GetAlternateName().c_str()));
return true;
}
@@ -2229,12 +2242,12 @@ bool Field::get_value(CJS_Runtime* pRuntime,
return false;
case FIELDTYPE_COMBOBOX:
case FIELDTYPE_TEXTFIELD:
- vp->Set(pRuntime, pFormField->GetValue());
+ vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
break;
case FIELDTYPE_LISTBOX: {
if (pFormField->CountSelectedItems() > 1) {
CJS_Array ValueArray;
- CJS_Value ElementValue(pRuntime);
+ CJS_Value ElementValue;
int iIndex;
for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
iIndex = pFormField->GetSelectedIndex(i);
@@ -2246,9 +2259,9 @@ bool Field::get_value(CJS_Runtime* pRuntime,
}
ValueArray.SetElement(pRuntime, i, ElementValue);
}
- vp->Set(pRuntime, ValueArray);
+ vp->Set(ValueArray.ToV8Array(pRuntime));
} else {
- vp->Set(pRuntime, pFormField->GetValue());
+ vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
}
break;
}
@@ -2257,18 +2270,19 @@ bool Field::get_value(CJS_Runtime* pRuntime,
bool bFind = false;
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
if (pFormField->GetControl(i)->IsChecked()) {
- vp->Set(pRuntime, pFormField->GetControl(i)->GetExportValue());
+ vp->Set(pRuntime->NewString(
+ pFormField->GetControl(i)->GetExportValue().c_str()));
bFind = true;
break;
}
}
if (!bFind)
- vp->Set(pRuntime, L"Off");
+ vp->Set(pRuntime->NewString(L"Off"));
break;
}
default:
- vp->Set(pRuntime, pFormField->GetValue());
+ vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
break;
}
vp->MaybeCoerceToNumber(pRuntime);
@@ -2283,9 +2297,9 @@ bool Field::set_value(CJS_Runtime* pRuntime,
std::vector<WideString> strArray;
if (vp.IsArrayObject()) {
- CJS_Array ValueArray = vp.ToArray(pRuntime);
+ CJS_Array ValueArray(vp.ToArray(pRuntime));
for (int i = 0, sz = ValueArray.GetLength(pRuntime); i < sz; i++) {
- CJS_Value ElementValue = ValueArray.GetElement(pRuntime, i);
+ CJS_Value ElementValue(ValueArray.GetElement(pRuntime, i));
strArray.push_back(ElementValue.ToWideString(pRuntime));
}
} else {
@@ -2370,7 +2384,8 @@ bool Field::get_value_as_string(CJS_Runtime* pRuntime,
if (!pFormField->CountControls())
return false;
- vp->Set(pRuntime, pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off");
+ vp->Set(pRuntime->NewString(
+ pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off"));
return true;
}
@@ -2378,10 +2393,11 @@ bool Field::get_value_as_string(CJS_Runtime* pRuntime,
!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) {
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
if (pFormField->GetControl(i)->IsChecked()) {
- vp->Set(pRuntime, pFormField->GetControl(i)->GetExportValue().c_str());
+ vp->Set(pRuntime->NewString(
+ pFormField->GetControl(i)->GetExportValue().c_str()));
break;
} else {
- vp->Set(pRuntime, L"Off");
+ vp->Set(pRuntime->NewString(L"Off"));
}
}
return true;
@@ -2389,9 +2405,9 @@ bool Field::get_value_as_string(CJS_Runtime* pRuntime,
if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX &&
(pFormField->CountSelectedItems() > 1)) {
- vp->Set(pRuntime, L"");
+ vp->Set(pRuntime->NewString(L""));
} else {
- vp->Set(pRuntime, pFormField->GetValue().c_str());
+ vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
}
return true;
@@ -2485,7 +2501,7 @@ bool Field::buttonGetIcon(CJS_Runtime* pRuntime,
return false;
CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
- vRet = CJS_Value(pRuntime, pJS_Icon);
+ vRet = CJS_Value(pJS_Icon);
return true;
}
@@ -2619,7 +2635,7 @@ bool Field::getArray(CJS_Runtime* pRuntime,
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pObj));
Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
pField->AttachField(m_pJSDoc, *pStr);
- FormFieldArray.SetElement(pRuntime, j++, CJS_Value(pRuntime, pJSField));
+ FormFieldArray.SetElement(pRuntime, j++, CJS_Value(pJSField));
}
vRet = CJS_Value(pRuntime, FormFieldArray);
@@ -2835,7 +2851,7 @@ bool Field::signatureValidate(CJS_Runtime* pRuntime,
bool Field::get_source(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, static_cast<CJS_Object*>(nullptr));
+ vp->Set(v8::Local<v8::Value>());
return true;
}
diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp
index a5fa3faa20..53f549d2f2 100644
--- a/fpdfsdk/javascript/Icon.cpp
+++ b/fpdfsdk/javascript/Icon.cpp
@@ -26,7 +26,7 @@ Icon::Icon(CJS_Object* pJSObject)
Icon::~Icon() {}
bool Icon::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- vp->Set(pRuntime, m_swIconName);
+ vp->Set(pRuntime->NewString(m_swIconName.c_str()));
return true;
}
diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h
index 4bcdcdf994..46469d7dec 100644
--- a/fpdfsdk/javascript/JS_Define.h
+++ b/fpdfsdk/javascript/JS_Define.h
@@ -52,13 +52,13 @@ void JSPropGetter(const char* prop_name_string,
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
WideString sError;
- CJS_Value prop_value(pRuntime);
+ CJS_Value prop_value;
if (!(pObj->*M)(pRuntime, &prop_value, &sError)) {
pRuntime->Error(
JSFormatErrorString(class_name_string, prop_name_string, sError));
return;
}
- info.GetReturnValue().Set(prop_value.ToV8Value(pRuntime));
+ info.GetReturnValue().Set(prop_value.ToV8Value());
}
template <class C, bool (C::*M)(CJS_Runtime*, const CJS_Value&, WideString*)>
@@ -80,7 +80,7 @@ void JSPropSetter(const char* prop_name_string,
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
WideString sError;
- CJS_Value prop_value(pRuntime, value);
+ CJS_Value prop_value(value);
if (!(pObj->*M)(pRuntime, prop_value, &sError)) {
pRuntime->Error(
JSFormatErrorString(class_name_string, prop_name_string, sError));
@@ -113,23 +113,25 @@ void JSMethod(const char* method_name_string,
CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
if (!pRuntime)
return;
+
std::vector<CJS_Value> parameters;
- for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
- parameters.push_back(CJS_Value(pRuntime, info[i]));
- }
+ for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
+ parameters.push_back(CJS_Value(info[i]));
+
CJS_Object* pJSObj =
static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(info.Holder()));
if (!pJSObj)
return;
+
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
WideString sError;
- CJS_Value valueRes(pRuntime);
+ CJS_Value valueRes;
if (!(pObj->*M)(pRuntime, parameters, valueRes, sError)) {
pRuntime->Error(
JSFormatErrorString(class_name_string, method_name_string, sError));
return;
}
- info.GetReturnValue().Set(valueRes.ToV8Value(pRuntime));
+ info.GetReturnValue().Set(valueRes.ToV8Value());
}
#define JS_STATIC_METHOD(method_name, class_name) \
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index fb38e8cbb1..7de267eaf3 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -178,90 +178,43 @@ double JS_LocalTime(double d) {
} // namespace
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime) {}
+CJS_Value::CJS_Value() {}
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue)
- : m_pValue(pValue) {}
+CJS_Value::CJS_Value(v8::Local<v8::Value> pValue) : m_pValue(pValue) {}
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, int iValue)
- : CJS_Value(pRuntime, pRuntime->NewNumber(iValue)) {}
+ : CJS_Value(pRuntime->NewNumber(iValue)) {}
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, bool bValue)
- : CJS_Value(pRuntime, pRuntime->NewBoolean(bValue)) {}
+ : CJS_Value(pRuntime->NewBoolean(bValue)) {}
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, double dValue)
- : CJS_Value(pRuntime, pRuntime->NewNumber(dValue)) {}
+ : CJS_Value(pRuntime->NewNumber(dValue)) {}
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj) {
+CJS_Value::CJS_Value(CJS_Object* pObj) {
if (pObj)
m_pValue = pObj->ToV8Object();
}
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const wchar_t* pWstr)
- : CJS_Value(pRuntime, pRuntime->NewString(pWstr)) {}
+ : CJS_Value(pRuntime->NewString(pWstr)) {}
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const char* pStr)
- : CJS_Value(pRuntime,
- pRuntime->NewString(WideString::FromLocal(pStr).c_str())) {}
+ : CJS_Value(pRuntime->NewString(WideString::FromLocal(pStr).c_str())) {}
CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array)
- : CJS_Value(pRuntime, array.ToV8Array(pRuntime)) {}
+ : CJS_Value(array.ToV8Array(pRuntime)) {}
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date)
- : CJS_Value(pRuntime, date.ToV8Date(pRuntime)) {}
+CJS_Value::CJS_Value(const CJS_Date& date) : CJS_Value(date.ToV8Date()) {}
CJS_Value::~CJS_Value() {}
CJS_Value::CJS_Value(const CJS_Value& other) = default;
-void CJS_Value::SetNull(CJS_Runtime* pRuntime) {
- m_pValue = pRuntime->NewNull();
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue) {
+void CJS_Value::Set(v8::Local<v8::Value> pValue) {
m_pValue = pValue;
}
-void CJS_Value::Set(CJS_Runtime* pRuntime, int val) {
- m_pValue = pRuntime->NewNumber(val);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, bool val) {
- m_pValue = pRuntime->NewBoolean(val);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, double val) {
- m_pValue = pRuntime->NewNumber(val);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, CJS_Object* pObj) {
- m_pValue = pObj->ToV8Object();
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, CJS_Document* pJsDoc) {
- m_pValue = pJsDoc->ToV8Object();
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const ByteString& str) {
- m_pValue = pRuntime->NewString(WideString::FromLocal(str.c_str()).c_str());
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const WideString& str) {
- m_pValue = pRuntime->NewString(str.c_str());
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const wchar_t* c_string) {
- m_pValue = pRuntime->NewString(c_string);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const CJS_Array& array) {
- m_pValue = array.ToV8Array(pRuntime);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const CJS_Date& date) {
- m_pValue = date.ToV8Date(pRuntime);
-}
-
int CJS_Value::ToInt(CJS_Runtime* pRuntime) const {
return pRuntime->ToInt32(m_pValue);
}
@@ -292,7 +245,7 @@ CJS_Array CJS_Value::ToArray(CJS_Runtime* pRuntime) const {
return CJS_Array(pRuntime->ToArray(m_pValue));
}
-CJS_Date CJS_Value::ToDate(CJS_Runtime* pRuntime) const {
+CJS_Date CJS_Value::ToDate() const {
ASSERT(IsDateObject());
v8::Local<v8::Value> mutable_value = m_pValue;
return CJS_Date(mutable_value.As<v8::Date>());
@@ -310,7 +263,7 @@ ByteString CJS_Value::ToByteString(CJS_Runtime* pRuntime) const {
return ByteString::FromUnicode(ToWideString(pRuntime));
}
-v8::Local<v8::Value> CJS_Value::ToV8Value(CJS_Runtime* pRuntime) const {
+v8::Local<v8::Value> CJS_Value::ToV8Value() const {
return m_pValue;
}
@@ -378,9 +331,9 @@ CJS_Array::~CJS_Array() {}
CJS_Value CJS_Array::GetElement(CJS_Runtime* pRuntime, unsigned index) const {
if (!m_pArray.IsEmpty())
- return CJS_Value(pRuntime, pRuntime->GetArrayElement(m_pArray, index));
-
- return CJS_Value(pRuntime);
+ return CJS_Value(
+ v8::Local<v8::Value>(pRuntime->GetArrayElement(m_pArray, index)));
+ return {};
}
void CJS_Array::SetElement(CJS_Runtime* pRuntime,
@@ -389,7 +342,7 @@ void CJS_Array::SetElement(CJS_Runtime* pRuntime,
if (m_pArray.IsEmpty())
m_pArray = pRuntime->NewArray();
- pRuntime->PutArrayElement(m_pArray, index, value.ToV8Value(pRuntime));
+ pRuntime->PutArrayElement(m_pArray, index, value.ToV8Value());
}
int CJS_Array::GetLength(CJS_Runtime* pRuntime) const {
@@ -470,7 +423,7 @@ int CJS_Date::GetSeconds(CJS_Runtime* pRuntime) const {
return JS_GetSecFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
}
-v8::Local<v8::Date> CJS_Date::ToV8Date(CJS_Runtime* pRuntime) const {
+v8::Local<v8::Date> CJS_Date::ToV8Date() const {
return m_pDate;
}
@@ -585,7 +538,7 @@ std::vector<CJS_Value> ExpandKeywordParams(
...) {
ASSERT(nKeywords);
- std::vector<CJS_Value> result(nKeywords, CJS_Value(pRuntime));
+ std::vector<CJS_Value> result(nKeywords, CJS_Value());
size_t size = std::min(originals.size(), nKeywords);
for (size_t i = 0; i < size; ++i)
result[i] = originals[i];
@@ -595,7 +548,7 @@ std::vector<CJS_Value> ExpandKeywordParams(
return result;
}
v8::Local<v8::Object> pObj = originals[0].ToV8Object(pRuntime);
- result[0] = CJS_Value(pRuntime); // Make unknown.
+ result[0] = CJS_Value(); // Make unknown.
va_list ap;
va_start(ap, nKeywords);
@@ -603,7 +556,7 @@ std::vector<CJS_Value> ExpandKeywordParams(
const wchar_t* property = va_arg(ap, const wchar_t*);
v8::Local<v8::Value> v8Value = pRuntime->GetObjectProperty(pObj, property);
if (!v8Value->IsUndefined())
- result[i] = CJS_Value(pRuntime, v8Value);
+ result[i] = CJS_Value(v8Value);
}
va_end(ap);
return result;
diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h
index 49dd2492da..72d381e188 100644
--- a/fpdfsdk/javascript/JS_Value.h
+++ b/fpdfsdk/javascript/JS_Value.h
@@ -32,34 +32,22 @@ class CJS_Value {
static Type GetValueType(v8::Local<v8::Value> value);
- explicit CJS_Value(CJS_Runtime* pRuntime);
- CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue);
+ CJS_Value();
+ explicit CJS_Value(v8::Local<v8::Value> pValue);
CJS_Value(CJS_Runtime* pRuntime, int iValue);
CJS_Value(CJS_Runtime* pRuntime, double dValue);
CJS_Value(CJS_Runtime* pRuntime, bool bValue);
- CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj);
+ explicit CJS_Value(CJS_Object* pObj);
CJS_Value(CJS_Runtime* pRuntime, const char* pStr);
CJS_Value(CJS_Runtime* pRuntime, const wchar_t* pWstr);
CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array);
- CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date);
- CJS_Value(CJS_Runtime* pRuntime, const CJS_Object* object);
+ explicit CJS_Value(const CJS_Date& date);
CJS_Value(const CJS_Value& other);
~CJS_Value();
// These calls may re-enter JS (and hence invalidate objects).
- void Set(CJS_Runtime* pRuntime, int val);
- void Set(CJS_Runtime* pRuntime, bool val);
- void Set(CJS_Runtime* pRuntime, double val);
- void Set(CJS_Runtime* pRuntime, CJS_Object* pObj);
- void Set(CJS_Runtime* pRuntime, CJS_Document* pJsDoc);
- void Set(CJS_Runtime* pRuntime, const ByteString&);
- void Set(CJS_Runtime* pRuntime, const WideString&);
- void Set(CJS_Runtime* pRuntime, const wchar_t* c_string);
- void Set(CJS_Runtime* pRuntime, const CJS_Array& array);
- void Set(CJS_Runtime* pRuntime, const CJS_Date& date);
- void Set(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue);
- void SetNull(CJS_Runtime* pRuntime);
+ void Set(v8::Local<v8::Value> pValue);
Type GetType() const { return GetValueType(m_pValue); }
@@ -70,12 +58,12 @@ class CJS_Value {
CJS_Object* ToObject(CJS_Runtime* pRuntime) const;
CJS_Document* ToDocument(CJS_Runtime* pRuntime) const;
CJS_Array ToArray(CJS_Runtime* pRuntime) const;
- CJS_Date ToDate(CJS_Runtime* pRuntime) const;
+ CJS_Date ToDate() const;
WideString ToWideString(CJS_Runtime* pRuntime) const;
ByteString ToByteString(CJS_Runtime* pRuntime) const;
v8::Local<v8::Object> ToV8Object(CJS_Runtime* pRuntime) const;
v8::Local<v8::Array> ToV8Array(CJS_Runtime* pRuntime) const;
- v8::Local<v8::Value> ToV8Value(CJS_Runtime* pRuntime) const;
+ v8::Local<v8::Value> ToV8Value() const;
// Replace the current |m_pValue| with a v8::Number if possible
// to make one from the current |m_pValue|.
@@ -133,7 +121,7 @@ class CJS_Date {
int GetMinutes(CJS_Runtime* pRuntime) const;
int GetSeconds(CJS_Runtime* pRuntime) const;
- v8::Local<v8::Date> ToV8Date(CJS_Runtime* pRuntime) const;
+ v8::Local<v8::Date> ToV8Date() const;
WideString ToWideString(int style) const;
protected:
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 5e428007ad..ccd2cfc885 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -122,15 +122,15 @@ void JSGlobalFunc(const char* func_name_string,
return;
std::vector<CJS_Value> parameters;
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
- parameters.push_back(CJS_Value(pRuntime, info[i]));
+ parameters.push_back(CJS_Value(info[i]));
}
- CJS_Value valueRes(pRuntime);
+ CJS_Value valueRes;
WideString sError;
if (!(*F)(pRuntime, parameters, valueRes, sError)) {
pRuntime->Error(JSFormatErrorString(func_name_string, nullptr, sError));
return;
}
- info.GetReturnValue().Set(valueRes.ToV8Value(pRuntime));
+ info.GetReturnValue().Set(valueRes.ToV8Value());
}
} // namespace
@@ -896,7 +896,7 @@ bool CJS_PublicMethods::AFNumber_Format(CJS_Runtime* pRuntime,
if (iNegStyle == 1 || iNegStyle == 3) {
if (Field* fTarget = pEvent->Target_Field()) {
CJS_Array arColor;
- CJS_Value vColElm(pRuntime);
+ CJS_Value vColElm;
vColElm = CJS_Value(pRuntime, L"RGB");
arColor.SetElement(pRuntime, 0, vColElm);
vColElm = CJS_Value(pRuntime, 1);
@@ -913,7 +913,7 @@ bool CJS_PublicMethods::AFNumber_Format(CJS_Runtime* pRuntime,
if (iNegStyle == 1 || iNegStyle == 3) {
if (Field* fTarget = pEvent->Target_Field()) {
CJS_Array arColor;
- CJS_Value vColElm(pRuntime);
+ CJS_Value vColElm;
vColElm = CJS_Value(pRuntime, L"RGB");
arColor.SetElement(pRuntime, 0, vColElm);
vColElm = CJS_Value(pRuntime, 0);
@@ -921,7 +921,7 @@ bool CJS_PublicMethods::AFNumber_Format(CJS_Runtime* pRuntime,
arColor.SetElement(pRuntime, 2, vColElm);
arColor.SetElement(pRuntime, 3, vColElm);
- CJS_Value vProp(pRuntime);
+ CJS_Value vProp;
fTarget->get_text_color(pRuntime, &vProp, &sError);
CFX_Color crProp =
@@ -1661,7 +1661,7 @@ bool CJS_PublicMethods::AFSimple_Calculate(CJS_Runtime* pRuntime,
return false;
}
- CJS_Value params1 = params[1];
+ CJS_Value params1(params[1]);
if (!params1.IsArrayObject() && params1.GetType() != CJS_Value::VT_string) {
sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
return false;
@@ -1826,7 +1826,7 @@ bool CJS_PublicMethods::AFExtractNums(CJS_Runtime* pRuntime,
if (nums.GetLength(pRuntime) > 0)
vRet = CJS_Value(pRuntime, nums);
else
- vRet.SetNull(pRuntime);
+ vRet.Set(pRuntime->NewNull());
return true;
}
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 9894bb82fa..1c822df1d7 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -217,11 +217,11 @@ bool app::get_active_docs(CJS_Runtime* pRuntime,
pJSDocument = static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj));
CJS_Array aDocs;
- aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument));
+ aDocs.SetElement(pRuntime, 0, CJS_Value(pJSDocument));
if (aDocs.GetLength(pRuntime) > 0)
- vp->Set(pRuntime, aDocs);
+ vp->Set(aDocs.ToV8Array(pRuntime));
else
- vp->SetNull(pRuntime);
+ vp->Set(pRuntime->NewNull());
return true;
}
@@ -235,7 +235,7 @@ bool app::set_active_docs(CJS_Runtime* pRuntime,
bool app::get_calculate(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, m_bCalculate);
+ vp->Set(pRuntime->NewBoolean(m_bCalculate));
return true;
}
@@ -250,7 +250,7 @@ bool app::set_calculate(CJS_Runtime* pRuntime,
bool app::get_forms_version(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, JS_NUM_FORMSVERSION);
+ vp->Set(pRuntime->NewNumber(JS_NUM_FORMSVERSION));
return true;
}
@@ -263,7 +263,7 @@ bool app::set_forms_version(CJS_Runtime* pRuntime,
bool app::get_viewer_type(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, JS_STR_VIEWERTYPE);
+ vp->Set(pRuntime->NewString(JS_STR_VIEWERTYPE));
return true;
}
@@ -276,7 +276,7 @@ bool app::set_viewer_type(CJS_Runtime* pRuntime,
bool app::get_viewer_variation(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, JS_STR_VIEWERVARIATION);
+ vp->Set(pRuntime->NewString(JS_STR_VIEWERVARIATION));
return true;
}
@@ -292,11 +292,11 @@ bool app::get_viewer_version(CJS_Runtime* pRuntime,
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext();
if (pXFAContext->ContainsXFAForm()) {
- vp->Set(pRuntime, JS_NUM_VIEWERVERSION_XFA);
+ vp->Set(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA));
return true;
}
#endif // PDF_ENABLE_XFA
- vp->Set(pRuntime, JS_NUM_VIEWERVERSION);
+ vp->Set(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));
return true;
}
@@ -316,11 +316,11 @@ bool app::get_platform(CJS_Runtime* pRuntime,
WideString platfrom = pFormFillEnv->GetPlatform();
if (!platfrom.IsEmpty()) {
- vp->Set(pRuntime, platfrom);
+ vp->Set(pRuntime->NewString(platfrom.c_str()));
return true;
}
#endif
- vp->Set(pRuntime, JS_STR_PLATFORM);
+ vp->Set(pRuntime->NewString(JS_STR_PLATFORM));
return true;
}
@@ -340,11 +340,11 @@ bool app::get_language(CJS_Runtime* pRuntime,
WideString language = pFormFillEnv->GetLanguage();
if (!language.IsEmpty()) {
- vp->Set(pRuntime, language);
+ vp->Set(pRuntime->NewString(language.c_str()));
return true;
}
#endif
- vp->Set(pRuntime, JS_STR_LANGUAGE);
+ vp->Set(pRuntime->NewString(JS_STR_LANGUAGE));
return true;
}
@@ -508,7 +508,7 @@ bool app::setInterval(CJS_Runtime* pRuntime,
TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
pTimerObj->SetTimer(timerRef);
- vRet = CJS_Value(pRuntime, pRetObj);
+ vRet = CJS_Value(pRetObj);
return true;
}
@@ -542,7 +542,7 @@ bool app::setTimeOut(CJS_Runtime* pRuntime,
static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
pTimerObj->SetTimer(timerRef);
- vRet = CJS_Value(pRuntime, pRetObj);
+ vRet = CJS_Value(pRetObj);
return true;
}
@@ -694,7 +694,7 @@ bool app::launchURL(CJS_Runtime* pRuntime,
bool app::get_runtime_highlight(CJS_Runtime* pRuntime,
CJS_Value* vp,
WideString* sError) {
- vp->Set(pRuntime, m_bRuntimeHighLight);
+ vp->Set(pRuntime->NewBoolean(m_bRuntimeHighLight));
return true;
}
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 2eccdae11e..37ab1cc4fe 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -261,7 +261,7 @@ bool color::set_light_gray(CJS_Runtime* pRuntime,
bool color::GetPropertyHelper(CJS_Runtime* pRuntime,
CJS_Value* vp,
CFX_Color* var) {
- vp->Set(pRuntime, ConvertPWLColorToArray(pRuntime, *var));
+ vp->Set(ConvertPWLColorToArray(pRuntime, *var).ToV8Array(pRuntime));
return true;
}
diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp
index 11b8b01f6d..361afa8cff 100644
--- a/fpdfsdk/javascript/event.cpp
+++ b/fpdfsdk/javascript/event.cpp
@@ -51,7 +51,7 @@ bool event::get_change(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Change());
+ vp->Set(pRuntime->NewString(pEvent->Change().c_str()));
return true;
}
@@ -74,7 +74,7 @@ bool event::get_change_ex(CJS_Runtime* pRuntime,
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->ChangeEx());
+ vp->Set(pRuntime->NewString(pEvent->ChangeEx().c_str()));
return true;
}
@@ -90,7 +90,7 @@ bool event::get_commit_key(CJS_Runtime* pRuntime,
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->CommitKey());
+ vp->Set(pRuntime->NewNumber(pEvent->CommitKey()));
return true;
}
@@ -109,7 +109,7 @@ bool event::get_field_full(CJS_Runtime* pRuntime,
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
return false;
- vp->Set(pRuntime, pEvent->FieldFull());
+ vp->Set(pRuntime->NewBoolean(pEvent->FieldFull()));
return true;
}
@@ -124,7 +124,7 @@ bool event::get_key_down(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->KeyDown());
+ vp->Set(pRuntime->NewBoolean(pEvent->KeyDown()));
return true;
}
@@ -139,7 +139,7 @@ bool event::get_modifier(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Modifier());
+ vp->Set(pRuntime->NewBoolean(pEvent->Modifier()));
return true;
}
@@ -152,7 +152,7 @@ bool event::set_modifier(CJS_Runtime* pRuntime,
bool event::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Name());
+ vp->Set(pRuntime->NewString(pEvent->Name()));
return true;
}
@@ -165,7 +165,7 @@ bool event::set_name(CJS_Runtime* pRuntime,
bool event::get_rc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Rc());
+ vp->Set(pRuntime->NewBoolean(pEvent->Rc()));
return true;
}
@@ -223,7 +223,7 @@ bool event::get_sel_end(CJS_Runtime* pRuntime,
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
return true;
- vp->Set(pRuntime, pEvent->SelEnd());
+ vp->Set(pRuntime->NewNumber(pEvent->SelEnd()));
return true;
}
@@ -249,7 +249,7 @@ bool event::get_sel_start(CJS_Runtime* pRuntime,
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
return true;
- vp->Set(pRuntime, pEvent->SelStart());
+ vp->Set(pRuntime->NewNumber(pEvent->SelStart()));
return true;
}
@@ -271,7 +271,7 @@ bool event::get_shift(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Shift());
+ vp->Set(pRuntime->NewBoolean(pEvent->Shift()));
return true;
}
@@ -286,7 +286,7 @@ bool event::get_source(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Source()->GetJSObject());
+ vp->Set(pEvent->Source()->GetJSObject()->ToV8Object());
return true;
}
@@ -301,7 +301,7 @@ bool event::get_target(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Target_Field()->GetJSObject());
+ vp->Set(pEvent->Target_Field()->GetJSObject()->ToV8Object());
return true;
}
@@ -316,7 +316,7 @@ bool event::get_target_name(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->TargetName());
+ vp->Set(pRuntime->NewString(pEvent->TargetName().c_str()));
return true;
}
@@ -329,7 +329,7 @@ bool event::set_target_name(CJS_Runtime* pRuntime,
bool event::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->Type());
+ vp->Set(pRuntime->NewString(pEvent->Type()));
return true;
}
@@ -351,7 +351,7 @@ bool event::get_value(CJS_Runtime* pRuntime,
if (!pEvent->m_pValue)
return false;
- vp->Set(pRuntime, pEvent->Value());
+ vp->Set(pRuntime->NewString(pEvent->Value().c_str()));
return true;
}
@@ -376,7 +376,7 @@ bool event::get_will_commit(CJS_Runtime* pRuntime,
WideString* sError) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime, pEvent->WillCommit());
+ vp->Set(pRuntime->NewBoolean(pEvent->WillCommit()));
return true;
}
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index ee76469150..a226bb25cc 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -104,12 +104,12 @@ void JSSpecialPropGet(const char* class_name,
WideString propname =
WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
- CJS_Value value(pRuntime);
+ CJS_Value value;
if (!pObj->GetProperty(pRuntime, propname.c_str(), &value)) {
pRuntime->Error(JSFormatErrorString(class_name, "GetProperty", L""));
return;
}
- info.GetReturnValue().Set(value.ToV8Value(pRuntime));
+ info.GetReturnValue().Set(value.ToV8Value());
}
template <class Alt>
@@ -131,7 +131,7 @@ void JSSpecialPropPut(const char* class_name,
v8::String::Utf8Value utf8_value(property);
WideString propname =
WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
- CJS_Value prop_value(pRuntime, value);
+ CJS_Value prop_value(value);
if (!pObj->SetProperty(pRuntime, propname.c_str(), prop_value)) {
pRuntime->Error(JSFormatErrorString(class_name, "PutProperty", L""));
}
@@ -287,33 +287,33 @@ bool JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime,
CJS_Value* vp) {
auto it = m_MapGlobal.find(ByteString::FromUnicode(propname));
if (it == m_MapGlobal.end()) {
- vp->SetNull(pRuntime);
+ vp->Set(pRuntime->NewNull());
return true;
}
JSGlobalData* pData = it->second.get();
if (pData->bDeleted) {
- vp->SetNull(pRuntime);
+ vp->Set(pRuntime->NewNull());
return true;
}
switch (pData->nType) {
case JS_GlobalDataType::NUMBER:
- vp->Set(pRuntime, pData->dData);
+ vp->Set(pRuntime->NewNumber(pData->dData));
return true;
case JS_GlobalDataType::BOOLEAN:
- vp->Set(pRuntime, pData->bData);
+ vp->Set(pRuntime->NewBoolean(pData->bData));
return true;
case JS_GlobalDataType::STRING:
- vp->Set(pRuntime, pData->sData);
+ vp->Set(pRuntime->NewString(
+ WideString::FromLocal(pData->sData.c_str()).c_str()));
return true;
case JS_GlobalDataType::OBJECT: {
- vp->Set(pRuntime,
- v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
+ vp->Set(v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
return true;
}
case JS_GlobalDataType::NULLOBJ:
- vp->SetNull(pRuntime);
+ vp->Set(pRuntime->NewNull());
return true;
default:
break;
@@ -485,7 +485,7 @@ void JSGlobalAlternate::ObjectToArray(CJS_Runtime* pRuntime,
array.Add(pObjElement);
} break;
case CJS_Value::VT_string: {
- ByteString sValue = CJS_Value(pRuntime, v).ToByteString(pRuntime);
+ ByteString sValue = CJS_Value(v).ToByteString(pRuntime);
CJS_KeyValue* pObjElement = new CJS_KeyValue;
pObjElement->nType = JS_GlobalDataType::STRING;
pObjElement->sKey = sKey;
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 9b63823e3c..3d669b30ca 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -151,7 +151,7 @@ bool util::printd(CJS_Runtime* pRuntime,
return false;
}
- CJS_Date jsDate = p2.ToDate(pRuntime);
+ CJS_Date jsDate = p2.ToDate();
if (!jsDate.IsValidDate(pRuntime)) {
sError = JSGetStringFromID(IDS_STRING_JSPRINT2);
return false;
@@ -396,9 +396,9 @@ bool util::scand(CJS_Runtime* pRuntime,
}
if (!std::isnan(dDate)) {
- vRet = CJS_Value(pRuntime, CJS_Date(pRuntime, dDate));
+ vRet = CJS_Value(CJS_Date(pRuntime, dDate));
} else {
- vRet.SetNull(pRuntime);
+ vRet.Set(pRuntime->NewNull());
}
return true;