Chromium Code Reviews| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 return sRet; | 238 return sRet; |
| 239 } | 239 } |
| 240 FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name, | 240 FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name, |
| 241 FXJSE_HVALUE hValue) { | 241 FXJSE_HVALUE hValue) { |
| 242 #ifdef PDF_ENABLE_XFA | 242 #ifdef PDF_ENABLE_XFA |
| 243 const FX_CHAR* name = utf8Name.GetCStr(); | 243 const FX_CHAR* name = utf8Name.GetCStr(); |
| 244 | 244 |
| 245 v8::Locker lock(GetIsolate()); | 245 v8::Locker lock(GetIsolate()); |
| 246 v8::Isolate::Scope isolate_scope(GetIsolate()); | 246 v8::Isolate::Scope isolate_scope(GetIsolate()); |
| 247 v8::HandleScope handle_scope(GetIsolate()); | 247 v8::HandleScope handle_scope(GetIsolate()); |
| 248 v8::Local<v8::Context> old_context = GetIsolate()->GetCurrentContext(); | |
| 248 v8::Local<v8::Context> context = | 249 v8::Local<v8::Context> context = |
| 249 v8::Local<v8::Context>::New(GetIsolate(), m_context); | 250 v8::Local<v8::Context>::New(GetIsolate(), m_context); |
| 250 v8::Context::Scope context_scope(context); | 251 v8::Context::Scope context_scope(context); |
| 251 | 252 |
| 252 // v8::Local<v8::Context> tmpCotext = | 253 // Caution: We're about to hand to XFA an object that may well require |
| 253 // v8::Local<v8::Context>::New(GetIsolate(), m_context); | 254 // |context| to obtain this CJS_Runtime, but XFA will invoke against |
| 255 // its own |old_context|, which has no CJS_Runtime. Associate ourselves | |
| 256 // with it at this point. | |
|
jochen (gone - plz use gerrit)
2015/11/07 05:56:18
i don't understand this comment?
Tom Sepez
2015/11/09 22:15:05
Because the new XFA code and the old PDF code don'
| |
| 257 // TODO(tsepez): redesign PDF-side objects to not rely on context. | |
|
jochen (gone - plz use gerrit)
2015/11/07 05:56:18
nor this
Tom Sepez
2015/11/09 22:15:05
Changed. Better?
| |
| 258 FXJS_SetRuntimeForV8Context(old_context, this); | |
| 259 | |
| 254 v8::Local<v8::Value> propvalue = | 260 v8::Local<v8::Value> propvalue = |
| 255 context->Global()->Get(v8::String::NewFromUtf8( | 261 context->Global()->Get(v8::String::NewFromUtf8( |
| 256 GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength())); | 262 GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength())); |
| 257 | 263 |
| 258 if (propvalue.IsEmpty()) { | 264 if (propvalue.IsEmpty()) { |
| 259 FXJSE_Value_SetUndefined(hValue); | 265 FXJSE_Value_SetUndefined(hValue); |
| 260 return FALSE; | 266 return FALSE; |
| 261 } | 267 } |
| 262 ((CFXJSE_Value*)hValue)->ForceSetValue(propvalue); | 268 ((CFXJSE_Value*)hValue)->ForceSetValue(propvalue); |
| 263 #endif | 269 #endif |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 292 | 298 |
| 293 void CJS_Runtime::AddObserver(Observer* observer) { | 299 void CJS_Runtime::AddObserver(Observer* observer) { |
| 294 ASSERT(m_observers.find(observer) == m_observers.end()); | 300 ASSERT(m_observers.find(observer) == m_observers.end()); |
| 295 m_observers.insert(observer); | 301 m_observers.insert(observer); |
| 296 } | 302 } |
| 297 | 303 |
| 298 void CJS_Runtime::RemoveObserver(Observer* observer) { | 304 void CJS_Runtime::RemoveObserver(Observer* observer) { |
| 299 ASSERT(m_observers.find(observer) != m_observers.end()); | 305 ASSERT(m_observers.find(observer) != m_observers.end()); |
| 300 m_observers.erase(observer); | 306 m_observers.erase(observer); |
| 301 } | 307 } |
| OLD | NEW |