summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-30 17:05:31 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-10-30 17:05:31 +0000
commita146507fdbe8a8d13fe590b5fa883efc7bffe90a (patch)
treebacdd8e8ae0ac850df26cd834893936f647513c9
parent5ce2d2e0c7899dc2d3b3ac6a25293894fea04183 (diff)
downloadpdfium-a146507fdbe8a8d13fe590b5fa883efc7bffe90a.tar.xz
Move JS_Value into JS_Define
This CL moves CJS_Return to its own files and moves the remaining function definitions from JS_Value to JS_Define. Change-Id: Ic7058a02330153f22d1fff9fc6cdebd9167c498b Reviewed-on: https://pdfium-review.googlesource.com/17038 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--BUILD.gn5
-rw-r--r--fpdfsdk/javascript/JS_Define.cpp (renamed from fpdfsdk/javascript/JS_Value.cpp)14
-rw-r--r--fpdfsdk/javascript/JS_Define.h27
-rw-r--r--fpdfsdk/javascript/JS_Value.h65
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp1
-rw-r--r--fpdfsdk/javascript/app.cpp1
-rw-r--r--fpdfsdk/javascript/cjs_annot.cpp1
-rw-r--r--fpdfsdk/javascript/cjs_document.h1
-rw-r--r--fpdfsdk/javascript/cjs_eventhandler.cpp1
-rw-r--r--fpdfsdk/javascript/cjs_global.cpp1
-rw-r--r--fpdfsdk/javascript/cjs_return.cpp18
-rw-r--r--fpdfsdk/javascript/cjs_return.h34
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp1
-rw-r--r--fpdfsdk/javascript/color.cpp1
-rw-r--r--fpdfsdk/javascript/console.cpp1
-rw-r--r--fpdfsdk/javascript/event.cpp1
-rw-r--r--fpdfsdk/javascript/report.cpp1
-rw-r--r--fpdfsdk/javascript/util.cpp1
18 files changed, 83 insertions, 92 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 7aaf6427d9..612ea18cdc 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1188,13 +1188,12 @@ static_library("javascript") {
if (pdf_enable_v8) {
sources += [
+ "fpdfsdk/javascript/JS_Define.cpp",
"fpdfsdk/javascript/JS_Define.h",
"fpdfsdk/javascript/JS_GlobalData.cpp",
"fpdfsdk/javascript/JS_GlobalData.h",
"fpdfsdk/javascript/JS_KeyValue.cpp",
"fpdfsdk/javascript/JS_KeyValue.h",
- "fpdfsdk/javascript/JS_Value.cpp",
- "fpdfsdk/javascript/JS_Value.h",
"fpdfsdk/javascript/PublicMethods.cpp",
"fpdfsdk/javascript/PublicMethods.h",
"fpdfsdk/javascript/app.cpp",
@@ -1235,6 +1234,8 @@ static_library("javascript") {
"fpdfsdk/javascript/cjs_position.h",
"fpdfsdk/javascript/cjs_printparamsobj.cpp",
"fpdfsdk/javascript/cjs_printparamsobj.h",
+ "fpdfsdk/javascript/cjs_return.cpp",
+ "fpdfsdk/javascript/cjs_return.h",
"fpdfsdk/javascript/cjs_runtime.cpp",
"fpdfsdk/javascript/cjs_runtime.h",
"fpdfsdk/javascript/cjs_scalehow.cpp",
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Define.cpp
index da09ff28ac..18887e636a 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Define.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/javascript/JS_Value.h"
+#include "fpdfsdk/javascript/JS_Define.h"
#include <time.h>
@@ -13,7 +13,6 @@
#include <limits>
#include <vector>
-#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/cjs_document.h"
#include "fpdfsdk/javascript/cjs_object.h"
@@ -168,17 +167,6 @@ int DateFromTime(double t) {
} // namespace
-CJS_Return::CJS_Return(bool result) : is_error_(!result) {}
-
-CJS_Return::CJS_Return(const WideString& err) : is_error_(true), error_(err) {}
-
-CJS_Return::CJS_Return(v8::Local<v8::Value> ret)
- : is_error_(false), return_(ret) {}
-
-CJS_Return::CJS_Return(const CJS_Return&) = default;
-
-CJS_Return::~CJS_Return() = default;
-
double JS_GetDateTime() {
if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
return 0;
diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h
index 5824011665..4f82a74b0d 100644
--- a/fpdfsdk/javascript/JS_Define.h
+++ b/fpdfsdk/javascript/JS_Define.h
@@ -9,11 +9,36 @@
#include <vector>
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_object.h"
+#include "fpdfsdk/javascript/cjs_return.h"
#include "fpdfsdk/javascript/resource.h"
#include "fxjs/fxjs_v8.h"
+double JS_GetDateTime();
+int JS_GetYearFromTime(double dt);
+int JS_GetMonthFromTime(double dt);
+int JS_GetDayFromTime(double dt);
+int JS_GetHourFromTime(double dt);
+int JS_GetMinFromTime(double dt);
+int JS_GetSecFromTime(double dt);
+double JS_LocalTime(double d);
+double JS_DateParse(const WideString& str);
+double JS_MakeDay(int nYear, int nMonth, int nDay);
+double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
+double JS_MakeDate(double day, double time);
+
+// Some JS methods have the bizarre convention that they may also be called
+// with a single argument which is an object containing the actual arguments
+// as its properties. The varying arguments to this method are the property
+// names as wchar_t string literals corresponding to each positional argument.
+// The result will always contain |nKeywords| value, with unspecified ones
+// being set to type VT_unknown.
+std::vector<v8::Local<v8::Value>> ExpandKeywordParams(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& originals,
+ size_t nKeywords,
+ ...);
+
// All JS classes have a name, an object defintion ID, and the ability to
// register themselves with FXJS_V8. We never make a BASE class on its own
// because it can't really do anything.
diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h
deleted file mode 100644
index 046d959e68..0000000000
--- a/fpdfsdk/javascript/JS_Value.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef FPDFSDK_JAVASCRIPT_JS_VALUE_H_
-#define FPDFSDK_JAVASCRIPT_JS_VALUE_H_
-
-#include <vector>
-
-#include "fxjs/fxjs_v8.h"
-
-class CJS_Document;
-class CJS_Object;
-class CJS_Runtime;
-
-class CJS_Return {
- public:
- explicit CJS_Return(bool);
- explicit CJS_Return(const WideString&);
- explicit CJS_Return(v8::Local<v8::Value>);
- CJS_Return(const CJS_Return&);
- ~CJS_Return();
-
- bool HasError() const { return is_error_; }
- WideString Error() const { return error_; }
-
- bool HasReturn() const { return !return_.IsEmpty(); }
- v8::Local<v8::Value> Return() const { return return_; }
-
- private:
- CJS_Return() = delete;
-
- bool is_error_ = false;
- WideString error_;
- v8::Local<v8::Value> return_;
-};
-
-double JS_GetDateTime();
-int JS_GetYearFromTime(double dt);
-int JS_GetMonthFromTime(double dt);
-int JS_GetDayFromTime(double dt);
-int JS_GetHourFromTime(double dt);
-int JS_GetMinFromTime(double dt);
-int JS_GetSecFromTime(double dt);
-double JS_LocalTime(double d);
-double JS_DateParse(const WideString& str);
-double JS_MakeDay(int nYear, int nMonth, int nDay);
-double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
-double JS_MakeDate(double day, double time);
-
-// Some JS methods have the bizarre convention that they may also be called
-// with a single argument which is an object containing the actual arguments
-// as its properties. The varying arguments to this method are the property
-// names as wchar_t string literals corresponding to each positional argument.
-// The result will always contain |nKeywords| value, with unspecified ones
-// being set to type VT_unknown.
-std::vector<v8::Local<v8::Value>> ExpandKeywordParams(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& originals,
- size_t nKeywords,
- ...);
-
-#endif // FPDFSDK_JAVASCRIPT_JS_VALUE_H_
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index b2469ad218..7969b62d9a 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -20,7 +20,6 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_eventhandler.h"
#include "fpdfsdk/javascript/cjs_field.h"
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 8a91a1da39..3e8ca0bf1a 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -13,7 +13,6 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_document.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_eventhandler.h"
diff --git a/fpdfsdk/javascript/cjs_annot.cpp b/fpdfsdk/javascript/cjs_annot.cpp
index fa7773fab4..8ff0d2c72e 100644
--- a/fpdfsdk/javascript/cjs_annot.cpp
+++ b/fpdfsdk/javascript/cjs_annot.cpp
@@ -7,7 +7,6 @@
#include "fpdfsdk/javascript/cjs_annot.h"
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_object.h"
diff --git a/fpdfsdk/javascript/cjs_document.h b/fpdfsdk/javascript/cjs_document.h
index e6aab6b2c0..f935eae7d4 100644
--- a/fpdfsdk/javascript/cjs_document.h
+++ b/fpdfsdk/javascript/cjs_document.h
@@ -13,6 +13,7 @@
#include "fpdfsdk/javascript/JS_Define.h"
+class CJS_Document;
class CPDF_TextObject;
struct CJS_DelayData;
diff --git a/fpdfsdk/javascript/cjs_eventhandler.cpp b/fpdfsdk/javascript/cjs_eventhandler.cpp
index 002f6b0fd8..406fd0bb1c 100644
--- a/fpdfsdk/javascript/cjs_eventhandler.cpp
+++ b/fpdfsdk/javascript/cjs_eventhandler.cpp
@@ -8,7 +8,6 @@
#include "core/fpdfdoc/cpdf_formfield.h"
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_document.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_field.h"
diff --git a/fpdfsdk/javascript/cjs_global.cpp b/fpdfsdk/javascript/cjs_global.cpp
index 5ef4d09894..d89005d2af 100644
--- a/fpdfsdk/javascript/cjs_global.cpp
+++ b/fpdfsdk/javascript/cjs_global.cpp
@@ -15,7 +15,6 @@
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_GlobalData.h"
#include "fpdfsdk/javascript/JS_KeyValue.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_eventhandler.h"
#include "fpdfsdk/javascript/cjs_object.h"
diff --git a/fpdfsdk/javascript/cjs_return.cpp b/fpdfsdk/javascript/cjs_return.cpp
new file mode 100644
index 0000000000..ecf36da705
--- /dev/null
+++ b/fpdfsdk/javascript/cjs_return.cpp
@@ -0,0 +1,18 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/javascript/cjs_return.h"
+
+CJS_Return::CJS_Return(bool result) : is_error_(!result) {}
+
+CJS_Return::CJS_Return(const WideString& err) : is_error_(true), error_(err) {}
+
+CJS_Return::CJS_Return(v8::Local<v8::Value> ret)
+ : is_error_(false), return_(ret) {}
+
+CJS_Return::CJS_Return(const CJS_Return&) = default;
+
+CJS_Return::~CJS_Return() = default;
diff --git a/fpdfsdk/javascript/cjs_return.h b/fpdfsdk/javascript/cjs_return.h
new file mode 100644
index 0000000000..f277c1a5a9
--- /dev/null
+++ b/fpdfsdk/javascript/cjs_return.h
@@ -0,0 +1,34 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FPDFSDK_JAVASCRIPT_CJS_RETURN_H_
+#define FPDFSDK_JAVASCRIPT_CJS_RETURN_H_
+
+#include "fxjs/fxjs_v8.h"
+
+class CJS_Return {
+ public:
+ explicit CJS_Return(bool);
+ explicit CJS_Return(const WideString&);
+ explicit CJS_Return(v8::Local<v8::Value>);
+ CJS_Return(const CJS_Return&);
+ ~CJS_Return();
+
+ bool HasError() const { return is_error_; }
+ WideString Error() const { return error_; }
+
+ bool HasReturn() const { return !return_.IsEmpty(); }
+ v8::Local<v8::Value> Return() const { return return_; }
+
+ private:
+ CJS_Return() = delete;
+
+ bool is_error_ = false;
+ WideString error_;
+ v8::Local<v8::Value> return_;
+};
+
+#endif // FPDFSDK_JAVASCRIPT_CJS_RETURN_H_
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index 64123ce395..139dacf6da 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -11,7 +11,6 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_GlobalData.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/PublicMethods.h"
#include "fpdfsdk/javascript/app.h"
#include "fpdfsdk/javascript/cjs_annot.h"
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 405f12d0f3..0f9ed0a4b8 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -9,7 +9,6 @@
#include <vector>
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_eventhandler.h"
#include "fpdfsdk/javascript/cjs_object.h"
diff --git a/fpdfsdk/javascript/console.cpp b/fpdfsdk/javascript/console.cpp
index 81db44d2a1..67ca1655ff 100644
--- a/fpdfsdk/javascript/console.cpp
+++ b/fpdfsdk/javascript/console.cpp
@@ -9,7 +9,6 @@
#include <vector>
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_eventhandler.h"
#include "fpdfsdk/javascript/cjs_object.h"
diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp
index 7682a64033..22aaa04315 100644
--- a/fpdfsdk/javascript/event.cpp
+++ b/fpdfsdk/javascript/event.cpp
@@ -7,7 +7,6 @@
#include "fpdfsdk/javascript/event.h"
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_eventhandler.h"
#include "fpdfsdk/javascript/cjs_field.h"
diff --git a/fpdfsdk/javascript/report.cpp b/fpdfsdk/javascript/report.cpp
index 676451af82..88ea57569a 100644
--- a/fpdfsdk/javascript/report.cpp
+++ b/fpdfsdk/javascript/report.cpp
@@ -9,7 +9,6 @@
#include <vector>
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/cjs_object.h"
const JSMethodSpec CJS_Report::MethodSpecs[] = {{"save", save_static},
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index a8f5486c35..99934726ff 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -16,7 +16,6 @@
#include "core/fxcrt/fx_extension.h"
#include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/PublicMethods.h"
#include "fpdfsdk/javascript/cjs_event_context.h"
#include "fpdfsdk/javascript/cjs_eventhandler.h"