| 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/JS_Value.h" | 7 #include "fpdfsdk/javascript/JS_Value.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 void CJS_Value::MaybeCoerceToNumber() { | 145 void CJS_Value::MaybeCoerceToNumber() { |
| 146 bool bAllowNaN = false; | 146 bool bAllowNaN = false; |
| 147 if (m_eType == VT_string) { | 147 if (m_eType == VT_string) { |
| 148 CFX_ByteString bstr = ToCFXByteString(); | 148 CFX_ByteString bstr = ToCFXByteString(); |
| 149 if (bstr.GetLength() == 0) | 149 if (bstr.GetLength() == 0) |
| 150 return; | 150 return; |
| 151 if (bstr == "NaN") | 151 if (bstr == "NaN") |
| 152 bAllowNaN = true; | 152 bAllowNaN = true; |
| 153 } | 153 } |
| 154 v8::TryCatch(m_pJSRuntime->GetIsolate()); | 154 v8::TryCatch try_catch(m_pJSRuntime->GetIsolate()); |
| 155 v8::MaybeLocal<v8::Number> maybeNum = | 155 v8::MaybeLocal<v8::Number> maybeNum = |
| 156 m_pValue->ToNumber(m_pJSRuntime->GetIsolate()->GetCurrentContext()); | 156 m_pValue->ToNumber(m_pJSRuntime->GetIsolate()->GetCurrentContext()); |
| 157 if (maybeNum.IsEmpty()) | 157 if (maybeNum.IsEmpty()) |
| 158 return; | 158 return; |
| 159 v8::Local<v8::Number> num = maybeNum.ToLocalChecked(); | 159 v8::Local<v8::Number> num = maybeNum.ToLocalChecked(); |
| 160 if (std::isnan(num->Value()) && !bAllowNaN) | 160 if (std::isnan(num->Value()) && !bAllowNaN) |
| 161 return; | 161 return; |
| 162 m_pValue = num; | 162 m_pValue = num; |
| 163 m_eType = VT_number; | 163 m_eType = VT_number; |
| 164 } | 164 } |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 for (size_t i = 0; i < nKeywords; ++i) { | 893 for (size_t i = 0; i < nKeywords; ++i) { |
| 894 const wchar_t* property = va_arg(ap, const wchar_t*); | 894 const wchar_t* property = va_arg(ap, const wchar_t*); |
| 895 v8::Local<v8::Value> v8Value = | 895 v8::Local<v8::Value> v8Value = |
| 896 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); | 896 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); |
| 897 if (!v8Value->IsUndefined()) | 897 if (!v8Value->IsUndefined()) |
| 898 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); | 898 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); |
| 899 } | 899 } |
| 900 va_end(ap); | 900 va_end(ap); |
| 901 return result; | 901 return result; |
| 902 } | 902 } |
| OLD | NEW |