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 "Consts.h" | 9 #include "Consts.h" |
10 #include "Document.h" | 10 #include "Document.h" |
11 #include "Field.h" | 11 #include "Field.h" |
12 #include "Icon.h" | 12 #include "Icon.h" |
13 #include "JS_Context.h" | 13 #include "JS_Context.h" |
14 #include "JS_Define.h" | 14 #include "JS_Define.h" |
15 #include "JS_EventHandler.h" | 15 #include "JS_EventHandler.h" |
16 #include "JS_GlobalData.h" | 16 #include "JS_GlobalData.h" |
17 #include "JS_Object.h" | 17 #include "JS_Object.h" |
18 #include "JS_Value.h" | 18 #include "JS_Value.h" |
19 #include "PublicMethods.h" | 19 #include "PublicMethods.h" |
20 #include "app.h" | 20 #include "app.h" |
21 #include "color.h" | 21 #include "color.h" |
22 #include "console.h" | 22 #include "console.h" |
23 #include "event.h" | 23 #include "event.h" |
24 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. | 24 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. |
25 #include "fpdfsdk/include/javascript/IJavaScript.h" | 25 #include "fpdfsdk/include/javascript/IJavaScript.h" |
26 #include "global.h" | 26 #include "global.h" |
27 #include "report.h" | 27 #include "report.h" |
28 #include "util.h" | 28 #include "util.h" |
| 29 #include "third_party/base/stl_util.h" |
29 | 30 |
30 // static | 31 // static |
31 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) { | 32 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) { |
32 FXJS_Initialize(slot, reinterpret_cast<v8::Isolate*>(isolate)); | 33 FXJS_Initialize(slot, reinterpret_cast<v8::Isolate*>(isolate)); |
33 } | 34 } |
34 | 35 |
35 // static | 36 // static |
36 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { | 37 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { |
37 return new CJS_Runtime(pEnv); | 38 return new CJS_Runtime(pEnv); |
38 } | 39 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 200 |
200 void CJS_Runtime::RemoveEventFromSet(const FieldEvent& event) { | 201 void CJS_Runtime::RemoveEventFromSet(const FieldEvent& event) { |
201 m_FieldEventSet.erase(event); | 202 m_FieldEventSet.erase(event); |
202 } | 203 } |
203 | 204 |
204 v8::Local<v8::Context> CJS_Runtime::NewJSContext() { | 205 v8::Local<v8::Context> CJS_Runtime::NewJSContext() { |
205 return v8::Local<v8::Context>::New(m_isolate, m_context); | 206 return v8::Local<v8::Context>::New(m_isolate, m_context); |
206 } | 207 } |
207 | 208 |
208 void CJS_Runtime::AddObserver(Observer* observer) { | 209 void CJS_Runtime::AddObserver(Observer* observer) { |
209 ASSERT(m_observers.find(observer) == m_observers.end()); | 210 ASSERT(!pdfium::ContainsKey(m_observers, observer)); |
210 m_observers.insert(observer); | 211 m_observers.insert(observer); |
211 } | 212 } |
212 | 213 |
213 void CJS_Runtime::RemoveObserver(Observer* observer) { | 214 void CJS_Runtime::RemoveObserver(Observer* observer) { |
214 ASSERT(m_observers.find(observer) != m_observers.end()); | 215 ASSERT(pdfium::ContainsKey(m_observers, observer)); |
215 m_observers.erase(observer); | 216 m_observers.erase(observer); |
216 } | 217 } |
OLD | NEW |