summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-14 23:40:10 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-14 23:40:10 +0000
commit55ccb526913debb3269a33792bbd61b05656ec46 (patch)
treea98152baf9d4a5dcf1c76ecaf53cbae35720d2b8 /fxjs
parent48d62c3a5f57eb3397a335bea4a5a30de2fcb955 (diff)
downloadpdfium-55ccb526913debb3269a33792bbd61b05656ec46.tar.xz
Remove optional argument from NewFXJSBoundObject().
Additionally, we have a pre-existing enum type that is more meaningful than just a boolean. Change-Id: Ie6ad13a3c9b22e34dedf7a5a9b5b9cc2a49b1f03 Reviewed-on: https://pdfium-review.googlesource.com/40190 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjs_engine.cpp6
-rw-r--r--fxjs/cfxjs_engine.h3
-rw-r--r--fxjs/cfxjs_engine_unittest.cpp6
-rw-r--r--fxjs/cjs_app.cpp8
-rw-r--r--fxjs/cjs_document.cpp24
-rw-r--r--fxjs/cjs_eventhandler.cpp16
-rw-r--r--fxjs/cjs_field.cpp8
7 files changed, 36 insertions, 35 deletions
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 8587b8af98..2a95e4c58d 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -467,7 +467,7 @@ void CFXJS_Engine::InitializeEngine() {
}
} else if (pObjDef->m_ObjType == FXJSOBJTYPE_STATIC) {
v8::Local<v8::String> pObjName = NewString(pObjDef->m_ObjName);
- v8::Local<v8::Object> obj = NewFXJSBoundObject(i, true);
+ v8::Local<v8::Object> obj = NewFXJSBoundObject(i, FXJSOBJTYPE_STATIC);
if (!obj.IsEmpty()) {
v8Context->Global()->Set(v8Context, pObjName, obj).FromJust();
m_StaticObjects[i] = v8::Global<v8::Object>(GetIsolate(), obj);
@@ -542,7 +542,7 @@ Optional<IJS_Runtime::JS_Error> CFXJS_Engine::Execute(
}
v8::Local<v8::Object> CFXJS_Engine::NewFXJSBoundObject(int nObjDefnID,
- bool bStatic) {
+ FXJSOBJTYPE type) {
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::Local<v8::Context> context = GetIsolate()->GetCurrentContext();
FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(GetIsolate());
@@ -562,7 +562,7 @@ v8::Local<v8::Object> CFXJS_Engine::NewFXJSBoundObject(int nObjDefnID,
if (pObjDef->m_pConstructor)
pObjDef->m_pConstructor(this, obj);
- if (!bStatic) {
+ if (type == FXJSOBJTYPE_DYNAMIC) {
auto* pIsolateData = FXJS_PerIsolateData::Get(GetIsolate());
if (pIsolateData->m_pDynamicObjsMap)
pIsolateData->m_pDynamicObjsMap->SetAndMakeWeak(pObjData, obj);
diff --git a/fxjs/cfxjs_engine.h b/fxjs/cfxjs_engine.h
index a940f3fc46..63c6732791 100644
--- a/fxjs/cfxjs_engine.h
+++ b/fxjs/cfxjs_engine.h
@@ -128,8 +128,7 @@ class CFXJS_Engine : public CFX_V8 {
Optional<IJS_Runtime::JS_Error> Execute(const WideString& script);
v8::Local<v8::Object> GetThisObj();
- v8::Local<v8::Object> NewFXJSBoundObject(int nObjDefnID,
- bool bStatic = false);
+ v8::Local<v8::Object> NewFXJSBoundObject(int nObjDefnID, FXJSOBJTYPE type);
void Error(const WideString& message);
v8::Local<v8::Context> GetV8Context() {
diff --git a/fxjs/cfxjs_engine_unittest.cpp b/fxjs/cfxjs_engine_unittest.cpp
index 64cd3a3e1e..0902fdbb0e 100644
--- a/fxjs/cfxjs_engine_unittest.cpp
+++ b/fxjs/cfxjs_engine_unittest.cpp
@@ -66,14 +66,16 @@ TEST_F(FXJSEngineUnitTest, GC) {
engine()->InitializeEngine();
v8::Context::Scope context_scope(engine()->GetV8Context());
- v8::Local<v8::Object> perm = engine()->NewFXJSBoundObject(0, false);
+ v8::Local<v8::Object> perm =
+ engine()->NewFXJSBoundObject(0, FXJSOBJTYPE_DYNAMIC);
EXPECT_FALSE(perm.IsEmpty());
EXPECT_TRUE(perm_created);
EXPECT_FALSE(perm_destroyed);
{
v8::HandleScope inner_handle_scope(isolate());
- v8::Local<v8::Object> temp = engine()->NewFXJSBoundObject(1, false);
+ v8::Local<v8::Object> temp =
+ engine()->NewFXJSBoundObject(1, FXJSOBJTYPE_DYNAMIC);
EXPECT_FALSE(temp.IsEmpty());
EXPECT_TRUE(temp_created);
EXPECT_FALSE(temp_destroyed);
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index 485184bfc4..7029ddaf26 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -327,8 +327,8 @@ CJS_Return CJS_App::setInterval(
GlobalTimer* pTimerRef = timerRef.get();
m_Timers.insert(std::move(timerRef));
- v8::Local<v8::Object> pRetObj =
- pRuntime->NewFXJSBoundObject(CJS_TimerObj::GetObjDefnID());
+ v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(
+ CJS_TimerObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pRetObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
@@ -356,8 +356,8 @@ CJS_Return CJS_App::setTimeOut(
GlobalTimer* pTimerRef = timerRef.get();
m_Timers.insert(std::move(timerRef));
- v8::Local<v8::Object> pRetObj =
- pRuntime->NewFXJSBoundObject(CJS_TimerObj::GetObjDefnID());
+ v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(
+ CJS_TimerObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pRetObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index fa9826d1ae..7e89e40230 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -247,8 +247,8 @@ CJS_Return CJS_Document::getField(
if (pPDFForm->CountFields(wideName) <= 0)
return CJS_Return(pRuntime->NewUndefined());
- v8::Local<v8::Object> pFieldObj =
- pRuntime->NewFXJSBoundObject(CJS_Field::GetObjDefnID());
+ v8::Local<v8::Object> pFieldObj = pRuntime->NewFXJSBoundObject(
+ CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pFieldObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
@@ -1012,8 +1012,8 @@ CJS_Return CJS_Document::getAnnot(
if (!pSDKBAAnnot)
return CJS_Return(JSMessage::kBadObjectError);
- v8::Local<v8::Object> pObj =
- pRuntime->NewFXJSBoundObject(CJS_Annot::GetObjDefnID());
+ v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
+ CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
@@ -1047,8 +1047,8 @@ CJS_Return CJS_Document::getAnnots(
if (!pSDKAnnotCur)
return CJS_Return(JSMessage::kBadObjectError);
- v8::Local<v8::Object> pObj =
- pRuntime->NewFXJSBoundObject(CJS_Annot::GetObjDefnID());
+ v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
+ CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
@@ -1119,8 +1119,8 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
v8::Local<v8::Array> Icons = pRuntime->NewArray();
int i = 0;
for (const auto& name : m_IconNames) {
- v8::Local<v8::Object> pObj =
- pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID());
+ v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
+ CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
@@ -1151,8 +1151,8 @@ CJS_Return CJS_Document::getIcon(
if (it == m_IconNames.end())
return CJS_Return(JSMessage::kBadObjectError);
- v8::Local<v8::Object> pObj =
- pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID());
+ v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
+ CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
@@ -1301,8 +1301,8 @@ CJS_Return CJS_Document::getPageNumWords(
CJS_Return CJS_Document::getPrintParams(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- v8::Local<v8::Object> pRetObj =
- pRuntime->NewFXJSBoundObject(CJS_PrintParamsObj::GetObjDefnID());
+ v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(
+ CJS_PrintParamsObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pRetObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(JSMessage::kNotSupportedError);
diff --git a/fxjs/cjs_eventhandler.cpp b/fxjs/cjs_eventhandler.cpp
index 884651a77b..1a4ffbbd01 100644
--- a/fxjs/cjs_eventhandler.cpp
+++ b/fxjs/cjs_eventhandler.cpp
@@ -576,13 +576,13 @@ bool CJS_EventHandler::Shift() const {
CJS_Field* CJS_EventHandler::Source() {
CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
- v8::Local<v8::Object> pDocObj =
- pRuntime->NewFXJSBoundObject(CJS_Document::GetObjDefnID());
+ v8::Local<v8::Object> pDocObj = pRuntime->NewFXJSBoundObject(
+ CJS_Document::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pDocObj.IsEmpty())
return nullptr;
- v8::Local<v8::Object> pFieldObj =
- pRuntime->NewFXJSBoundObject(CJS_Field::GetObjDefnID());
+ v8::Local<v8::Object> pFieldObj = pRuntime->NewFXJSBoundObject(
+ CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pFieldObj.IsEmpty())
return nullptr;
@@ -602,13 +602,13 @@ CJS_Field* CJS_EventHandler::Source() {
CJS_Field* CJS_EventHandler::Target_Field() {
CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
- v8::Local<v8::Object> pDocObj =
- pRuntime->NewFXJSBoundObject(CJS_Document::GetObjDefnID());
+ v8::Local<v8::Object> pDocObj = pRuntime->NewFXJSBoundObject(
+ CJS_Document::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pDocObj.IsEmpty())
return nullptr;
- v8::Local<v8::Object> pFieldObj =
- pRuntime->NewFXJSBoundObject(CJS_Field::GetObjDefnID());
+ v8::Local<v8::Object> pFieldObj = pRuntime->NewFXJSBoundObject(
+ CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pFieldObj.IsEmpty())
return nullptr;
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index cd97372ad0..45715e22a0 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -2274,8 +2274,8 @@ CJS_Return CJS_Field::buttonGetIcon(
if (!pFormControl)
return CJS_Return(JSMessage::kBadObjectError);
- v8::Local<v8::Object> pObj =
- pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID());
+ v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
+ CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);
@@ -2386,8 +2386,8 @@ CJS_Return CJS_Field::getArray(
v8::Local<v8::Array> FormFieldArray = pRuntime->NewArray();
int j = 0;
for (const auto& pStr : swSort) {
- v8::Local<v8::Object> pObj =
- pRuntime->NewFXJSBoundObject(CJS_Field::GetObjDefnID());
+ v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
+ CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
return CJS_Return(JSMessage::kBadObjectError);