| 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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_EventHandler.h" | 9 #include "../../include/javascript/JS_EventHandler.h" |
| 10 #include "../../include/javascript/JS_Runtime.h" | 10 #include "../../include/javascript/JS_Runtime.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 void* CJS_ArrayBufferAllocator::AllocateUninitialized(size_t length) { | 100 void* CJS_ArrayBufferAllocator::AllocateUninitialized(size_t length) { |
| 101 return malloc(length); | 101 return malloc(length); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void CJS_ArrayBufferAllocator::Free(void* data, size_t length) { | 104 void CJS_ArrayBufferAllocator::Free(void* data, size_t length) { |
| 105 free(data); | 105 free(data); |
| 106 } | 106 } |
| 107 | 107 |
| 108 /* ------------------------------ CJS_Runtime ------------------------------ */ | 108 /* ------------------------------ CJS_Runtime ------------------------------ */ |
| 109 extern v8::Persistent<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime*
pJSRuntime); | 109 extern v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJS
Runtime); |
| 110 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) : | 110 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) : |
| 111 m_pApp(pApp), | 111 m_pApp(pApp), |
| 112 m_pDocument(NULL), | 112 m_pDocument(NULL), |
| 113 m_bBlocking(FALSE), | 113 m_bBlocking(FALSE), |
| 114 m_bRegistered(FALSE), | 114 m_bRegistered(FALSE), |
| 115 m_pFieldEventPath(NULL) | 115 m_pFieldEventPath(NULL) |
| 116 { | 116 { |
| 117 if (FPDFXFA_GetApp()->GetJSERuntime()) { | 117 if (FPDFXFA_GetApp()->GetJSERuntime()) { |
| 118 m_isolate = (v8::Isolate*)FPDFXFA_GetApp()->GetJSERuntime(); | 118 m_isolate = (v8::Isolate*)FPDFXFA_GetApp()->GetJSERuntime(); |
| 119 } else { | 119 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 //m_isolate->Exit(); | 161 //m_isolate->Exit(); |
| 162 //m_isolate->Dispose(); | 162 //m_isolate->Dispose(); |
| 163 m_isolate = NULL; | 163 m_isolate = NULL; |
| 164 } | 164 } |
| 165 | 165 |
| 166 FX_BOOL CJS_Runtime::InitJSObjects() | 166 FX_BOOL CJS_Runtime::InitJSObjects() |
| 167 { | 167 { |
| 168 v8::Isolate::Scope isolate_scope(GetIsolate()); | 168 v8::Isolate::Scope isolate_scope(GetIsolate()); |
| 169 v8::Locker locker(GetIsolate()); | 169 v8::Locker locker(GetIsolate()); |
| 170 v8::HandleScope handle_scope(GetIsolate()); | 170 v8::HandleScope handle_scope(GetIsolate()); |
| 171 » v8::Handle<v8::Context> context = v8::Context::New(GetIsolate()); | 171 » v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); |
| 172 v8::Context::Scope context_scope(context); | 172 v8::Context::Scope context_scope(context); |
| 173 //0 - 8 | 173 //0 - 8 |
| 174 if (CJS_Border::Init(*this, JS_STATIC) < 0) return FALSE; | 174 if (CJS_Border::Init(*this, JS_STATIC) < 0) return FALSE; |
| 175 if (CJS_Display::Init(*this, JS_STATIC) < 0) return FALSE; | 175 if (CJS_Display::Init(*this, JS_STATIC) < 0) return FALSE; |
| 176 if (CJS_Font::Init(*this, JS_STATIC) < 0) return FALSE; | 176 if (CJS_Font::Init(*this, JS_STATIC) < 0) return FALSE; |
| 177 if (CJS_Highlight::Init(*this, JS_STATIC) < 0) return FALSE; | 177 if (CJS_Highlight::Init(*this, JS_STATIC) < 0) return FALSE; |
| 178 if (CJS_Position::Init(*this, JS_STATIC) < 0) return FALSE; | 178 if (CJS_Position::Init(*this, JS_STATIC) < 0) return FALSE; |
| 179 if (CJS_ScaleHow::Init(*this, JS_STATIC) < 0) return FALSE; | 179 if (CJS_ScaleHow::Init(*this, JS_STATIC) < 0) return FALSE; |
| 180 if (CJS_ScaleWhen::Init(*this, JS_STATIC) < 0) return FALSE; | 180 if (CJS_ScaleWhen::Init(*this, JS_STATIC) < 0) return FALSE; |
| 181 if (CJS_Style::Init(*this, JS_STATIC) < 0) return FALSE; | 181 if (CJS_Style::Init(*this, JS_STATIC) < 0) return FALSE; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 341 |
| 342 while (p) | 342 while (p) |
| 343 { | 343 { |
| 344 CJS_FieldEvent* pOld = p; | 344 CJS_FieldEvent* pOld = p; |
| 345 p = pOld->pNext; | 345 p = pOld->pNext; |
| 346 | 346 |
| 347 delete pOld; | 347 delete pOld; |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 v8::Handle<v8::Context>»CJS_Runtime::NewJSContext() | 351 v8::Local<v8::Context>» CJS_Runtime::NewJSContext() |
| 352 { | 352 { |
| 353 return v8::Local<v8::Context>::New(m_isolate, m_context); | 353 return v8::Local<v8::Context>::New(m_isolate, m_context); |
| 354 } | 354 } |
| 355 | 355 |
| 356 CFX_WideString ChangeObjName(const CFX_WideString& str) | 356 CFX_WideString ChangeObjName(const CFX_WideString& str) |
| 357 { | 357 { |
| 358 CFX_WideString sRet = str; | 358 CFX_WideString sRet = str; |
| 359 sRet.Replace(L"_", L"."); | 359 sRet.Replace(L"_", L"."); |
| 360 return sRet; | 360 return sRet; |
| 361 } | 361 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 v8::Local<v8::Context> context = | 394 v8::Local<v8::Context> context = |
| 395 v8::Local<v8::Context>::New(pIsolate, m_context); | 395 v8::Local<v8::Context>::New(pIsolate, m_context); |
| 396 v8::Context::Scope context_scope(context); | 396 v8::Context::Scope context_scope(context); |
| 397 | 397 |
| 398 //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsol
ate(), m_context); | 398 //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsol
ate(), m_context); |
| 399 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(GetIsolate(),
((CFXJSE_Value*)hValue)->DirectGetValue()); | 399 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(GetIsolate(),
((CFXJSE_Value*)hValue)->DirectGetValue()); |
| 400 context->Global()->Set(v8::String::NewFromUtf8(pIsolate, name, v8::Strin
g::kNormalString, utf8Name.GetLength()), propvalue); | 400 context->Global()->Set(v8::String::NewFromUtf8(pIsolate, name, v8::Strin
g::kNormalString, utf8Name.GetLength()), propvalue); |
| 401 | 401 |
| 402 return TRUE; | 402 return TRUE; |
| 403 } | 403 } |
| OLD | NEW |