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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 m_pApp = NULL; | 131 m_pApp = NULL; |
132 m_pDocument = NULL; | 132 m_pDocument = NULL; |
133 m_pFieldEventPath = NULL; | 133 m_pFieldEventPath = NULL; |
134 m_context.Reset(); | 134 m_context.Reset(); |
135 | 135 |
136 if (m_isolateManaged) | 136 if (m_isolateManaged) |
137 m_isolate->Dispose(); | 137 m_isolate->Dispose(); |
138 } | 138 } |
139 | 139 |
140 FX_BOOL CJS_Runtime::DefineJSObjects() { | 140 void CJS_Runtime::DefineJSObjects() { |
141 v8::Isolate::Scope isolate_scope(GetIsolate()); | 141 v8::Isolate::Scope isolate_scope(GetIsolate()); |
142 v8::HandleScope handle_scope(GetIsolate()); | 142 v8::HandleScope handle_scope(GetIsolate()); |
143 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); | 143 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); |
144 v8::Context::Scope context_scope(context); | 144 v8::Context::Scope context_scope(context); |
145 | 145 |
146 // The call order determines the "ObjDefID" assigned to each class. | 146 // The call order determines the "ObjDefID" assigned to each class. |
147 // ObjDefIDs 0 - 2 | 147 // ObjDefIDs 0 - 2 |
148 if (CJS_Border::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 148 CJS_Border::DefineJSObjects(GetIsolate(), JS_STATIC); |
149 return FALSE; | 149 CJS_Display::DefineJSObjects(GetIsolate(), JS_STATIC); |
150 if (CJS_Display::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 150 CJS_Font::DefineJSObjects(GetIsolate(), JS_STATIC); |
151 return FALSE; | |
152 if (CJS_Font::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
153 return FALSE; | |
154 | 151 |
155 // ObjDefIDs 3 - 5 | 152 // ObjDefIDs 3 - 5 |
156 if (CJS_Highlight::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 153 CJS_Highlight::DefineJSObjects(GetIsolate(), JS_STATIC); |
157 return FALSE; | 154 CJS_Position::DefineJSObjects(GetIsolate(), JS_STATIC); |
158 if (CJS_Position::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 155 CJS_ScaleHow::DefineJSObjects(GetIsolate(), JS_STATIC); |
159 return FALSE; | |
160 if (CJS_ScaleHow::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
161 return FALSE; | |
162 | 156 |
163 // ObjDefIDs 6 - 8 | 157 // ObjDefIDs 6 - 8 |
164 if (CJS_ScaleWhen::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 158 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), JS_STATIC); |
165 return FALSE; | 159 CJS_Style::DefineJSObjects(GetIsolate(), JS_STATIC); |
166 if (CJS_Style::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 160 CJS_Zoomtype::DefineJSObjects(GetIsolate(), JS_STATIC); |
167 return FALSE; | |
168 if (CJS_Zoomtype::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
169 return FALSE; | |
170 | 161 |
171 // ObjDefIDs 9 - 11 | 162 // ObjDefIDs 9 - 11 |
172 if (CJS_App::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 163 CJS_App::DefineJSObjects(GetIsolate(), JS_STATIC); |
173 return FALSE; | 164 CJS_Color::DefineJSObjects(GetIsolate(), JS_STATIC); |
174 if (CJS_Color::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 165 CJS_Console::DefineJSObjects(GetIsolate(), JS_STATIC); |
175 return FALSE; | |
176 if (CJS_Console::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
177 return FALSE; | |
178 | 166 |
179 // ObjDefIDs 12 - 14 | 167 // ObjDefIDs 12 - 14 |
180 if (CJS_Document::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 168 CJS_Document::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
181 return FALSE; | 169 CJS_Event::DefineJSObjects(GetIsolate(), JS_STATIC); |
182 if (CJS_Event::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 170 CJS_Field::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
183 return FALSE; | |
184 if (CJS_Field::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | |
185 return FALSE; | |
186 | 171 |
187 // ObjDefIDs 15 - 17 | 172 // ObjDefIDs 15 - 17 |
188 if (CJS_Global::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | 173 CJS_Global::DefineJSObjects(GetIsolate(), JS_STATIC); |
189 return FALSE; | 174 CJS_Icon::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
190 if (CJS_Icon::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 175 CJS_Util::DefineJSObjects(GetIsolate(), JS_STATIC); |
191 return FALSE; | |
192 if (CJS_Util::DefineJSObjects(GetIsolate(), JS_STATIC) < 0) | |
193 return FALSE; | |
194 | 176 |
195 // ObjDefIDs 18 - 20 | 177 // ObjDefIDs 18 - 20 (these can't fail, return void). |
196 if (CJS_PublicMethods::DefineJSObjects(GetIsolate()) < 0) | 178 CJS_PublicMethods::DefineJSObjects(GetIsolate()); |
197 return FALSE; | 179 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); |
198 if (CJS_GlobalConsts::DefineJSObjects(GetIsolate()) < 0) | 180 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); |
199 return FALSE; | |
200 if (CJS_GlobalArrays::DefineJSObjects(GetIsolate()) < 0) | |
201 return FALSE; | |
202 | 181 |
203 if (CJS_TimerObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 182 // ObjDefIDs 21 - 22. |
204 return FALSE; | 183 CJS_TimerObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
205 if (CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0) | 184 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC); |
206 return FALSE; | |
207 | |
208 return TRUE; | |
209 } | 185 } |
210 | 186 |
211 IFXJS_Context* CJS_Runtime::NewContext() { | 187 IFXJS_Context* CJS_Runtime::NewContext() { |
212 CJS_Context* p = new CJS_Context(this); | 188 CJS_Context* p = new CJS_Context(this); |
213 m_ContextArray.Add(p); | 189 m_ContextArray.Add(p); |
214 return p; | 190 return p; |
215 } | 191 } |
216 | 192 |
217 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { | 193 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { |
218 CJS_Context* pJSContext = (CJS_Context*)pContext; | 194 CJS_Context* pJSContext = (CJS_Context*)pContext; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 305 |
330 v8::Local<v8::Context> CJS_Runtime::NewJSContext() { | 306 v8::Local<v8::Context> CJS_Runtime::NewJSContext() { |
331 return v8::Local<v8::Context>::New(m_isolate, m_context); | 307 return v8::Local<v8::Context>::New(m_isolate, m_context); |
332 } | 308 } |
333 | 309 |
334 CFX_WideString ChangeObjName(const CFX_WideString& str) { | 310 CFX_WideString ChangeObjName(const CFX_WideString& str) { |
335 CFX_WideString sRet = str; | 311 CFX_WideString sRet = str; |
336 sRet.Replace(L"_", L"."); | 312 sRet.Replace(L"_", L"."); |
337 return sRet; | 313 return sRet; |
338 } | 314 } |
OLD | NEW |