OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/javascript/global.h" | 7 #include "fpdfsdk/javascript/global.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 void JSGlobalAlternate::ObjectToArray(IJS_Context* cc, | 271 void JSGlobalAlternate::ObjectToArray(IJS_Context* cc, |
272 v8::Local<v8::Object> pObj, | 272 v8::Local<v8::Object> pObj, |
273 CJS_GlobalVariableArray& array) { | 273 CJS_GlobalVariableArray& array) { |
274 v8::Isolate* isolate = pObj->GetIsolate(); | 274 v8::Isolate* isolate = pObj->GetIsolate(); |
275 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 275 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
276 v8::Local<v8::Array> pKeyList = FXJS_GetObjectElementNames(isolate, pObj); | 276 std::vector<CFX_WideString> pKeyList = |
277 int nObjElements = pKeyList->Length(); | 277 FXJS_GetObjectPropertyNames(isolate, pObj); |
278 for (int i = 0; i < nObjElements; i++) { | 278 for (const auto& ws : pKeyList) { |
279 CFX_WideString ws = | |
280 FXJS_ToString(isolate, FXJS_GetArrayElement(isolate, pKeyList, i)); | |
281 CFX_ByteString sKey = ws.UTF8Encode(); | 279 CFX_ByteString sKey = ws.UTF8Encode(); |
282 v8::Local<v8::Value> v = FXJS_GetObjectElement(isolate, pObj, ws); | 280 v8::Local<v8::Value> v = FXJS_GetObjectProperty(isolate, pObj, ws); |
283 switch (CJS_Value::GetValueType(v)) { | 281 switch (CJS_Value::GetValueType(v)) { |
284 case CJS_Value::VT_number: { | 282 case CJS_Value::VT_number: { |
285 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 283 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
286 pObjElement->nType = JS_GlobalDataType::NUMBER; | 284 pObjElement->nType = JS_GlobalDataType::NUMBER; |
287 pObjElement->sKey = sKey; | 285 pObjElement->sKey = sKey; |
288 pObjElement->dData = FXJS_ToNumber(isolate, v); | 286 pObjElement->dData = FXJS_ToNumber(isolate, v); |
289 array.Add(pObjElement); | 287 array.Add(pObjElement); |
290 } break; | 288 } break; |
291 case CJS_Value::VT_boolean: { | 289 case CJS_Value::VT_boolean: { |
292 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 290 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 pNewData->nType = JS_GlobalDataType::NULLOBJ; | 434 pNewData->nType = JS_GlobalDataType::NULLOBJ; |
437 pNewData->bPersistent = bDefaultPersistent; | 435 pNewData->bPersistent = bDefaultPersistent; |
438 } break; | 436 } break; |
439 default: | 437 default: |
440 return FALSE; | 438 return FALSE; |
441 } | 439 } |
442 | 440 |
443 m_mapGlobal[propname] = pNewData; | 441 m_mapGlobal[propname] = pNewData; |
444 return TRUE; | 442 return TRUE; |
445 } | 443 } |
OLD | NEW |