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 "../../include/javascript/IJavaScript.h" | 7 #include "../../include/javascript/IJavaScript.h" |
| 8 #include "../../include/javascript/JS_Context.h" | 8 #include "../../include/javascript/JS_Context.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_EventHandler.h" | 10 #include "../../include/javascript/JS_EventHandler.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 { | 186 { |
| 187 DelProperty(cc, propname, sError); | 187 DelProperty(cc, propname, sError); |
| 188 return TRUE; | 188 return TRUE; |
| 189 } | 189 } |
| 190 default: | 190 default: |
| 191 return FALSE; | 191 return FALSE; |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 else | 194 else |
| 195 { | 195 { |
| 196 » » js_global_data* pData = NULL; | 196 » » void* pVoid = nullptr; |
| 197 » » CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname) ; | 197 » » if (!m_mapGlobal.Lookup(CFX_ByteString::FromUnicode(propname), p Void)) |
| 198 | |
| 199 » » if (m_mapGlobal.Lookup(sPropName, (void*&)pData)) | |
|
Tom Sepez
2015/07/20 23:59:58
note: fix illegal cast while were at it.
| |
| 200 » » { | |
| 201 » » » if (pData) | |
| 202 » » » { | |
| 203 » » » » if (!pData->bDeleted) | |
| 204 » » » » { | |
| 205 » » » » » switch (pData->nType) | |
| 206 » » » » » { | |
| 207 » » » » » case JS_GLOBALDATA_TYPE_NUMBER: | |
| 208 » » » » » » vp << pData->dData; | |
| 209 » » » » » » break; | |
| 210 » » » » » case JS_GLOBALDATA_TYPE_BOOLEAN: | |
| 211 » » » » » » vp << pData->bData; | |
| 212 » » » » » » break; | |
| 213 » » » » » case JS_GLOBALDATA_TYPE_STRING: | |
| 214 » » » » » » vp << pData->sData; | |
| 215 » » » » » » break; | |
| 216 » » » » » case JS_GLOBALDATA_TYPE_OBJECT: | |
| 217 » » » » » » { | |
| 218 » » » » » » » v8::Local<v8::Object> ob j = v8::Local<v8::Object>::New(vp.GetIsolate(),pData->pData); | |
| 219 » » » » » » » vp << obj; | |
| 220 » » » » » » » break; | |
| 221 » » » » » » } | |
| 222 » » » » » case JS_GLOBALDATA_TYPE_NULL: | |
| 223 » » » » » » vp.SetNull(); | |
| 224 » » » » » » break; | |
| 225 » » » » » default: | |
| 226 » » » » » » return FALSE; | |
| 227 » » » » » } | |
| 228 » » » » » return TRUE; | |
| 229 » » » » } | |
| 230 » » » » else | |
| 231 » » » » { | |
| 232 » » » » » return TRUE; | |
| 233 » » » » } | |
| 234 » » » } | |
| 235 » » » else | |
| 236 » » » { | |
| 237 » » » » vp.SetNull(); | |
| 238 » » » » return TRUE; | |
| 239 » » » } | |
| 240 » » } | |
| 241 » » else | |
| 242 { | 198 { |
| 243 vp.SetNull(); | 199 vp.SetNull(); |
| 244 return TRUE; | 200 return TRUE; |
| 245 } | 201 } |
| 202 if (!pVoid) | |
| 203 { | |
| 204 vp.SetNull(); | |
| 205 return TRUE; | |
| 206 } | |
| 207 js_global_data* pData = (js_global_data*)pVoid; | |
| 208 if (pData->bDeleted) | |
| 209 return TRUE; | |
| 210 | |
| 211 switch (pData->nType) | |
| 212 { | |
| 213 case JS_GLOBALDATA_TYPE_NUMBER: | |
| 214 vp << pData->dData; | |
| 215 break; | |
| 216 case JS_GLOBALDATA_TYPE_BOOLEAN: | |
| 217 vp << pData->bData; | |
| 218 break; | |
| 219 case JS_GLOBALDATA_TYPE_STRING: | |
| 220 vp << pData->sData; | |
| 221 break; | |
| 222 case JS_GLOBALDATA_TYPE_OBJECT: | |
| 223 { | |
| 224 v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(vp.Ge tIsolate(),pData->pData); | |
| 225 vp << obj; | |
| 226 break; | |
| 227 } | |
| 228 case JS_GLOBALDATA_TYPE_NULL: | |
| 229 vp.SetNull(); | |
| 230 break; | |
| 231 default: | |
| 232 return FALSE; | |
| 233 } | |
| 234 return TRUE; | |
|
Lei Zhang
2015/07/21 23:43:23
This can't be reached because of the "default" 3 l
Tom Sepez
2015/07/22 20:38:24
Killed defaults, breaks => returns to match if-bod
| |
| 246 } | 235 } |
| 247 | |
| 248 return FALSE; | 236 return FALSE; |
| 249 } | 237 } |
| 250 | 238 |
| 251 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) | 239 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) |
| 252 { | 240 { |
| 253 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 241 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 254 if (params.size() != 2) | 242 if (params.size() != 2) |
| 255 { | 243 { |
| 256 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 244 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 257 return FALSE; | 245 return FALSE; |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 if (nHash == JSCONST_nDateHash) | 601 if (nHash == JSCONST_nDateHash) |
| 614 return VT_date; | 602 return VT_date; |
| 615 if (nHash == JSCONST_nObjectHash) | 603 if (nHash == JSCONST_nObjectHash) |
| 616 return VT_object; | 604 return VT_object; |
| 617 if (nHash == JSCONST_nFXobjHash) | 605 if (nHash == JSCONST_nFXobjHash) |
| 618 return VT_fxobject; | 606 return VT_fxobject; |
| 619 | 607 |
| 620 return VT_unknown; | 608 return VT_unknown; |
| 621 } | 609 } |
| 622 | 610 |
| OLD | NEW |