From 6687f780d0c7a9a4f453f166bb4efb55294349a6 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 25 Oct 2017 14:34:26 -0400 Subject: Remove CJS_Date This CL removes the CJS_Date class and uses the v8::Local directly. Change-Id: I4a59b0076bc0e5dc3142b36bd7125115605d416f Reviewed-on: https://pdfium-review.googlesource.com/16811 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- fpdfsdk/javascript/JS_Value.cpp | 6 ------ fpdfsdk/javascript/JS_Value.h | 12 ------------ fpdfsdk/javascript/util.cpp | 8 +++----- 3 files changed, 3 insertions(+), 23 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 1ef5599e9e..dee06e62f3 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -209,12 +209,6 @@ int CJS_Array::GetLength(CJS_Runtime* pRuntime) const { return pRuntime->GetArrayLength(m_pArray); } -CJS_Date::CJS_Date(v8::Local pDate) : m_pDate(pDate) {} - -CJS_Date::CJS_Date(const CJS_Date& other) = default; - -CJS_Date::~CJS_Date() {} - double JS_GetDateTime() { if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h index 6136119e51..2d5a390fca 100644 --- a/fpdfsdk/javascript/JS_Value.h +++ b/fpdfsdk/javascript/JS_Value.h @@ -60,18 +60,6 @@ class CJS_Array { mutable v8::Local m_pArray; }; -class CJS_Date { - public: - explicit CJS_Date(v8::Local pDate); - CJS_Date(const CJS_Date&); - virtual ~CJS_Date(); - - v8::Local ToV8Value() const { return m_pDate; } - - private: - v8::Local m_pDate; -}; - double JS_GetDateTime(); int JS_GetYearFromTime(double dt); int JS_GetMonthFromTime(double dt); diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 26e44496da..b9deda1db8 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -143,13 +143,11 @@ CJS_Return util::printd(CJS_Runtime* pRuntime, if (params[1].IsEmpty() || !params[1]->IsDate()) return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT1)); - CJS_Date jsDate(params[1].As()); - if (jsDate.ToV8Value().IsEmpty() || - std::isnan(pRuntime->ToDouble(jsDate.ToV8Value()))) { + v8::Local v8_date = params[1].As(); + if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date))) return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT2)); - } - double date = JS_LocalTime(pRuntime->ToDouble(jsDate.ToV8Value())); + double date = JS_LocalTime(pRuntime->ToDouble(v8_date)); int year = JS_GetYearFromTime(date); int month = JS_GetMonthFromTime(date) + 1; // One-based. int day = JS_GetDayFromTime(date); -- cgit v1.2.3