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

Side by Side Diff: fpdfsdk/src/jsapi/fxjs_v8.cpp

Issue 1350703003: Don't pass null isolates to FXJS_ when we have a real isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 3 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
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 "../../../core/include/fxcrt/fx_basic.h" 7 #include "../../../core/include/fxcrt/fx_basic.h"
8 #include "../../include/fsdk_define.h" 8 #include "../../include/fsdk_define.h"
9 #include "../../include/jsapi/fxjs_v8.h" 9 #include "../../include/jsapi/fxjs_v8.h"
10 10
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (pObj->IsDate()) 482 if (pObj->IsDate())
483 return kFXJSValueNameDate; 483 return kFXJSValueNameDate;
484 if (pObj->IsObject()) 484 if (pObj->IsObject())
485 return kFXJSValueNameObject; 485 return kFXJSValueNameObject;
486 if (pObj->IsNull()) 486 if (pObj->IsNull())
487 return kFXJSValueNameNull; 487 return kFXJSValueNameNull;
488 if (pObj->IsUndefined()) 488 if (pObj->IsUndefined())
489 return kFXJSValueNameUndefined; 489 return kFXJSValueNameUndefined;
490 return NULL; 490 return NULL;
491 } 491 }
492 void FXJS_SetPrivate(v8::Local<v8::Object> pObj, void* p) {
493 FXJS_SetPrivate(NULL, pObj, p);
494 }
495
496 void* FXJS_GetPrivate(v8::Local<v8::Object> pObj) {
497 return FXJS_GetPrivate(NULL, pObj);
498 }
499 492
500 void FXJS_SetPrivate(v8::Isolate* pIsolate, 493 void FXJS_SetPrivate(v8::Isolate* pIsolate,
501 v8::Local<v8::Object> pObj, 494 v8::Local<v8::Object> pObj,
502 void* p) { 495 void* p) {
503 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 496 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
504 return; 497 return;
505 CFXJS_PrivateData* pPrivateData = 498 CFXJS_PrivateData* pPrivateData =
506 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); 499 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0);
507 if (!pPrivateData) 500 if (!pPrivateData)
508 return; 501 return;
509 pPrivateData->pPrivate = p; 502 pPrivateData->pPrivate = p;
510 } 503 }
511 504
512 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj) { 505 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj) {
513 if (pObj.IsEmpty()) 506 if (pObj.IsEmpty())
514 return NULL; 507 return nullptr;
515 CFXJS_PrivateData* pPrivateData = NULL; 508 CFXJS_PrivateData* pPrivateData = nullptr;
516 if (pObj->InternalFieldCount()) 509 if (pObj->InternalFieldCount()) {
517 pPrivateData = 510 pPrivateData =
518 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); 511 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0);
519 else { 512 } else {
520 // It could be a global proxy object. 513 // It could be a global proxy object.
521 v8::Local<v8::Value> v = pObj->GetPrototype(); 514 v8::Local<v8::Value> v = pObj->GetPrototype();
522 v8::Isolate* isolate = (v8::Isolate*)pIsolate; 515 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
523 v8::Local<v8::Context> context = isolate->GetCurrentContext();
524 if (v->IsObject()) 516 if (v->IsObject())
525 pPrivateData = (CFXJS_PrivateData*)v->ToObject(context) 517 pPrivateData = (CFXJS_PrivateData*)v->ToObject(context)
526 .ToLocalChecked() 518 .ToLocalChecked()
527 ->GetAlignedPointerFromInternalField(0); 519 ->GetAlignedPointerFromInternalField(0);
528 } 520 }
529 if (!pPrivateData) 521 return pPrivateData ? pPrivateData->pPrivate : nullptr;
530 return NULL;
531 return pPrivateData->pPrivate;
532 } 522 }
533 523
534 void FXJS_FreePrivate(void* pPrivateData) { 524 void FXJS_FreePrivate(void* pPrivateData) {
535 delete (CFXJS_PrivateData*)pPrivateData; 525 delete (CFXJS_PrivateData*)pPrivateData;
536 } 526 }
537 527
538 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) { 528 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) {
539 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 529 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
540 return; 530 return;
541 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0)); 531 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0));
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 return v8::Local<v8::Array>(); 760 return v8::Local<v8::Array>();
771 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 761 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
772 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 762 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
773 } 763 }
774 764
775 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 765 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
776 pTo = pFrom; 766 pTo = pFrom;
777 } 767 }
778 768
779 769
OLDNEW
« fpdfsdk/src/javascript/Field.cpp ('K') | « fpdfsdk/src/javascript/JS_Runtime.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698