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 "JS_Runtime.h" | 7 #include "JS_Runtime.h" |
8 | 8 |
9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
10 #include "../../include/javascript/IJavaScript.h" | 10 #include "../../include/javascript/IJavaScript.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 void CJS_Runtime::DefineJSObjects() { | 79 void CJS_Runtime::DefineJSObjects() { |
80 v8::Isolate::Scope isolate_scope(GetIsolate()); | 80 v8::Isolate::Scope isolate_scope(GetIsolate()); |
81 v8::HandleScope handle_scope(GetIsolate()); | 81 v8::HandleScope handle_scope(GetIsolate()); |
82 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); | 82 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); |
83 v8::Context::Scope context_scope(context); | 83 v8::Context::Scope context_scope(context); |
84 | 84 |
85 // The call order determines the "ObjDefID" assigned to each class. | 85 // The call order determines the "ObjDefID" assigned to each class. |
86 // ObjDefIDs 0 - 2 | 86 // ObjDefIDs 0 - 2 |
87 CJS_Border::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 87 CJS_Border::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
88 CJS_Display::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 88 CJS_Display::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
89 CJS_Font::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 89 CJS_Font::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
90 | 90 |
91 // ObjDefIDs 3 - 5 | 91 // ObjDefIDs 3 - 5 |
92 CJS_Highlight::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 92 CJS_Highlight::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
93 CJS_Position::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 93 CJS_Position::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
94 CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 94 CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
95 | 95 |
96 // ObjDefIDs 6 - 8 | 96 // ObjDefIDs 6 - 8 |
97 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 97 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
98 CJS_Style::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 98 CJS_Style::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
99 CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 99 CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
100 | 100 |
101 // ObjDefIDs 9 - 11 | 101 // ObjDefIDs 9 - 11 |
102 CJS_App::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 102 CJS_App::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
103 CJS_Color::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 103 CJS_Color::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
104 CJS_Console::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 104 CJS_Console::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
105 | 105 |
106 // ObjDefIDs 12 - 14 | 106 // ObjDefIDs 12 - 14 |
107 CJS_Document::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 107 CJS_Document::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_GLOBAL); |
108 CJS_Event::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 108 CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
109 CJS_Field::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 109 CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
110 | 110 |
111 // ObjDefIDs 15 - 17 | 111 // ObjDefIDs 15 - 17 |
112 CJS_Global::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 112 CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
113 CJS_Icon::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 113 CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
114 CJS_Util::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 114 CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
115 | 115 |
116 // ObjDefIDs 18 - 20 (these can't fail, return void). | 116 // ObjDefIDs 18 - 20 (these can't fail, return void). |
117 CJS_PublicMethods::DefineJSObjects(GetIsolate()); | 117 CJS_PublicMethods::DefineJSObjects(GetIsolate()); |
118 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); | 118 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); |
119 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); | 119 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); |
120 | 120 |
121 // ObjDefIDs 21 - 22. | 121 // ObjDefIDs 21 - 22. |
122 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 122 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
123 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 123 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
124 } | 124 } |
125 | 125 |
126 IFXJS_Context* CJS_Runtime::NewContext() { | 126 IFXJS_Context* CJS_Runtime::NewContext() { |
127 CJS_Context* p = new CJS_Context(this); | 127 CJS_Context* p = new CJS_Context(this); |
128 m_ContextArray.Add(p); | 128 m_ContextArray.Add(p); |
129 return p; | 129 return p; |
130 } | 130 } |
131 | 131 |
132 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { | 132 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { |
133 CJS_Context* pJSContext = (CJS_Context*)pContext; | 133 CJS_Context* pJSContext = (CJS_Context*)pContext; |
(...skipping 18 matching lines...) Expand all Loading... |
152 v8::Isolate::Scope isolate_scope(m_isolate); | 152 v8::Isolate::Scope isolate_scope(m_isolate); |
153 v8::HandleScope handle_scope(m_isolate); | 153 v8::HandleScope handle_scope(m_isolate); |
154 v8::Local<v8::Context> context = | 154 v8::Local<v8::Context> context = |
155 v8::Local<v8::Context>::New(m_isolate, m_context); | 155 v8::Local<v8::Context>::New(m_isolate, m_context); |
156 v8::Context::Scope context_scope(context); | 156 v8::Context::Scope context_scope(context); |
157 | 157 |
158 m_pDocument = pReaderDoc; | 158 m_pDocument = pReaderDoc; |
159 if (pReaderDoc) { | 159 if (pReaderDoc) { |
160 v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate()); | 160 v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate()); |
161 if (!pThis.IsEmpty()) { | 161 if (!pThis.IsEmpty()) { |
162 if (FXJS_GetObjDefnID(pThis) == | 162 if (FXJS_GetObjDefnID(pThis) == CJS_Document::g_nObjDefnID) { |
163 FXJS_GetObjDefnID(GetIsolate(), L"Document")) { | |
164 if (CJS_Document* pJSDocument = | 163 if (CJS_Document* pJSDocument = |
165 (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) { | 164 (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) { |
166 if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject()) | 165 if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject()) |
167 pDocument->AttachDoc(pReaderDoc); | 166 pDocument->AttachDoc(pReaderDoc); |
168 } | 167 } |
169 } | 168 } |
170 } | 169 } |
171 } | 170 } |
172 } | 171 } |
173 } | 172 } |
(...skipping 18 matching lines...) Expand all Loading... |
192 void CJS_Runtime::RemoveObserver(Observer* observer) { | 191 void CJS_Runtime::RemoveObserver(Observer* observer) { |
193 ASSERT(m_observers.find(observer) != m_observers.end()); | 192 ASSERT(m_observers.find(observer) != m_observers.end()); |
194 m_observers.erase(observer); | 193 m_observers.erase(observer); |
195 } | 194 } |
196 | 195 |
197 CFX_WideString ChangeObjName(const CFX_WideString& str) { | 196 CFX_WideString ChangeObjName(const CFX_WideString& str) { |
198 CFX_WideString sRet = str; | 197 CFX_WideString sRet = str; |
199 sRet.Replace(L"_", L"."); | 198 sRet.Replace(L"_", L"."); |
200 return sRet; | 199 return sRet; |
201 } | 200 } |
OLD | NEW |