From 88b6686f6e56a01dab0172f4b3129ab7ae0cd8d8 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 14 Jul 2016 12:07:48 -0700 Subject: Do not try to v8::Object::Clone() any objects v8::Object::Clone() is deprecated, and gets us into trouble with some corner cases. Create a new handle to the same object instead. Remove FXJS_NewObject() and FXJS_NewObject2(), and replace with direct assignments. Pass isolate to FXJS_NewNull() while were at it, even though not needed, for consistency with all remaining FXJS_New*() calls. BUG=628106 R=jochen@chromium.org Review-Url: https://codereview.chromium.org/2151023002 --- fpdfsdk/javascript/JS_Value.cpp | 7 +++---- fxjs/fxjs_v8.cpp | 16 +--------------- fxjs/include/fxjs_v8.h | 6 +----- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 53d6d59833..6bc45c555d 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -186,7 +186,7 @@ void CJS_Value::operator=(float fValue) { } void CJS_Value::operator=(v8::Local pObj) { - m_pValue = FXJS_NewObject(m_pJSRuntime->GetIsolate(), pObj); + m_pValue = pObj; m_eType = VT_fxobject; } @@ -208,7 +208,7 @@ void CJS_Value::operator=(const FX_WCHAR* pWstr) { } void CJS_Value::SetNull() { - m_pValue = FXJS_NewNull(); + m_pValue = FXJS_NewNull(m_pJSRuntime->GetIsolate()); m_eType = VT_null; } @@ -217,8 +217,7 @@ void CJS_Value::operator=(const FX_CHAR* pStr) { } void CJS_Value::operator=(CJS_Array& array) { - m_pValue = - FXJS_NewObject2(m_pJSRuntime->GetIsolate(), (v8::Local)array); + m_pValue = static_cast>(array); m_eType = VT_object; } diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp index c98de070ab..8595ac8a71 100644 --- a/fxjs/fxjs_v8.cpp +++ b/fxjs/fxjs_v8.cpp @@ -779,25 +779,11 @@ v8::Local FXJS_NewBoolean(v8::Isolate* pIsolate, bool b) { return v8::Boolean::New(pIsolate, b); } -v8::Local FXJS_NewObject(v8::Isolate* pIsolate, - v8::Local pObj) { - if (pObj.IsEmpty()) - return v8::Local(); - return pObj->Clone(); -} - -v8::Local FXJS_NewObject2(v8::Isolate* pIsolate, - v8::Local pObj) { - if (pObj.IsEmpty()) - return v8::Local(); - return pObj->Clone(); -} - v8::Local FXJS_NewString(v8::Isolate* pIsolate, const wchar_t* str) { return FXJS_WSToJSString(pIsolate, str); } -v8::Local FXJS_NewNull() { +v8::Local FXJS_NewNull(v8::Isolate* pIsolate) { return v8::Local(); } diff --git a/fxjs/include/fxjs_v8.h b/fxjs/include/fxjs_v8.h index 465feef5e8..c8cd65be2f 100644 --- a/fxjs/include/fxjs_v8.h +++ b/fxjs/include/fxjs_v8.h @@ -263,17 +263,13 @@ unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate, unsigned index, v8::Local pValue); +v8::Local FXJS_NewNull(v8::Isolate* pIsolate); v8::Local FXJS_NewArray(v8::Isolate* pIsolate); v8::Local FXJS_NewNumber(v8::Isolate* pIsolate, int number); v8::Local FXJS_NewNumber(v8::Isolate* pIsolate, double number); v8::Local FXJS_NewNumber(v8::Isolate* pIsolate, float number); v8::Local FXJS_NewBoolean(v8::Isolate* pIsolate, bool b); -v8::Local FXJS_NewObject(v8::Isolate* pIsolate, - v8::Local pObj); -v8::Local FXJS_NewObject2(v8::Isolate* pIsolate, - v8::Local pObj); v8::Local FXJS_NewString(v8::Isolate* pIsolate, const wchar_t* str); -v8::Local FXJS_NewNull(); v8::Local FXJS_NewDate(v8::Isolate* pIsolate, double d); int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local pValue); -- cgit v1.2.3