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>
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 8587b8a..2a95e4c 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -467,7 +467,7 @@
       }
     } 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 @@
 }
 
 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 @@
   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 a940f3f..63c6732 100644
--- a/fxjs/cfxjs_engine.h
+++ b/fxjs/cfxjs_engine.h
@@ -128,8 +128,7 @@
   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 64cd3a3..0902fdb 100644
--- a/fxjs/cfxjs_engine_unittest.cpp
+++ b/fxjs/cfxjs_engine_unittest.cpp
@@ -66,14 +66,16 @@
   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 485184b..7029dda 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -327,8 +327,8 @@
   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 @@
   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 fa9826d..7e89e40 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -247,8 +247,8 @@
   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 @@
   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 @@
       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 @@
   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 @@
   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::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 884651a..1a4ffbb 100644
--- a/fxjs/cjs_eventhandler.cpp
+++ b/fxjs/cjs_eventhandler.cpp
@@ -576,13 +576,13 @@
 
 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::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 cd97372..45715e2 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -2274,8 +2274,8 @@
   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 @@
   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);