From d94df885e9e680e7dc8a5ac116c8d4ab5e4790cd Mon Sep 17 00:00:00 2001 From: Jochen Eisinger Date: Sun, 17 May 2015 13:07:02 +0200 Subject: Replace deprecated with non-deprecated V8 APIs In most cases, we just CHECK() that no exception was thrown. Previously, we'd just crash. Ideally, this should all be fixed and the system should cope with those exceptions, but that's beyond this CL. R=tsepez@chromium.org BUG= Review URL: https://codereview.chromium.org/1126203010 --- fpdfsdk/src/javascript/JS_Value.cpp | 39 +++++++++++++++++++------------------ fpdfsdk/src/javascript/global.cpp | 13 ++++++------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'fpdfsdk/src/javascript') diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp index 1b36f314ca..d3de6d1719 100644 --- a/fpdfsdk/src/javascript/JS_Value.cpp +++ b/fpdfsdk/src/javascript/JS_Value.cpp @@ -98,17 +98,17 @@ void CJS_Value::Detach() int CJS_Value::ToInt() const { - return JS_ToInt32(m_pValue); + return JS_ToInt32(m_isolate, m_pValue); } bool CJS_Value::ToBool() const { - return JS_ToBoolean(m_pValue); + return JS_ToBoolean(m_isolate, m_pValue); } double CJS_Value::ToDouble() const { - return JS_ToNumber(m_pValue); + return JS_ToNumber(m_isolate, m_pValue); } float CJS_Value::ToFloat() const @@ -118,18 +118,18 @@ float CJS_Value::ToFloat() const CJS_Object* CJS_Value::ToCJSObject() const { - v8::Handle pObj = JS_ToObject(m_pValue); + v8::Handle pObj = JS_ToObject(m_isolate, m_pValue); return (CJS_Object*)JS_GetPrivate(m_isolate, pObj); } v8::Handle CJS_Value::ToV8Object() const { - return JS_ToObject(m_pValue); + return JS_ToObject(m_isolate, m_pValue); } CFX_WideString CJS_Value::ToCFXWideString() const { - return JS_ToString(m_pValue); + return JS_ToString(m_isolate, m_pValue); } CFX_ByteString CJS_Value::ToCFXByteString() const @@ -145,7 +145,7 @@ v8::Handle CJS_Value::ToV8Value() const v8::HandleCJS_Value::ToV8Array() const { if (IsArrayObject()) - return v8::Handle::Cast(JS_ToObject(m_pValue)); + return v8::Handle::Cast(JS_ToObject(m_isolate, m_pValue)); return v8::Handle(); } @@ -238,6 +238,7 @@ void CJS_Value::operator = (CJS_Value value) m_pValue = value.ToV8Value(); m_eType = value.m_eType; + m_isolate = value.m_isolate; } /* ---------------------------------------------------------------------------------------- */ @@ -272,7 +273,7 @@ FX_BOOL CJS_Value::ConvertToArray(CJS_Array &array) const { if (IsArrayObject()) { - array.Attach(JS_ToArray(m_pValue)); + array.Attach(JS_ToArray(m_isolate, m_pValue)); return TRUE; } @@ -488,7 +489,7 @@ void CJS_Array::GetElement(unsigned index,CJS_Value &value) { if (m_pArray.IsEmpty()) return; - v8::Handle p = JS_GetArrayElemnet(m_pArray,index); + v8::Handle p = JS_GetArrayElement(m_isolate, m_pArray,index); value.Attach(p,VT_object); } @@ -497,7 +498,7 @@ void CJS_Array::SetElement(unsigned index,CJS_Value value) if (m_pArray.IsEmpty()) m_pArray = JS_NewArray(m_isolate); - JS_PutArrayElement(m_pArray, index, value.ToV8Value(), value.GetType()); + JS_PutArrayElement(m_isolate, m_pArray, index, value.ToV8Value(), value.GetType()); } int CJS_Array::GetLength() @@ -545,7 +546,7 @@ CJS_Date::~CJS_Date() FX_BOOL CJS_Date::IsValidDate() { if(m_pDate.IsEmpty()) return FALSE; - return !JS_PortIsNan(JS_ToNumber(m_pDate)); + return !JS_PortIsNan(JS_ToNumber(m_isolate, m_pDate)); } void CJS_Date::Attach(v8::Handle pDate) @@ -556,7 +557,7 @@ void CJS_Date::Attach(v8::Handle pDate) int CJS_Date::GetYear() { if (IsValidDate()) - return JS_GetYearFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetYearFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -570,7 +571,7 @@ void CJS_Date::SetYear(int iYear) int CJS_Date::GetMonth() { if (IsValidDate()) - return JS_GetMonthFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetMonthFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -586,7 +587,7 @@ void CJS_Date::SetMonth(int iMonth) int CJS_Date::GetDay() { if (IsValidDate()) - return JS_GetDayFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetDayFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -602,7 +603,7 @@ void CJS_Date::SetDay(int iDay) int CJS_Date::GetHours() { if (IsValidDate()) - return JS_GetHourFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetHourFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -616,7 +617,7 @@ void CJS_Date::SetHours(int iHours) int CJS_Date::GetMinutes() { if (IsValidDate()) - return JS_GetMinFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetMinFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -630,7 +631,7 @@ void CJS_Date::SetMinutes(int minutes) int CJS_Date::GetSeconds() { if (IsValidDate()) - return JS_GetSecFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetSecFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -650,12 +651,12 @@ CJS_Date::operator double() const { if(m_pDate.IsEmpty()) return 0.0; - return JS_ToNumber(m_pDate); + return JS_ToNumber(m_isolate, m_pDate); } CFX_WideString CJS_Date::ToString() const { if(m_pDate.IsEmpty()) return L""; - return JS_ToString(m_pDate); + return JS_ToString(m_isolate, m_pDate); } diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index 418508f89e..99db9e7a71 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -387,16 +387,15 @@ void global_alternate::CommitGlobalPersisitentVariables() void global_alternate::ObjectToArray(v8::Handle pObj, CJS_GlobalVariableArray& array) { - v8::Handle pKeyList = JS_GetObjectElementNames(pObj); - int nObjElements = pKeyList->Length(); - v8::Local context = pObj->CreationContext(); v8::Isolate* isolate = context->GetIsolate(); + v8::Handle pKeyList = JS_GetObjectElementNames(isolate, pObj); + int nObjElements = pKeyList->Length(); for (int i=0; i v = JS_GetObjectElement(isolate, pObj, ws.c_str()); @@ -408,7 +407,7 @@ void global_alternate::ObjectToArray(v8::Handle pObj, CJS_GlobalVari CJS_KeyValue* pObjElement = new CJS_KeyValue; pObjElement->nType = JS_GLOBALDATA_TYPE_NUMBER; pObjElement->sKey = sKey; - pObjElement->dData = JS_ToNumber(v); + pObjElement->dData = JS_ToNumber(isolate, v); array.Add(pObjElement); } break; @@ -417,7 +416,7 @@ void global_alternate::ObjectToArray(v8::Handle pObj, CJS_GlobalVari CJS_KeyValue* pObjElement = new CJS_KeyValue; pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN; pObjElement->sKey = sKey; - pObjElement->dData = JS_ToBoolean(v); + pObjElement->dData = JS_ToBoolean(isolate, v); array.Add(pObjElement); } break; @@ -436,7 +435,7 @@ void global_alternate::ObjectToArray(v8::Handle pObj, CJS_GlobalVari CJS_KeyValue* pObjElement = new CJS_KeyValue; pObjElement->nType = JS_GLOBALDATA_TYPE_OBJECT; pObjElement->sKey = sKey; - ObjectToArray(JS_ToObject(v), pObjElement->objData); + ObjectToArray(JS_ToObject(isolate, v), pObjElement->objData); array.Add(pObjElement); } break; -- cgit v1.2.3