summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/JS_Value.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-29 09:10:41 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-29 09:10:41 -0800
commitbd9325754999c2c3a01562ea090654f1ab07cc59 (patch)
treea07252668e75a4dbf1cc820f8175ecc0a867f974 /fpdfsdk/src/javascript/JS_Value.cpp
parent61dc96f9aa2512807b62cfaec35b1cd012459a6f (diff)
downloadpdfium-bd9325754999c2c3a01562ea090654f1ab07cc59.tar.xz
Merge to XFA: Fix behaviour of app.alert() with a single object argument.
Original Review URL: https://codereview.chromium.org/1641693003 . (cherry picked from commit 66519af52b61ca158044651d0507d47efb364f87) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1639253008 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Value.cpp')
-rw-r--r--fpdfsdk/src/javascript/JS_Value.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp
index cfa565e4d4..c63963a110 100644
--- a/fpdfsdk/src/javascript/JS_Value.cpp
+++ b/fpdfsdk/src/javascript/JS_Value.cpp
@@ -7,6 +7,7 @@
#include "JS_Value.h"
#include <time.h>
+#include <algorithm>
#include <cmath>
#include <limits>
@@ -879,3 +880,35 @@ bool JS_PortIsNan(double d) {
double JS_LocalTime(double d) {
return JS_GetDateTime() + _getDaylightSavingTA(d);
}
+
+std::vector<CJS_Value> JS_ExpandKeywordParams(
+ CJS_Runtime* pRuntime,
+ const std::vector<CJS_Value>& originals,
+ size_t nKeywords,
+ ...) {
+ ASSERT(nKeywords);
+
+ std::vector<CJS_Value> result(nKeywords, CJS_Value(pRuntime));
+ size_t size = std::min(originals.size(), nKeywords);
+ for (size_t i = 0; i < size; ++i)
+ result[i] = originals[i];
+
+ if (originals.size() != 1 || originals[0].GetType() != CJS_Value::VT_object ||
+ originals[0].IsArrayObject()) {
+ return result;
+ }
+ v8::Local<v8::Object> pObj = originals[0].ToV8Object();
+ result[0] = CJS_Value(pRuntime); // Make unknown.
+
+ va_list ap;
+ va_start(ap, nKeywords);
+ for (int i = 0; i < nKeywords; ++i) {
+ const wchar_t* property = va_arg(ap, const wchar_t*);
+ v8::Local<v8::Value> v8Value =
+ FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property);
+ if (!v8Value->IsUndefined())
+ result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown);
+ }
+ va_end(ap);
+ return result;
+}