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/global.h" | 7 #include "fpdfsdk/javascript/global.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 break; | 154 break; |
155 } | 155 } |
156 } | 156 } |
157 return FALSE; | 157 return FALSE; |
158 } | 158 } |
159 | 159 |
160 FX_BOOL JSGlobalAlternate::setPersistent(IJS_Context* cc, | 160 FX_BOOL JSGlobalAlternate::setPersistent(IJS_Context* cc, |
161 const std::vector<CJS_Value>& params, | 161 const std::vector<CJS_Value>& params, |
162 CJS_Value& vRet, | 162 CJS_Value& vRet, |
163 CFX_WideString& sError) { | 163 CFX_WideString& sError) { |
164 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | |
165 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | |
166 if (params.size() != 2) { | 164 if (params.size() != 2) { |
167 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 165 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); |
168 return FALSE; | 166 return FALSE; |
169 } | 167 } |
170 | 168 |
| 169 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
171 auto it = m_mapGlobal.find(params[0].ToCFXByteString(pRuntime)); | 170 auto it = m_mapGlobal.find(params[0].ToCFXByteString(pRuntime)); |
172 if (it != m_mapGlobal.end()) { | 171 if (it != m_mapGlobal.end()) { |
173 JSGlobalData* pData = it->second; | 172 JSGlobalData* pData = it->second; |
174 if (!pData->bDeleted) { | 173 if (!pData->bDeleted) { |
175 pData->bPersistent = params[1].ToBool(pRuntime); | 174 pData->bPersistent = params[1].ToBool(pRuntime); |
176 return TRUE; | 175 return TRUE; |
177 } | 176 } |
178 } | 177 } |
179 | 178 |
180 sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL); | 179 sError = JSGetStringFromID(IDS_STRING_JSNOGLOBAL); |
181 return FALSE; | 180 return FALSE; |
182 } | 181 } |
183 | 182 |
184 void JSGlobalAlternate::UpdateGlobalPersistentVariables() { | 183 void JSGlobalAlternate::UpdateGlobalPersistentVariables() { |
185 CJS_Runtime* pRuntime = | 184 CJS_Runtime* pRuntime = |
186 static_cast<CJS_Runtime*>(CFXJS_Engine::CurrentEngineFromIsolate( | 185 static_cast<CJS_Runtime*>(CFXJS_Engine::CurrentEngineFromIsolate( |
187 m_pJSObject->ToV8Object()->GetIsolate())); | 186 m_pJSObject->ToV8Object()->GetIsolate())); |
188 | 187 |
189 for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) { | 188 for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) { |
190 CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i); | 189 CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 pNewData->nType = JS_GlobalDataType::NULLOBJ; | 433 pNewData->nType = JS_GlobalDataType::NULLOBJ; |
435 pNewData->bPersistent = bDefaultPersistent; | 434 pNewData->bPersistent = bDefaultPersistent; |
436 } break; | 435 } break; |
437 default: | 436 default: |
438 return FALSE; | 437 return FALSE; |
439 } | 438 } |
440 | 439 |
441 m_mapGlobal[propname] = pNewData; | 440 m_mapGlobal[propname] = pNewData; |
442 return TRUE; | 441 return TRUE; |
443 } | 442 } |
OLD | NEW |