Return v8::Date specialization not v8::Value where possible

Also get rid of FXJS_ValueCopy() while we're at it.

BUG=pdfium:556

Review-Url: https://codereview.chromium.org/2215093002
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index fa1f7d9..9d65c79 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -252,7 +252,8 @@
 
 FX_BOOL CJS_Value::ConvertToDate(CJS_Date& date) const {
   if (IsDateObject()) {
-    date.Attach(m_pValue);
+    v8::Local<v8::Value> mutable_value = m_pValue;
+    date.Attach(mutable_value.As<v8::Date>());
     return TRUE;
   }
 
@@ -437,7 +438,7 @@
          !JS_PortIsNan(FXJS_ToNumber(m_pJSRuntime->GetIsolate(), m_pDate));
 }
 
-void CJS_Date::Attach(v8::Local<v8::Value> pDate) {
+void CJS_Date::Attach(v8::Local<v8::Date> pDate) {
   m_pDate = pDate;
 }
 
@@ -452,7 +453,7 @@
 void CJS_Date::SetYear(int iYear) {
   double date = MakeDate(iYear, GetMonth(), GetDay(), GetHours(), GetMinutes(),
                          GetSeconds(), 0);
-  FXJS_ValueCopy(m_pDate, FXJS_NewDate(m_pJSRuntime->GetIsolate(), date));
+  m_pDate = FXJS_NewDate(m_pJSRuntime->GetIsolate(), date);
 }
 
 int CJS_Date::GetMonth() const {
@@ -466,7 +467,7 @@
 void CJS_Date::SetMonth(int iMonth) {
   double date = MakeDate(GetYear(), iMonth, GetDay(), GetHours(), GetMinutes(),
                          GetSeconds(), 0);
-  FXJS_ValueCopy(m_pDate, FXJS_NewDate(m_pJSRuntime->GetIsolate(), date));
+  m_pDate = FXJS_NewDate(m_pJSRuntime->GetIsolate(), date);
 }
 
 int CJS_Date::GetDay() const {
@@ -480,7 +481,7 @@
 void CJS_Date::SetDay(int iDay) {
   double date = MakeDate(GetYear(), GetMonth(), iDay, GetHours(), GetMinutes(),
                          GetSeconds(), 0);
-  FXJS_ValueCopy(m_pDate, FXJS_NewDate(m_pJSRuntime->GetIsolate(), date));
+  m_pDate = FXJS_NewDate(m_pJSRuntime->GetIsolate(), date);
 }
 
 int CJS_Date::GetHours() const {
@@ -494,7 +495,7 @@
 void CJS_Date::SetHours(int iHours) {
   double date = MakeDate(GetYear(), GetMonth(), GetDay(), iHours, GetMinutes(),
                          GetSeconds(), 0);
-  FXJS_ValueCopy(m_pDate, FXJS_NewDate(m_pJSRuntime->GetIsolate(), date));
+  m_pDate = FXJS_NewDate(m_pJSRuntime->GetIsolate(), date);
 }
 
 int CJS_Date::GetMinutes() const {
@@ -508,7 +509,7 @@
 void CJS_Date::SetMinutes(int minutes) {
   double date = MakeDate(GetYear(), GetMonth(), GetDay(), GetHours(), minutes,
                          GetSeconds(), 0);
-  FXJS_ValueCopy(m_pDate, FXJS_NewDate(m_pJSRuntime->GetIsolate(), date));
+  m_pDate = FXJS_NewDate(m_pJSRuntime->GetIsolate(), date);
 }
 
 int CJS_Date::GetSeconds() const {
@@ -522,7 +523,7 @@
 void CJS_Date::SetSeconds(int seconds) {
   double date = MakeDate(GetYear(), GetMonth(), GetDay(), GetHours(),
                          GetMinutes(), seconds, 0);
-  FXJS_ValueCopy(m_pDate, FXJS_NewDate(m_pJSRuntime->GetIsolate(), date));
+  m_pDate = FXJS_NewDate(m_pJSRuntime->GetIsolate(), date);
 }
 
 double CJS_Date::ToDouble() const {
diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h
index 5943aaf..01b4e5b 100644
--- a/fpdfsdk/javascript/JS_Value.h
+++ b/fpdfsdk/javascript/JS_Value.h
@@ -159,7 +159,7 @@
            int sec);
   virtual ~CJS_Date();
 
-  void Attach(v8::Local<v8::Value> pDate);
+  void Attach(v8::Local<v8::Date> pDate);
   bool IsValidDate() const;
 
   int GetYear() const;
@@ -186,7 +186,7 @@
   CFX_WideString ToString() const;
 
  protected:
-  v8::Local<v8::Value> m_pDate;
+  v8::Local<v8::Date> m_pDate;
   CJS_Runtime* const m_pJSRuntime;
 };
 
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp
index 6577885..d161af6 100644
--- a/fxjs/fxjs_v8.cpp
+++ b/fxjs/fxjs_v8.cpp
@@ -758,8 +758,10 @@
   return v8::Local<v8::Value>();
 }
 
-v8::Local<v8::Value> FXJS_NewDate(v8::Isolate* pIsolate, double d) {
-  return v8::Date::New(pIsolate->GetCurrentContext(), d).ToLocalChecked();
+v8::Local<v8::Date> FXJS_NewDate(v8::Isolate* pIsolate, double d) {
+  return v8::Date::New(pIsolate->GetCurrentContext(), d)
+      .ToLocalChecked()
+      .As<v8::Date>();
 }
 
 int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue) {
@@ -807,7 +809,3 @@
   v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
   return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
 }
-
-void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
-  pTo = pFrom;
-}
diff --git a/fxjs/include/fxjs_v8.h b/fxjs/include/fxjs_v8.h
index f59f510..cd4d7c4 100644
--- a/fxjs/include/fxjs_v8.h
+++ b/fxjs/include/fxjs_v8.h
@@ -260,7 +260,7 @@
 v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, float number);
 v8::Local<v8::Value> FXJS_NewBoolean(v8::Isolate* pIsolate, bool b);
 v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate, const wchar_t* str);
-v8::Local<v8::Value> FXJS_NewDate(v8::Isolate* pIsolate, double d);
+v8::Local<v8::Date> FXJS_NewDate(v8::Isolate* pIsolate, double d);
 
 int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
 bool FXJS_ToBoolean(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
@@ -271,6 +271,4 @@
                              v8::Local<v8::Value> pValue);
 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate,
                                   v8::Local<v8::Value> pValue);
-void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
-
 #endif  // FXJS_INCLUDE_FXJS_V8_H_