| 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 "xfa/fxjse/context.h" | 7 #include "xfa/fxjse/context.h" |
| 8 | 8 |
| 9 #include "xfa/fxjse/class.h" | 9 #include "xfa/fxjse/class.h" |
| 10 #include "xfa/fxjse/scope_inline.h" | 10 #include "xfa/fxjse/scope_inline.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 FXJSE_GetGlobalObjectFromContext(hNewContext); | 150 FXJSE_GetGlobalObjectFromContext(hNewContext); |
| 151 FXJSE_UpdateObjectBinding(hGlobalObject, lpGlobalObject); | 151 FXJSE_UpdateObjectBinding(hGlobalObject, lpGlobalObject); |
| 152 pContext->m_hContext.Reset(pIsolate, hNewContext); | 152 pContext->m_hContext.Reset(pIsolate, hNewContext); |
| 153 return pContext; | 153 return pContext; |
| 154 } | 154 } |
| 155 | 155 |
| 156 CFXJSE_Context::CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} | 156 CFXJSE_Context::CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} |
| 157 | 157 |
| 158 CFXJSE_Context::~CFXJSE_Context() {} | 158 CFXJSE_Context::~CFXJSE_Context() {} |
| 159 | 159 |
| 160 void CFXJSE_Context::GetGlobalObject(CFXJSE_Value* pValue) { | 160 std::unique_ptr<CFXJSE_Value> CFXJSE_Context::GetGlobalObject() { |
| 161 ASSERT(pValue); | 161 std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(m_pIsolate)); |
| 162 |
| 162 CFXJSE_ScopeUtil_IsolateHandleContext scope(this); | 163 CFXJSE_ScopeUtil_IsolateHandleContext scope(this); |
| 163 v8::Local<v8::Context> hContext = | 164 v8::Local<v8::Context> hContext = |
| 164 v8::Local<v8::Context>::New(m_pIsolate, m_hContext); | 165 v8::Local<v8::Context>::New(m_pIsolate, m_hContext); |
| 165 v8::Local<v8::Object> hGlobalObject = hContext->Global(); | 166 v8::Local<v8::Object> hGlobalObject = hContext->Global(); |
| 166 pValue->ForceSetValue(hGlobalObject); | 167 pValue->ForceSetValue(hGlobalObject); |
| 168 |
| 169 return pValue; |
| 167 } | 170 } |
| 168 | 171 |
| 169 void CFXJSE_Context::EnableCompatibleMode() { | 172 void CFXJSE_Context::EnableCompatibleMode() { |
| 170 ExecuteScript(szCompatibleModeScript, nullptr, nullptr); | 173 ExecuteScript(szCompatibleModeScript, nullptr, nullptr); |
| 171 } | 174 } |
| 172 | 175 |
| 173 FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript, | 176 FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript, |
| 174 CFXJSE_Value* lpRetValue, | 177 CFXJSE_Value* lpRetValue, |
| 175 CFXJSE_Value* lpNewThisObject) { | 178 CFXJSE_Value* lpNewThisObject) { |
| 176 CFXJSE_ScopeUtil_IsolateHandleContext scope(this); | 179 CFXJSE_ScopeUtil_IsolateHandleContext scope(this); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 return TRUE; | 217 return TRUE; |
| 215 } | 218 } |
| 216 } | 219 } |
| 217 if (lpRetValue) { | 220 if (lpRetValue) { |
| 218 lpRetValue->m_hValue.Reset(m_pIsolate, | 221 lpRetValue->m_hValue.Reset(m_pIsolate, |
| 219 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); | 222 FXJSE_CreateReturnValue(m_pIsolate, trycatch)); |
| 220 } | 223 } |
| 221 return FALSE; | 224 return FALSE; |
| 222 } | 225 } |
| 223 } | 226 } |
| OLD | NEW |