From 3cac3602f24f56413cc2ca312731675fc080b7ef Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 24 Oct 2017 15:15:27 -0400 Subject: Remove GetType from CJS_Value This CL removes the GetType method from CJS_Value and, instead, retrieves the value from the v8 object directly. Change-Id: Ia8390f3ead163c09a39cae493e75fccdd41a0961 Reviewed-on: https://pdfium-review.googlesource.com/16615 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/javascript/JS_Value.cpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'fpdfsdk/javascript/JS_Value.cpp') diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 35a5b1c682..f535f69f94 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -196,7 +196,7 @@ v8::Local CJS_Value::ToV8Value() const { void CJS_Value::MaybeCoerceToNumber(CJS_Runtime* pRuntime) { bool bAllowNaN = false; - if (GetType() == VT_string) { + if (ToV8Value()->IsString()) { ByteString bstr = ByteString::FromUnicode(pRuntime->ToWideString(ToV8Value())); if (bstr.GetLength() == 0) @@ -216,27 +216,6 @@ void CJS_Value::MaybeCoerceToNumber(CJS_Runtime* pRuntime) { m_pValue = num; } -// static -CJS_Value::Type CJS_Value::GetValueType(v8::Local value) { - if (value.IsEmpty()) - return VT_unknown; - if (value->IsString()) - return VT_string; - if (value->IsNumber()) - return VT_number; - if (value->IsBoolean()) - return VT_boolean; - if (value->IsDate()) - return VT_date; - if (value->IsObject()) - return VT_object; - if (value->IsNull()) - return VT_null; - if (value->IsUndefined()) - return VT_undefined; - return VT_unknown; -} - bool CJS_Value::IsArrayObject() const { return !m_pValue.IsEmpty() && m_pValue->IsArray(); } @@ -456,7 +435,7 @@ std::vector ExpandKeywordParams( for (size_t i = 0; i < size; ++i) result[i] = originals[i]; - if (originals.size() != 1 || originals[0].GetType() != CJS_Value::VT_object || + if (originals.size() != 1 || !originals[0].ToV8Value()->IsObject() || originals[0].IsArrayObject()) { return result; } -- cgit v1.2.3