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

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

Issue 1342403005: Merge to XFA: Don't pass null isolates to FXJS_ when we have a real isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime.cpp ('k') | no next file » | 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 "../../../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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 if (pObj->IsDate()) 490 if (pObj->IsDate())
491 return kFXJSValueNameDate; 491 return kFXJSValueNameDate;
492 if (pObj->IsObject()) 492 if (pObj->IsObject())
493 return kFXJSValueNameObject; 493 return kFXJSValueNameObject;
494 if (pObj->IsNull()) 494 if (pObj->IsNull())
495 return kFXJSValueNameNull; 495 return kFXJSValueNameNull;
496 if (pObj->IsUndefined()) 496 if (pObj->IsUndefined())
497 return kFXJSValueNameUndefined; 497 return kFXJSValueNameUndefined;
498 return NULL; 498 return NULL;
499 } 499 }
500 void FXJS_SetPrivate(v8::Local<v8::Object> pObj, void* p) {
501 FXJS_SetPrivate(NULL, pObj, p);
502 }
503
504 void* FXJS_GetPrivate(v8::Local<v8::Object> pObj) {
505 return FXJS_GetPrivate(NULL, pObj);
506 }
507 500
508 void FXJS_SetPrivate(v8::Isolate* pIsolate, 501 void FXJS_SetPrivate(v8::Isolate* pIsolate,
509 v8::Local<v8::Object> pObj, 502 v8::Local<v8::Object> pObj,
510 void* p) { 503 void* p) {
511 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 504 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
512 return; 505 return;
513 CFXJS_PrivateData* pPrivateData = 506 CFXJS_PrivateData* pPrivateData =
514 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); 507 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0);
515 if (!pPrivateData) 508 if (!pPrivateData)
516 return; 509 return;
517 pPrivateData->pPrivate = p; 510 pPrivateData->pPrivate = p;
518 } 511 }
519 512
520 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj) { 513 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj) {
521 if (pObj.IsEmpty()) 514 if (pObj.IsEmpty())
522 return NULL; 515 return nullptr;
523 CFXJS_PrivateData* pPrivateData = NULL; 516 CFXJS_PrivateData* pPrivateData = nullptr;
524 if (pObj->InternalFieldCount()) 517 if (pObj->InternalFieldCount()) {
525 pPrivateData = 518 pPrivateData =
526 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); 519 (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0);
527 else { 520 } else {
528 // It could be a global proxy object. 521 // It could be a global proxy object.
529 v8::Local<v8::Value> v = pObj->GetPrototype(); 522 v8::Local<v8::Value> v = pObj->GetPrototype();
530 v8::Isolate* isolate = (v8::Isolate*)pIsolate; 523 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
531 v8::Local<v8::Context> context = isolate->GetCurrentContext();
532 if (v->IsObject()) 524 if (v->IsObject())
533 pPrivateData = (CFXJS_PrivateData*)v->ToObject(context) 525 pPrivateData = (CFXJS_PrivateData*)v->ToObject(context)
534 .ToLocalChecked() 526 .ToLocalChecked()
535 ->GetAlignedPointerFromInternalField(0); 527 ->GetAlignedPointerFromInternalField(0);
536 } 528 }
537 if (!pPrivateData) 529 return pPrivateData ? pPrivateData->pPrivate : nullptr;
538 return NULL;
539 return pPrivateData->pPrivate;
540 } 530 }
541 531
542 void FXJS_FreePrivate(void* pPrivateData) { 532 void FXJS_FreePrivate(void* pPrivateData) {
543 delete (CFXJS_PrivateData*)pPrivateData; 533 delete (CFXJS_PrivateData*)pPrivateData;
544 } 534 }
545 535
546 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) { 536 void FXJS_FreePrivate(v8::Local<v8::Object> pObj) {
547 if (pObj.IsEmpty() || !pObj->InternalFieldCount()) 537 if (pObj.IsEmpty() || !pObj->InternalFieldCount())
548 return; 538 return;
549 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0)); 539 FXJS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0));
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 return v8::Local<v8::Array>(); 768 return v8::Local<v8::Array>();
779 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 769 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
780 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 770 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
781 } 771 }
782 772
783 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 773 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
784 pTo = pFrom; 774 pTo = pFrom;
785 } 775 }
786 776
787 777
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698