| 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 "../../../xfa/src/fxjse/src/value.h" | 9 #include "../../../xfa/src/fxjse/src/value.h" |
| 10 #include "../../include/fpdfxfa/fpdfxfa_app.h" | 10 #include "../../include/fpdfxfa/fpdfxfa_app.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 void CJS_Runtime::DefineJSObjects() { | 103 void CJS_Runtime::DefineJSObjects() { |
| 104 v8::Isolate::Scope isolate_scope(GetIsolate()); | 104 v8::Isolate::Scope isolate_scope(GetIsolate()); |
| 105 v8::Locker locker(GetIsolate()); | 105 v8::Locker locker(GetIsolate()); |
| 106 v8::HandleScope handle_scope(GetIsolate()); | 106 v8::HandleScope handle_scope(GetIsolate()); |
| 107 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); | 107 v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); |
| 108 v8::Context::Scope context_scope(context); | 108 v8::Context::Scope context_scope(context); |
| 109 | 109 |
| 110 // The call order determines the "ObjDefID" assigned to each class. | 110 // The call order determines the "ObjDefID" assigned to each class. |
| 111 // ObjDefIDs 0 - 2 | 111 // ObjDefIDs 0 - 2 |
| 112 CJS_Border::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 112 CJS_Border::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 113 CJS_Display::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 113 CJS_Display::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 114 CJS_Font::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 114 CJS_Font::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 115 | 115 |
| 116 // ObjDefIDs 3 - 5 | 116 // ObjDefIDs 3 - 5 |
| 117 CJS_Highlight::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 117 CJS_Highlight::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 118 CJS_Position::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 118 CJS_Position::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 119 CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 119 CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 120 | 120 |
| 121 // ObjDefIDs 6 - 8 | 121 // ObjDefIDs 6 - 8 |
| 122 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 122 CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 123 CJS_Style::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 123 CJS_Style::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 124 CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 124 CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 125 | 125 |
| 126 // ObjDefIDs 9 - 11 | 126 // ObjDefIDs 9 - 11 |
| 127 CJS_App::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 127 CJS_App::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 128 CJS_Color::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 128 CJS_Color::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 129 CJS_Console::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 129 CJS_Console::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 130 | 130 |
| 131 // ObjDefIDs 12 - 14 | 131 // ObjDefIDs 12 - 14 |
| 132 CJS_Document::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 132 CJS_Document::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_GLOBAL); |
| 133 CJS_Event::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 133 CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 134 CJS_Field::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 134 CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 135 | 135 |
| 136 // ObjDefIDs 15 - 17 | 136 // ObjDefIDs 15 - 17 |
| 137 CJS_Global::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 137 CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 138 CJS_Icon::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 138 CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 139 CJS_Util::DefineJSObjects(GetIsolate(), FXJS_STATIC); | 139 CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 140 | 140 |
| 141 // ObjDefIDs 18 - 20 (these can't fail, return void). | 141 // ObjDefIDs 18 - 20 (these can't fail, return void). |
| 142 CJS_PublicMethods::DefineJSObjects(GetIsolate()); | 142 CJS_PublicMethods::DefineJSObjects(GetIsolate()); |
| 143 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); | 143 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); |
| 144 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); | 144 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); |
| 145 | 145 |
| 146 // ObjDefIDs 21 - 22. | 146 // ObjDefIDs 21 - 22. |
| 147 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 147 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 148 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC); | 148 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 149 } | 149 } |
| 150 | 150 |
| 151 IFXJS_Context* CJS_Runtime::NewContext() { | 151 IFXJS_Context* CJS_Runtime::NewContext() { |
| 152 CJS_Context* p = new CJS_Context(this); | 152 CJS_Context* p = new CJS_Context(this); |
| 153 m_ContextArray.Add(p); | 153 m_ContextArray.Add(p); |
| 154 return p; | 154 return p; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { | 157 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { |
| 158 CJS_Context* pJSContext = (CJS_Context*)pContext; | 158 CJS_Context* pJSContext = (CJS_Context*)pContext; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 178 v8::Locker locker(m_isolate); | 178 v8::Locker locker(m_isolate); |
| 179 v8::HandleScope handle_scope(m_isolate); | 179 v8::HandleScope handle_scope(m_isolate); |
| 180 v8::Local<v8::Context> context = | 180 v8::Local<v8::Context> context = |
| 181 v8::Local<v8::Context>::New(m_isolate, m_context); | 181 v8::Local<v8::Context>::New(m_isolate, m_context); |
| 182 v8::Context::Scope context_scope(context); | 182 v8::Context::Scope context_scope(context); |
| 183 | 183 |
| 184 m_pDocument = pReaderDoc; | 184 m_pDocument = pReaderDoc; |
| 185 if (pReaderDoc) { | 185 if (pReaderDoc) { |
| 186 v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate()); | 186 v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate()); |
| 187 if (!pThis.IsEmpty()) { | 187 if (!pThis.IsEmpty()) { |
| 188 if (FXJS_GetObjDefnID(pThis) == | 188 if (FXJS_GetObjDefnID(pThis) == CJS_Document::g_nObjDefnID) { |
| 189 FXJS_GetObjDefnID(GetIsolate(), L"Document")) { | |
| 190 if (CJS_Document* pJSDocument = | 189 if (CJS_Document* pJSDocument = |
| 191 (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) { | 190 (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) { |
| 192 if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject()) | 191 if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject()) |
| 193 pDocument->AttachDoc(pReaderDoc); | 192 pDocument->AttachDoc(pReaderDoc); |
| 194 } | 193 } |
| 195 } | 194 } |
| 196 } | 195 } |
| 197 } | 196 } |
| 198 } | 197 } |
| 199 } | 198 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 266 |
| 268 void CJS_Runtime::AddObserver(Observer* observer) { | 267 void CJS_Runtime::AddObserver(Observer* observer) { |
| 269 ASSERT(m_observers.find(observer) == m_observers.end()); | 268 ASSERT(m_observers.find(observer) == m_observers.end()); |
| 270 m_observers.insert(observer); | 269 m_observers.insert(observer); |
| 271 } | 270 } |
| 272 | 271 |
| 273 void CJS_Runtime::RemoveObserver(Observer* observer) { | 272 void CJS_Runtime::RemoveObserver(Observer* observer) { |
| 274 ASSERT(m_observers.find(observer) != m_observers.end()); | 273 ASSERT(m_observers.find(observer) != m_observers.end()); |
| 275 m_observers.erase(observer); | 274 m_observers.erase(observer); |
| 276 } | 275 } |
| OLD | NEW |