| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 m_pApp = NULL; | 149 m_pApp = NULL; |
| 150 m_pDocument = NULL; | 150 m_pDocument = NULL; |
| 151 m_pFieldEventPath = NULL; | 151 m_pFieldEventPath = NULL; |
| 152 m_context.Reset(); | 152 m_context.Reset(); |
| 153 | 153 |
| 154 if (m_isolateManaged) | 154 if (m_isolateManaged) |
| 155 m_isolate->Dispose(); | 155 m_isolate->Dispose(); |
| 156 m_isolate = NULL; | 156 m_isolate = NULL; |
| 157 } | 157 } |
| 158 | 158 |
| 159 FX_BOOL CJS_Runtime::DefineJSObjects() { | 159 void CJS_Runtime::DefineJSObjects() { |
| 160 v8::Isolate::Scope isolate_scope(GetIsolate()); | 160 v8::Isolate::Scope isolate_scope(GetIsolate()); |
| 161 v8::Locker locker(GetIsolate()); | 161 v8::Locker locker(GetIsolate()); |
| 162 v8::HandleScope handle_scope(GetIsolate()); | 162 v8::HandleScope handle_scope(GetIsolate()); |
| 163 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); | 163 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); |
| 164 v8::Context::Scope context_scope(context); | 164 v8::Context::Scope context_scope(context); |
| 165 | 165 |
| 166 // The call order determines the "ObjDefID" assigned to each class. | 166 // The call order determines the "ObjDefID" assigned to each class. |
| 167 // ObjDefIDs 0 - 2 | 167 // ObjDefIDs 0 - 2 |
| 168 if (CJS_Border::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 168 CJS_Border::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 169 return FALSE; | 169 CJS_Display::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 170 if (CJS_Display::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 170 CJS_Font::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 171 return FALSE; | |
| 172 if (CJS_Font::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
| 173 return FALSE; | |
| 174 | 171 |
| 175 // ObjDefIDs 3 - 5 | 172 // ObjDefIDs 3 - 5 |
| 176 if (CJS_Highlight::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 173 CJS_Highlight::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 177 return FALSE; | 174 CJS_Position::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 178 if (CJS_Position::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 175 CJS_ScaleHow::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 179 return FALSE; | |
| 180 if (CJS_ScaleHow::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
| 181 return FALSE; | |
| 182 | 176 |
| 183 // ObjDefIDs 6 - 8 | 177 // ObjDefIDs 6 - 8 |
| 184 if (CJS_ScaleWhen::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 178 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 185 return FALSE; | 179 CJS_Style::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 186 if (CJS_Style::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 180 CJS_Zoomtype::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 187 return FALSE; | |
| 188 if (CJS_Zoomtype::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
| 189 return FALSE; | |
| 190 | 181 |
| 191 // ObjDefIDs 9 - 11 | 182 // ObjDefIDs 9 - 11 |
| 192 if (CJS_App::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 183 CJS_App::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 193 return FALSE; | 184 CJS_Color::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 194 if (CJS_Color::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 185 CJS_Console::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 195 return FALSE; | |
| 196 if (CJS_Console::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
| 197 return FALSE; | |
| 198 | 186 |
| 199 // ObjDefIDs 12 - 14 | 187 // ObjDefIDs 12 - 14 |
| 200 if (CJS_Document::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 188 CJS_Document::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
| 201 return FALSE; | 189 CJS_Event::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 202 if (CJS_Event::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 190 CJS_Field::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
| 203 return FALSE; | |
| 204 if (CJS_Field::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | |
| 205 return FALSE; | |
| 206 | 191 |
| 207 // ObjDefIDs 15 - 17 | 192 // ObjDefIDs 15 - 17 |
| 208 if (CJS_Global::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 193 CJS_Global::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 209 return FALSE; | 194 CJS_Icon::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
| 210 if (CJS_Icon::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 195 CJS_Util::DefineJSObjects(GetIsolate(), JS_STATIC); |
| 211 return FALSE; | |
| 212 if (CJS_Util::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
| 213 return FALSE; | |
| 214 | 196 |
| 215 // ObjDefIDs 18 - 20 | 197 // ObjDefIDs 18 - 20 (these can't fail, return void). |
| 216 if (CJS_PublicMethods::DefineJSObjects(GetIsolate()) < 0) | 198 CJS_PublicMethods::DefineJSObjects(GetIsolate()); |
| 217 return FALSE; | 199 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); |
| 218 if (CJS_GlobalConsts::DefineJSObjects(GetIsolate()) < 0) | 200 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); |
| 219 return FALSE; | |
| 220 if (CJS_GlobalArrays::DefineJSObjects(GetIsolate()) < 0) | |
| 221 return FALSE; | |
| 222 | 201 |
| 223 if (CJS_TimerObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 202 // ObjDefIDs 21 - 22. |
| 224 return FALSE; | 203 CJS_TimerObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
| 225 if (CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 204 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
| 226 return FALSE; | |
| 227 | |
| 228 return TRUE; | |
| 229 } | 205 } |
| 230 | 206 |
| 231 IFXJS_Context* CJS_Runtime::NewContext() { | 207 IFXJS_Context* CJS_Runtime::NewContext() { |
| 232 CJS_Context* p = new CJS_Context(this); | 208 CJS_Context* p = new CJS_Context(this); |
| 233 m_ContextArray.Add(p); | 209 m_ContextArray.Add(p); |
| 234 return p; | 210 return p; |
| 235 } | 211 } |
| 236 | 212 |
| 237 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { | 213 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { |
| 238 CJS_Context* pJSContext = (CJS_Context*)pContext; | 214 CJS_Context* pJSContext = (CJS_Context*)pContext; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // v8::Local<v8::Context>::New(GetIsolate(), m_context); | 375 // v8::Local<v8::Context>::New(GetIsolate(), m_context); |
| 400 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New( | 376 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New( |
| 401 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue()); | 377 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue()); |
| 402 context->Global()->Set( | 378 context->Global()->Set( |
| 403 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, | 379 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, |
| 404 utf8Name.GetLength()), | 380 utf8Name.GetLength()), |
| 405 propvalue); | 381 propvalue); |
| 406 | 382 |
| 407 return TRUE; | 383 return TRUE; |
| 408 } | 384 } |
| OLD | NEW |