Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Unified Diff: fpdfsdk/src/javascript/JS_Value.cpp

Issue 1641693003: Fix behaviour of app.alert() with a single object argument. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix spelling, naming, braces. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/javascript/JS_Value.h ('k') | fpdfsdk/src/javascript/app.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/JS_Value.cpp
diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp
index cfa565e4d4e04fc209ebcd65ffa5d8f703fef924..c63963a110fd2ef9dadafd7b3334298aee4187c6 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;
+}
« no previous file with comments | « fpdfsdk/src/javascript/JS_Value.h ('k') | fpdfsdk/src/javascript/app.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698