| 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 "../../../core/include/fxcrt/fx_basic.h" | 7 #include "../../../core/include/fxcrt/fx_basic.h" | 
| 8 #include "../../../core/include/fxcrt/fx_ext.h" | 8 #include "../../../core/include/fxcrt/fx_ext.h" | 
| 9 #include "../../include/jsapi/fxjs_v8.h" | 9 #include "../../include/jsapi/fxjs_v8.h" | 
| 10 #include "../../include/fsdk_define.h" | 10 #include "../../include/fsdk_define.h" | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 73         v8::Persistent<v8::ObjectTemplate> m_objTemplate; | 73         v8::Persistent<v8::ObjectTemplate> m_objTemplate; | 
| 74         v8::Persistent<v8::Object> m_StaticObj; | 74         v8::Persistent<v8::Object> m_StaticObj; | 
| 75 }; | 75 }; | 
| 76 | 76 | 
| 77 int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e
      ObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApply
      New) | 77 int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e
      ObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApply
      New) | 
| 78 { | 78 { | 
| 79         v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 79         v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 
| 80         v8::Isolate::Scope isolate_scope(isolate); | 80         v8::Isolate::Scope isolate_scope(isolate); | 
| 81         v8::HandleScope handle_scope(isolate); | 81         v8::HandleScope handle_scope(isolate); | 
| 82         CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); | 82         CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); | 
| 83 »       if(!pArray) | 83 »       if(!pArray) | 
| 84         { | 84         { | 
| 85 »       »       pArray = FX_NEW CFX_PtrArray(); | 85 »       »       pArray = new CFX_PtrArray(); | 
| 86                 isolate->SetData(0, pArray); | 86                 isolate->SetData(0, pArray); | 
| 87         } | 87         } | 
| 88 »       CJS_ObjDefintion* pObjDef = FX_NEW CJS_ObjDefintion(isolate, sObjName, e
      ObjType, pConstructor, pDestructor, bApplyNew); | 88 »       CJS_ObjDefintion* pObjDef = new CJS_ObjDefintion(isolate, sObjName, eObj
      Type, pConstructor, pDestructor, bApplyNew); | 
| 89         pArray->Add(pObjDef); | 89         pArray->Add(pObjDef); | 
| 90         return pArray->GetSize()-1; | 90         return pArray->GetSize()-1; | 
| 91 } | 91 } | 
| 92 | 92 | 
| 93 int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
      MethodName, v8::FunctionCallback pMethodCall, unsigned nParamNum) | 93 int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s
      MethodName, v8::FunctionCallback pMethodCall, unsigned nParamNum) | 
| 94 { | 94 { | 
| 95         v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 95         v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 
| 96         v8::Isolate::Scope isolate_scope(isolate); | 96         v8::Isolate::Scope isolate_scope(isolate); | 
| 97         v8::HandleScope handle_scope(isolate); | 97         v8::HandleScope handle_scope(isolate); | 
| 98 | 98 | 
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 256                 CFX_ByteString bs = ws.UTF8Encode(); | 256                 CFX_ByteString bs = ws.UTF8Encode(); | 
| 257                 v8::Handle<v8::String> objName = v8::String::NewFromUtf8(isolate
      , bs.c_str(), v8::String::kNormalString, bs.GetLength()); | 257                 v8::Handle<v8::String> objName = v8::String::NewFromUtf8(isolate
      , bs.c_str(), v8::String::kNormalString, bs.GetLength()); | 
| 258 | 258 | 
| 259 | 259 | 
| 260                 if(pObjDef->objType == JS_DYNAMIC) | 260                 if(pObjDef->objType == JS_DYNAMIC) | 
| 261                 { | 261                 { | 
| 262                         //Document is set as global object, need to construct it
       first. | 262                         //Document is set as global object, need to construct it
       first. | 
| 263                         if(ws.Equal(L"Document")) | 263                         if(ws.Equal(L"Document")) | 
| 264                         { | 264                         { | 
| 265 | 265 | 
| 266 »       »       »       »       CJS_PrivateData* pPrivateData = FX_NEW CJS_Priva
      teData; | 266 »       »       »       »       CJS_PrivateData* pPrivateData = new CJS_PrivateD
      ata; | 
| 267                                 pPrivateData->ObjDefID = i; | 267                                 pPrivateData->ObjDefID = i; | 
| 268                                 v8::Handle<v8::External> ptr = v8::External::New
      (isolate, pPrivateData); | 268                                 v8::Handle<v8::External> ptr = v8::External::New
      (isolate, pPrivateData); | 
| 269 | 269 | 
| 270                                 v8Context->Global()->GetPrototype()->ToObject()-
      >SetInternalField(0, ptr); | 270                                 v8Context->Global()->GetPrototype()->ToObject()-
      >SetInternalField(0, ptr); | 
| 271 | 271 | 
| 272                                 if(pObjDef->m_pConstructor) | 272                                 if(pObjDef->m_pConstructor) | 
| 273                                         pObjDef->m_pConstructor(context, v8Conte
      xt->Global()->GetPrototype()->ToObject(), v8Context->Global()->GetPrototype()->T
      oObject()); | 273                                         pObjDef->m_pConstructor(context, v8Conte
      xt->Global()->GetPrototype()->ToObject(), v8Context->Global()->GetPrototype()->T
      oObject()); | 
| 274                         } | 274                         } | 
| 275                 } | 275                 } | 
| 276                 else | 276                 else | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 370 | 370 | 
| 371         CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); | 371         CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); | 
| 372         if(!pArray) return v8::Handle<v8::Object>(); | 372         if(!pArray) return v8::Handle<v8::Object>(); | 
| 373 | 373 | 
| 374 | 374 | 
| 375         if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Handle<v8:
      :Object>(); | 375         if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Handle<v8:
      :Object>(); | 
