summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/javascript/Field.cpp14
-rw-r--r--fpdfsdk/javascript/JS_Value.cpp10
-rw-r--r--fpdfsdk/javascript/JS_Value.h3
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp5
-rw-r--r--fpdfsdk/javascript/app.cpp24
-rw-r--r--fpdfsdk/javascript/color.cpp8
-rw-r--r--fpdfsdk/javascript/util.cpp4
7 files changed, 28 insertions, 40 deletions
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 0ed0594b3b..35b808c733 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -879,7 +879,7 @@ bool Field::set_current_value_indices(CJS_Runtime* pRuntime,
std::vector<uint32_t> array;
if (vp.ToV8Value()->IsNumber()) {
array.push_back(pRuntime->ToInt32(vp.ToV8Value()));
- } else if (vp.IsArrayObject()) {
+ } else if (!vp.ToV8Value().IsEmpty() && vp.ToV8Value()->IsArray()) {
CJS_Array SelArray(pRuntime->ToArray(vp.ToV8Value()));
for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++)
array.push_back(
@@ -1210,7 +1210,7 @@ bool Field::set_export_values(CJS_Runtime* pRuntime,
return false;
}
- return m_bCanSet && vp.IsArrayObject();
+ return m_bCanSet && !vp.ToV8Value().IsEmpty() && vp.ToV8Value()->IsArray();
}
bool Field::get_file_select(CJS_Runtime* pRuntime,
@@ -1297,7 +1297,7 @@ bool Field::set_fill_color(CJS_Runtime* pRuntime,
return false;
if (!m_bCanSet)
return false;
- if (!vp.IsArrayObject())
+ if (vp.ToV8Value().IsEmpty() || !vp.ToV8Value()->IsArray())
return false;
return true;
}
@@ -1797,7 +1797,7 @@ bool Field::set_rect(CJS_Runtime* pRuntime,
WideString* sError) {
if (!m_bCanSet)
return false;
- if (!vp.IsArrayObject())
+ if (vp.ToV8Value().IsEmpty() || !vp.ToV8Value()->IsArray())
return false;
CJS_Array rcArray(pRuntime->ToArray(vp.ToV8Value()));
@@ -2017,7 +2017,7 @@ bool Field::set_stroke_color(CJS_Runtime* pRuntime,
WideString* sError) {
if (!m_bCanSet)
return false;
- if (!vp.IsArrayObject())
+ if (vp.ToV8Value().IsEmpty() || !vp.ToV8Value()->IsArray())
return false;
return true;
}
@@ -2131,7 +2131,7 @@ bool Field::set_text_color(CJS_Runtime* pRuntime,
WideString* sError) {
if (!m_bCanSet)
return false;
- if (!vp.IsArrayObject())
+ if (vp.ToV8Value().IsEmpty() || !vp.ToV8Value()->IsArray())
return false;
return true;
}
@@ -2342,7 +2342,7 @@ bool Field::set_value(CJS_Runtime* pRuntime,
return false;
std::vector<WideString> strArray;
- if (vp.IsArrayObject()) {
+ if (!vp.ToV8Value().IsEmpty() && vp.ToV8Value()->IsArray()) {
CJS_Array ValueArray(pRuntime->ToArray(vp.ToV8Value()));
for (int i = 0, sz = ValueArray.GetLength(pRuntime); i < sz; i++) {
CJS_Value ElementValue(ValueArray.GetElement(pRuntime, i));
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index f535f69f94..9275de3d52 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -216,14 +216,6 @@ void CJS_Value::MaybeCoerceToNumber(CJS_Runtime* pRuntime) {
m_pValue = num;
}
-bool CJS_Value::IsArrayObject() const {
- return !m_pValue.IsEmpty() && m_pValue->IsArray();
-}
-
-bool CJS_Value::IsDateObject() const {
- return !m_pValue.IsEmpty() && m_pValue->IsDate();
-}
-
CJS_Array::CJS_Array() {}
CJS_Array::CJS_Array(v8::Local<v8::Array> pArray) : m_pArray(pArray) {}
@@ -436,7 +428,7 @@ std::vector<CJS_Value> ExpandKeywordParams(
result[i] = originals[i];
if (originals.size() != 1 || !originals[0].ToV8Value()->IsObject() ||
- originals[0].IsArrayObject()) {
+ originals[0].ToV8Value()->IsArray()) {
return result;
}
v8::Local<v8::Object> pObj = pRuntime->ToObject(originals[0].ToV8Value());
diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h
index 5e77e0beaa..ff3bf9c51e 100644
--- a/fpdfsdk/javascript/JS_Value.h
+++ b/fpdfsdk/javascript/JS_Value.h
@@ -33,9 +33,6 @@ class CJS_Value {
// to make one from the current |m_pValue|.
void MaybeCoerceToNumber(CJS_Runtime* pRuntime);
- bool IsArrayObject() const;
- bool IsDateObject() const;
-
private:
v8::Local<v8::Value> m_pValue;
};
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 68fc30572b..200e7d1046 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -247,7 +247,7 @@ double CJS_PublicMethods::AF_Simple(const wchar_t* sFuction,
CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
CJS_Value val) {
- if (val.IsArrayObject())
+ if (!val.ToV8Value().IsEmpty() && val.ToV8Value()->IsArray())
return CJS_Array(pRuntime->ToArray(val.ToV8Value()));
WideString wsStr = pRuntime->ToWideString(val.ToV8Value());
@@ -1675,7 +1675,8 @@ bool CJS_PublicMethods::AFSimple_Calculate(CJS_Runtime* pRuntime,
}
CJS_Value params1(params[1]);
- if (!params1.IsArrayObject() && !params1.ToV8Value()->IsString()) {
+ if ((params[1].ToV8Value().IsEmpty() || !params[1].ToV8Value()->IsArray()) &&
+ !params1.ToV8Value()->IsString()) {
sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
return false;
}
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 26f28f5b48..cb07a0ee7b 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -414,21 +414,17 @@ bool app::alert(CJS_Runtime* pRuntime,
}
WideString swMsg;
- if (newParams[0].ToV8Value()->IsObject()) {
- if (newParams[0].IsArrayObject()) {
- CJS_Array carray(pRuntime->ToArray(newParams[0].ToV8Value()));
- swMsg = L"[";
- for (int i = 0; i < carray.GetLength(pRuntime); ++i) {
- if (i)
- swMsg += L", ";
-
- CJS_Value element(carray.GetElement(pRuntime, i));
- swMsg += pRuntime->ToWideString(element.ToV8Value());
- }
- swMsg += L"]";
- } else {
- swMsg = pRuntime->ToWideString(newParams[0].ToV8Value());
+ if (newParams[0].ToV8Value()->IsArray()) {
+ CJS_Array carray(pRuntime->ToArray(newParams[0].ToV8Value()));
+ swMsg = L"[";
+ for (int i = 0; i < carray.GetLength(pRuntime); ++i) {
+ if (i)
+ swMsg += L", ";
+
+ CJS_Value element(carray.GetElement(pRuntime, i));
+ swMsg += pRuntime->ToWideString(element.ToV8Value());
}
+ swMsg += L"]";
} else {
swMsg = pRuntime->ToWideString(newParams[0].ToV8Value());
}
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 56baa59019..c095678732 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -289,7 +289,7 @@ bool color::GetPropertyHelper(CJS_Runtime* pRuntime,
bool color::SetPropertyHelper(CJS_Runtime* pRuntime,
const CJS_Value& vp,
CFX_Color* var) {
- if (!vp.IsArrayObject())
+ if (vp.ToV8Value().IsEmpty() || !vp.ToV8Value()->IsArray())
return false;
*var = ConvertArrayToPWLColor(pRuntime,
@@ -304,7 +304,7 @@ bool color::convert(CJS_Runtime* pRuntime,
int iSize = params.size();
if (iSize < 2)
return false;
- if (!params[0].IsArrayObject())
+ if (params[0].ToV8Value().IsEmpty() || !params[0].ToV8Value()->IsArray())
return false;
WideString sDestSpace = pRuntime->ToWideString(params[1].ToV8Value());
@@ -337,8 +337,10 @@ bool color::equal(CJS_Runtime* pRuntime,
WideString& sError) {
if (params.size() < 2)
return false;
- if (!params[0].IsArrayObject() || !params[1].IsArrayObject())
+ if (params[0].ToV8Value().IsEmpty() || !params[0].ToV8Value()->IsArray() ||
+ params[1].ToV8Value().IsEmpty() || !params[1].ToV8Value()->IsArray()) {
return false;
+ }
CFX_Color color1 = ConvertArrayToPWLColor(
pRuntime, CJS_Array(pRuntime->ToArray(params[0].ToV8Value())));
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 28ab0bb95c..4a7e148697 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -149,12 +149,12 @@ bool util::printd(CJS_Runtime* pRuntime,
const CJS_Value& p1 = params[0];
const CJS_Value& p2 = params[1];
- if (!p2.IsDateObject()) {
+ if (p2.ToV8Value().IsEmpty() || !p2.ToV8Value()->IsDate()) {
sError = JSGetStringFromID(IDS_STRING_JSPRINT1);
return false;
}
- ASSERT(p2.IsDateObject());
+ ASSERT(!p2.ToV8Value().IsEmpty() && p2.ToV8Value()->IsDate());
v8::Local<v8::Value> mutable_value = p2.ToV8Value();
CJS_Date jsDate(mutable_value.As<v8::Date>());
if (!jsDate.IsValidDate(pRuntime)) {