From dd6a46c7eddc31d29b2d2630378c52c25363ce59 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 26 May 2016 08:41:45 -0700 Subject: Revert of Remove parameters which are always null (patchset #1 id:1 of https://codereview.chromium.org/2009413002/ ) Reason for revert: Suspect that the lack of this parameter being passed accurately to GetObject is leading to https://bugs.chromium.org/p/chromium/issues/detail?id=613607, and that the right fix will be to pass it. Original issue's description: > Remove parameters which are always null > > These parameters are never set, remove them and their supporting code. > > Committed: https://pdfium.googlesource.com/pdfium/+/818e1900a3811e1bde1e594e4966db612f845966 TBR=tsepez@chromium.org,thestig@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2014863002 --- xfa/fxjse/cfxjse_arguments.h | 2 +- xfa/fxjse/class.cpp | 5 +++-- xfa/fxjse/include/fxjse.h | 2 +- xfa/fxjse/util_inline.h | 11 ++++++++++- xfa/fxjse/value.cpp | 9 +++++---- xfa/fxjse/value.h | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) (limited to 'xfa/fxjse') diff --git a/xfa/fxjse/cfxjse_arguments.h b/xfa/fxjse/cfxjse_arguments.h index d7b6734e14..423e22d888 100644 --- a/xfa/fxjse/cfxjse_arguments.h +++ b/xfa/fxjse/cfxjse_arguments.h @@ -18,7 +18,7 @@ class CFXJSE_Arguments { int32_t GetInt32(int32_t index) const; FX_FLOAT GetFloat(int32_t index) const; CFX_ByteString GetUTF8String(int32_t index) const; - void* GetObject(int32_t index) const; + void* GetObject(int32_t index, FXJSE_HCLASS hClass = nullptr) const; FXJSE_HVALUE GetReturnValue(); }; diff --git a/xfa/fxjse/class.cpp b/xfa/fxjse/class.cpp index 18c542a65e..ff5990aa85 100644 --- a/xfa/fxjse/class.cpp +++ b/xfa/fxjse/class.cpp @@ -183,7 +183,7 @@ CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const { return CFX_ByteString(*szStringVal); } -void* CFXJSE_Arguments::GetObject(int32_t index) const { +void* CFXJSE_Arguments::GetObject(int32_t index, FXJSE_HCLASS hClass) const { const CFXJSE_ArgumentsImpl* lpArguments = reinterpret_cast(this); v8::Local hValue = (*lpArguments->m_pInfo)[index]; @@ -191,7 +191,8 @@ void* CFXJSE_Arguments::GetObject(int32_t index) const { if (!hValue->IsObject()) { return NULL; } - return FXJSE_RetrieveObjectBinding(hValue.As()); + CFXJSE_Class* lpClass = reinterpret_cast(hClass); + return FXJSE_RetrieveObjectBinding(hValue.As(), lpClass); } FXJSE_HVALUE CFXJSE_Arguments::GetReturnValue() { diff --git a/xfa/fxjse/include/fxjse.h b/xfa/fxjse/include/fxjse.h index fce1b969fb..d009372c54 100644 --- a/xfa/fxjse/include/fxjse.h +++ b/xfa/fxjse/include/fxjse.h @@ -103,7 +103,7 @@ FX_FLOAT FXJSE_Value_ToFloat(FXJSE_HVALUE hValue); double FXJSE_Value_ToDouble(FXJSE_HVALUE hValue); int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue); void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, CFX_ByteString& szStrOutput); -void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue); +void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue, FXJSE_HCLASS hClass); void FXJSE_Value_SetUndefined(FXJSE_HVALUE hValue); void FXJSE_Value_SetNull(FXJSE_HVALUE hValue); diff --git a/xfa/fxjse/util_inline.h b/xfa/fxjse/util_inline.h index 336886b666..e61dc6aa80 100644 --- a/xfa/fxjse/util_inline.h +++ b/xfa/fxjse/util_inline.h @@ -20,7 +20,8 @@ static V8_INLINE void FXJSE_UpdateObjectBinding(v8::Local& hObject, hObject->SetAlignedPointerInInternalField(0, lpNewBinding); } static V8_INLINE void* FXJSE_RetrieveObjectBinding( - const v8::Local& hJSObject) { + const v8::Local& hJSObject, + CFXJSE_Class* lpClass = NULL) { ASSERT(!hJSObject.IsEmpty()); if (!hJSObject->IsObject()) { return NULL; @@ -36,6 +37,14 @@ static V8_INLINE void* FXJSE_RetrieveObjectBinding( return NULL; } } + if (lpClass) { + v8::Local hClass = + v8::Local::New( + lpClass->GetContext()->GetRuntime(), lpClass->GetTemplate()); + if (!hClass->HasInstance(hObject)) { + return NULL; + } + } return hObject->GetAlignedPointerFromInternalField(0); } diff --git a/xfa/fxjse/value.cpp b/xfa/fxjse/value.cpp index d3366cf08e..c23e12c32f 100644 --- a/xfa/fxjse/value.cpp +++ b/xfa/fxjse/value.cpp @@ -72,8 +72,9 @@ int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue) { return reinterpret_cast(hValue)->ToInteger(); } -void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue) { - return reinterpret_cast(hValue)->ToObject(); +void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue, FXJSE_HCLASS hClass) { + CFXJSE_Class* lpClass = reinterpret_cast(hClass); + return reinterpret_cast(hValue)->ToObject(lpClass); } void FXJSE_Value_SetUndefined(FXJSE_HVALUE hValue) { @@ -237,7 +238,7 @@ CFXJSE_Value* CFXJSE_Value::Create(v8::Isolate* pIsolate) { return new CFXJSE_Value(pIsolate); } -void* CFXJSE_Value::ToObject() const { +void* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const { ASSERT(!m_hValue.IsEmpty()); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); @@ -247,7 +248,7 @@ void* CFXJSE_Value::ToObject() const { if (!hValue->IsObject()) return nullptr; - return FXJSE_RetrieveObjectBinding(hValue.As()); + return FXJSE_RetrieveObjectBinding(hValue.As(), lpClass); } V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) { diff --git a/xfa/fxjse/value.h b/xfa/fxjse/value.h index 12db5883cf..2939ac34f7 100644 --- a/xfa/fxjse/value.h +++ b/xfa/fxjse/value.h @@ -148,7 +148,7 @@ class CFXJSE_Value { v8::String::Utf8Value hStringVal(hString); szStrOutput = *hStringVal; } - void* ToObject() const; + void* ToObject(CFXJSE_Class* lpClass) const; public: V8_INLINE void SetUndefined() { -- cgit v1.2.3