| 376         CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID)
      ; | 376         CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID)
      ; | 
| 377 | 377 | 
| 378         v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 378         v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 
| 379         v8::Local<v8::ObjectTemplate> objTemp = v8::Local<v8::ObjectTemplate>::N
      ew(isolate, pObjDef->m_objTemplate); | 379         v8::Local<v8::ObjectTemplate> objTemp = v8::Local<v8::ObjectTemplate>::N
      ew(isolate, pObjDef->m_objTemplate); | 
|  | 380         v8::Local<v8::Object> obj = objTemp->NewInstance(); | 
| 380 | 381 | 
| 381 »       v8::Local<v8::Object> obj = objTemp->NewInstance(); | 382 »       CJS_PrivateData* pPrivateData = new CJS_PrivateData; | 
| 382 » |  | 
| 383 »       CJS_PrivateData* pPrivateData = FX_NEW CJS_PrivateData; |  | 
| 384         pPrivateData->ObjDefID = nObjDefnID; | 383         pPrivateData->ObjDefID = nObjDefnID; | 
|  | 384 | 
| 385         v8::Handle<v8::External> ptr = v8::External::New(isolate, pPrivateData); | 385         v8::Handle<v8::External> ptr = v8::External::New(isolate, pPrivateData); | 
| 386 »       obj->SetInternalField(0, ptr); | 386 »       obj->SetInternalField(0, ptr); | 
| 387 |  | 
| 388         if(pObjDef->m_pConstructor) | 387         if(pObjDef->m_pConstructor) | 
| 389                 pObjDef->m_pConstructor(pJSContext, obj, context->Global()->GetP
      rototype()->ToObject()); | 388                 pObjDef->m_pConstructor(pJSContext, obj, context->Global()->GetP
      rototype()->ToObject()); | 
| 390 | 389 | 
| 391         return obj; | 390         return obj; | 
| 392 } | 391 } | 
| 393 | 392 | 
| 394 v8::Handle<v8::Object> JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID) | 393 v8::Handle<v8::Object> JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID) | 
| 395 { | 394 { | 
| 396         v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 395         v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; | 
| 397         v8::Isolate::Scope isolate_scope(isolate); | 396         v8::Isolate::Scope isolate_scope(isolate); | 
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1041 { | 1040 { | 
| 1042         return d != d; | 1041         return d != d; | 
| 1043 } | 1042 } | 
| 1044 | 1043 | 
| 1045 double JS_LocalTime(double d) | 1044 double JS_LocalTime(double d) | 
| 1046 { | 1045 { | 
| 1047         return JS_GetDateTime() + _getDaylightSavingTA(d); | 1046         return JS_GetDateTime() + _getDaylightSavingTA(d); | 
| 1048 } | 1047 } | 
| 1049 | 1048 | 
| 1050 //JavaScript time implement End. | 1049 //JavaScript time implement End. | 
| OLD | NEW | 
|---|