From f79a69c2513a9ee1431bd36c340e4b66bc2fd2d8 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 30 Oct 2014 13:23:42 -0700 Subject: For v8 Global Object, do not copy in CJS_Value constructor. BUG=425129 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/688303003 --- fpdfsdk/include/javascript/JS_Value.h | 30 +++++++++++++++--------------- fpdfsdk/src/javascript/JS_Value.cpp | 10 +++++++++- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/fpdfsdk/include/javascript/JS_Value.h b/fpdfsdk/include/javascript/JS_Value.h index 030cdd5cf9..e9faf32370 100644 --- a/fpdfsdk/include/javascript/JS_Value.h +++ b/fpdfsdk/include/javascript/JS_Value.h @@ -9,6 +9,8 @@ class CJS_Array; class CJS_Date; +class CJS_Document; +class CJS_Object; class CJS_Value { @@ -17,14 +19,15 @@ public: CJS_Value(v8::Isolate* isolate, v8::Handle pValue,FXJSVALUETYPE t); CJS_Value(v8::Isolate* isolate, const int &iValue); CJS_Value(v8::Isolate* isolate, const double &dValue); - CJS_Value(v8::Isolate* isolate, const float &fValue); + CJS_Value(v8::Isolate* isolate, const float &fValue); CJS_Value(v8::Isolate* isolate, const bool &bValue); CJS_Value(v8::Isolate* isolate, JSFXObject); - CJS_Value(v8::Isolate* isolate, CJS_Object *); + CJS_Value(v8::Isolate* isolate, CJS_Object*); + CJS_Value(v8::Isolate* isolate, CJS_Document*); CJS_Value(v8::Isolate* isolate, FX_LPCSTR pStr); CJS_Value(v8::Isolate* isolate, FX_LPCWSTR pWstr); CJS_Value(v8::Isolate* isolate, CJS_Array& array); - + ~CJS_Value(); void SetNull(); @@ -37,28 +40,25 @@ public: operator bool() const; operator double() const; operator float() const; - operator CJS_Object *() const; - //operator JSFXObject *() const; + operator CJS_Object*() const; operator v8::Handle() const; operator v8::Handle() const; operator CFX_WideString() const; - //operator FX_WCHAR *() const; operator CFX_ByteString() const; v8::Handle ToJSValue(); void operator = (int iValue); - void operator = (bool bValue); - void operator = (double); - void operator = (float); - void operator = (CJS_Object *); + void operator = (bool bValue); + void operator = (double); + void operator = (float); + void operator = (CJS_Object*); void operator = (v8::Handle); -// void operator = (JSObject *); void operator = (CJS_Array &); void operator = (CJS_Date &); - void operator = (FX_LPCWSTR pWstr); - void operator = (FX_LPCSTR pStr); + void operator = (FX_LPCWSTR pWstr); + void operator = (FX_LPCSTR pStr); void operator = (CJS_Value value); - + FX_BOOL IsArrayObject() const; FX_BOOL IsDateObject() const; FXJSVALUETYPE GetType() const; @@ -67,7 +67,7 @@ public: FX_BOOL ConvertToDate(CJS_Date &) const; v8::Isolate* GetIsolate() {return m_isolate;} -protected: +protected: v8::Handle m_pValue; FXJSVALUETYPE m_eType; v8::Isolate* m_isolate; diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp index 90b324ace2..93da9bea2e 100644 --- a/fpdfsdk/src/javascript/JS_Value.cpp +++ b/fpdfsdk/src/javascript/JS_Value.cpp @@ -8,6 +8,7 @@ #include "../../include/javascript/JS_Define.h" #include "../../include/javascript/JS_Object.h" #include "../../include/javascript/JS_Value.h" +#include "../../include/javascript/Document.h" /* ---------------------------- CJS_Value ---------------------------- */ @@ -44,11 +45,18 @@ CJS_Value::CJS_Value(v8::Isolate* isolate, JSFXObject pJsObj):m_isolate(isolate operator =(pJsObj); } -CJS_Value::CJS_Value(v8::Isolate* isolate, CJS_Object * pJsObj):m_isolate(isolate) +CJS_Value::CJS_Value(v8::Isolate* isolate, CJS_Object* pJsObj):m_isolate(isolate) { operator =(pJsObj); } +CJS_Value::CJS_Value(v8::Isolate* isolate, CJS_Document* pJsDoc):m_isolate(isolate) +{ + m_eType = VT_object; + if (pJsDoc) + m_pValue = (JSFXObject)*pJsDoc; +} + CJS_Value::CJS_Value(v8::Isolate* isolate, FX_LPCWSTR pWstr):m_isolate(isolate) { operator =(pWstr); -- cgit v1.2.3