Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: fpdfsdk/javascript/global.cpp

Issue 2242593002: Make FXJS_GetObjectElement return std::vector<CFX_WideString>. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/JS_Value.cpp ('k') | fxjs/fxjs_v8.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/JS_Value.cpp ('k') | fxjs/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698