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 "fpdfsdk/javascript/cjs_runtime.h" | 7 #include "fpdfsdk/javascript/cjs_runtime.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 #ifdef PDF_ENABLE_XFA | 257 #ifdef PDF_ENABLE_XFA |
258 CFX_WideString ChangeObjName(const CFX_WideString& str) { | 258 CFX_WideString ChangeObjName(const CFX_WideString& str) { |
259 CFX_WideString sRet = str; | 259 CFX_WideString sRet = str; |
260 sRet.Replace(L"_", L"."); | 260 sRet.Replace(L"_", L"."); |
261 return sRet; | 261 return sRet; |
262 } | 262 } |
263 FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name, | 263 FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name, |
264 FXJSE_HVALUE hValue) { | 264 FXJSE_HVALUE hValue) { |
265 #ifdef PDF_ENABLE_XFA | 265 #ifdef PDF_ENABLE_XFA |
266 const FX_CHAR* name = utf8Name.GetCStr(); | 266 const FX_CHAR* name = utf8Name.c_str(); |
267 | 267 |
268 v8::Locker lock(GetIsolate()); | 268 v8::Locker lock(GetIsolate()); |
269 v8::Isolate::Scope isolate_scope(GetIsolate()); | 269 v8::Isolate::Scope isolate_scope(GetIsolate()); |
270 v8::HandleScope handle_scope(GetIsolate()); | 270 v8::HandleScope handle_scope(GetIsolate()); |
271 v8::Local<v8::Context> old_context = GetIsolate()->GetCurrentContext(); | 271 v8::Local<v8::Context> old_context = GetIsolate()->GetCurrentContext(); |
272 v8::Local<v8::Context> context = | 272 v8::Local<v8::Context> context = |
273 v8::Local<v8::Context>::New(GetIsolate(), m_context); | 273 v8::Local<v8::Context>::New(GetIsolate(), m_context); |
274 v8::Context::Scope context_scope(context); | 274 v8::Context::Scope context_scope(context); |
275 | 275 |
276 // Caution: We're about to hand to XFA an object that in order to invoke | 276 // Caution: We're about to hand to XFA an object that in order to invoke |
(...skipping 16 matching lines...) Expand all Loading... |
293 ((CFXJSE_Value*)hValue)->ForceSetValue(propvalue); | 293 ((CFXJSE_Value*)hValue)->ForceSetValue(propvalue); |
294 #endif | 294 #endif |
295 | 295 |
296 return TRUE; | 296 return TRUE; |
297 } | 297 } |
298 FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name, | 298 FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name, |
299 FXJSE_HVALUE hValue) { | 299 FXJSE_HVALUE hValue) { |
300 #ifdef PDF_ENABLE_XFA | 300 #ifdef PDF_ENABLE_XFA |
301 if (utf8Name.IsEmpty() || hValue == NULL) | 301 if (utf8Name.IsEmpty() || hValue == NULL) |
302 return FALSE; | 302 return FALSE; |
303 const FX_CHAR* name = utf8Name.GetCStr(); | 303 const FX_CHAR* name = utf8Name.c_str(); |
304 v8::Isolate* pIsolate = GetIsolate(); | 304 v8::Isolate* pIsolate = GetIsolate(); |
305 v8::Locker lock(pIsolate); | 305 v8::Locker lock(pIsolate); |
306 v8::Isolate::Scope isolate_scope(pIsolate); | 306 v8::Isolate::Scope isolate_scope(pIsolate); |
307 v8::HandleScope handle_scope(pIsolate); | 307 v8::HandleScope handle_scope(pIsolate); |
308 v8::Local<v8::Context> context = | 308 v8::Local<v8::Context> context = |
309 v8::Local<v8::Context>::New(pIsolate, m_context); | 309 v8::Local<v8::Context>::New(pIsolate, m_context); |
310 v8::Context::Scope context_scope(context); | 310 v8::Context::Scope context_scope(context); |
311 | 311 |
312 // v8::Local<v8::Context> tmpCotext = | 312 // v8::Local<v8::Context> tmpCotext = |
313 // v8::Local<v8::Context>::New(GetIsolate(), m_context); | 313 // v8::Local<v8::Context>::New(GetIsolate(), m_context); |
(...skipping 10 matching lines...) Expand all Loading... |
324 #endif | 324 #endif |
325 void CJS_Runtime::AddObserver(Observer* observer) { | 325 void CJS_Runtime::AddObserver(Observer* observer) { |
326 ASSERT(!pdfium::ContainsKey(m_observers, observer)); | 326 ASSERT(!pdfium::ContainsKey(m_observers, observer)); |
327 m_observers.insert(observer); | 327 m_observers.insert(observer); |
328 } | 328 } |
329 | 329 |
330 void CJS_Runtime::RemoveObserver(Observer* observer) { | 330 void CJS_Runtime::RemoveObserver(Observer* observer) { |
331 ASSERT(pdfium::ContainsKey(m_observers, observer)); | 331 ASSERT(pdfium::ContainsKey(m_observers, observer)); |
332 m_observers.erase(observer); | 332 m_observers.erase(observer); |
333 } | 333 } |
OLD | NEW |