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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Do so now. | 270 // Do so now. |
271 // TODO(tsepez): redesign PDF-side objects to not rely on v8::Context's | 271 // TODO(tsepez): redesign PDF-side objects to not rely on v8::Context's |
272 // embedder data slots, and/or to always use the right context. | 272 // embedder data slots, and/or to always use the right context. |
273 FXJS_SetRuntimeForV8Context(old_context, this); | 273 FXJS_SetRuntimeForV8Context(old_context, this); |
274 | 274 |
275 v8::Local<v8::Value> propvalue = | 275 v8::Local<v8::Value> propvalue = |
276 context->Global()->Get(v8::String::NewFromUtf8( | 276 context->Global()->Get(v8::String::NewFromUtf8( |
277 GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength())); | 277 GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength())); |
278 | 278 |
279 if (propvalue.IsEmpty()) { | 279 if (propvalue.IsEmpty()) { |
280 FXJSE_Value_SetUndefined(pValue); | 280 pValue->SetUndefined(); |
281 return FALSE; | 281 return FALSE; |
282 } | 282 } |
283 pValue->ForceSetValue(propvalue); | 283 pValue->ForceSetValue(propvalue); |
284 #endif | 284 #endif |
285 | 285 |
286 return TRUE; | 286 return TRUE; |
287 } | 287 } |
288 FX_BOOL CJS_Runtime::SetValueByName(const CFX_ByteStringC& utf8Name, | 288 FX_BOOL CJS_Runtime::SetValueByName(const CFX_ByteStringC& utf8Name, |
289 CFXJSE_Value* pValue) { | 289 CFXJSE_Value* pValue) { |
290 #ifdef PDF_ENABLE_XFA | 290 #ifdef PDF_ENABLE_XFA |
(...skipping 22 matching lines...) Expand all Loading... |
313 #endif | 313 #endif |
314 void CJS_Runtime::AddObserver(Observer* observer) { | 314 void CJS_Runtime::AddObserver(Observer* observer) { |
315 ASSERT(!pdfium::ContainsKey(m_observers, observer)); | 315 ASSERT(!pdfium::ContainsKey(m_observers, observer)); |
316 m_observers.insert(observer); | 316 m_observers.insert(observer); |
317 } | 317 } |
318 | 318 |
319 void CJS_Runtime::RemoveObserver(Observer* observer) { | 319 void CJS_Runtime::RemoveObserver(Observer* observer) { |
320 ASSERT(pdfium::ContainsKey(m_observers, observer)); | 320 ASSERT(pdfium::ContainsKey(m_observers, observer)); |
321 m_observers.erase(observer); | 321 m_observers.erase(observer); |
322 } | 322 } |
OLD | NEW |