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 29 matching lines...) Expand all Loading... |
40 class CJS_ObjDefintion | 40 class CJS_ObjDefintion |
41 { | 41 { |
42 public: | 42 public: |
43 CJS_ObjDefintion(v8::Isolate* isolate, const wchar_t* sObjName, FXJSOBJT
YPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned b
ApplyNew): | 43 CJS_ObjDefintion(v8::Isolate* isolate, const wchar_t* sObjName, FXJSOBJT
YPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned b
ApplyNew): |
44 objName(sObjName), objType(eObjType), m_pConstructor(pConstructor), m_
pDestructor(pDestructor),m_bApplyNew(bApplyNew),m_bSetAsGlobalObject(FALSE) | 44 objName(sObjName), objType(eObjType), m_pConstructor(pConstructor), m_
pDestructor(pDestructor),m_bApplyNew(bApplyNew),m_bSetAsGlobalObject(FALSE) |
45 { | 45 { |
46 v8::Isolate::Scope isolate_scope(isolate); | 46 v8::Isolate::Scope isolate_scope(isolate); |
47 v8::HandleScope handle_scope(isolate); | 47 v8::HandleScope handle_scope(isolate); |
48 | 48 |
49 v8::Handle<v8::ObjectTemplate> objTemplate = v8::ObjectTemplat
e::New(isolate); | 49 v8::Handle<v8::ObjectTemplate> objTemplate = v8::ObjectTemplat
e::New(isolate); |
50 » » objTemplate->SetInternalFieldCount(1); | 50 » » objTemplate->SetInternalFieldCount(2); |
51 m_objTemplate.Reset(isolate, objTemplate); | 51 m_objTemplate.Reset(isolate, objTemplate); |
52 | 52 |
53 //Document as the global object. | 53 //Document as the global object. |
54 if(FXSYS_wcscmp(sObjName, L"Document") == 0) | 54 if(FXSYS_wcscmp(sObjName, L"Document") == 0) |
55 { | 55 { |
56 m_bSetAsGlobalObject = TRUE; | 56 m_bSetAsGlobalObject = TRUE; |
57 } | 57 } |
58 | 58 |
59 } | 59 } |
60 ~CJS_ObjDefintion() | 60 ~CJS_ObjDefintion() |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 { | 520 { |
521 //It could be a global proxy object. | 521 //It could be a global proxy object. |
522 v8::Local<v8::Value> v = pObj->GetPrototype(); | 522 v8::Local<v8::Value> v = pObj->GetPrototype(); |
523 if(v->IsObject()) | 523 if(v->IsObject()) |
524 pPrivateData = (CJS_PrivateData*)v->ToObject()->GetAlign
edPointerFromInternalField(0); | 524 pPrivateData = (CJS_PrivateData*)v->ToObject()->GetAlign
edPointerFromInternalField(0); |
525 } | 525 } |
526 if(!pPrivateData) return NULL; | 526 if(!pPrivateData) return NULL; |
527 return pPrivateData->pPrivate; | 527 return pPrivateData->pPrivate; |
528 } | 528 } |
529 | 529 |
| 530 void JS_FreePrivate(void* pPrivateData) |
| 531 { |
| 532 delete (CJS_PrivateData*)pPrivateData; |
| 533 } |
| 534 |
530 void JS_FreePrivate(v8::Handle<v8::Object> pObj) | 535 void JS_FreePrivate(v8::Handle<v8::Object> pObj) |
531 { | 536 { |
532 if(pObj.IsEmpty() || !pObj->InternalFieldCount()) return; | 537 if(pObj.IsEmpty() || !pObj->InternalFieldCount()) return; |
533 » delete (CJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); | 538 » JS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0)); |
534 pObj->SetAlignedPointerInInternalField(0, NULL); | 539 pObj->SetAlignedPointerInInternalField(0, NULL); |
535 } | 540 } |
536 | 541 |
537 | 542 |
538 v8::Handle<v8::Value> JS_GetObjectValue(v8::Handle<v8::Object> pObj) | 543 v8::Handle<v8::Value> JS_GetObjectValue(v8::Handle<v8::Object> pObj) |
539 { | 544 { |
540 return pObj; | 545 return pObj; |
541 } | 546 } |
542 | 547 |
543 v8::Handle<v8::String> WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* Prop
ertyName, int Len = -1) | 548 v8::Handle<v8::String> WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* Prop
ertyName, int Len = -1) |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 { | 1035 { |
1031 return d != d; | 1036 return d != d; |
1032 } | 1037 } |
1033 | 1038 |
1034 double JS_LocalTime(double d) | 1039 double JS_LocalTime(double d) |
1035 { | 1040 { |
1036 return JS_GetDateTime() + _getDaylightSavingTA(d); | 1041 return JS_GetDateTime() + _getDaylightSavingTA(d); |
1037 } | 1042 } |
1038 | 1043 |
1039 //JavaScript time implement End. | 1044 //JavaScript time implement End. |
OLD | NEW |