Use the new v8 interceptor API

The original v8 interceptor API has been deprecated. Update the code to
use the new API.

Change-Id: Icf5a2f2f4bd045d48c8a2143e2cdaa14964d27e0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117936
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 03d41f4..13ce5c9 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -212,12 +212,11 @@
     GetInstanceTemplate()->Set(sMethodName, fun, v8::ReadOnly);
   }
 
-  void DefineAllProperties(
-      v8::GenericNamedPropertyQueryCallback pPropQurey,
-      v8::GenericNamedPropertyGetterCallback pPropGet,
-      v8::GenericNamedPropertySetterCallback pPropPut,
-      v8::GenericNamedPropertyDeleterCallback pPropDel,
-      v8::GenericNamedPropertyEnumeratorCallback pPropEnum) {
+  void DefineAllProperties(v8::NamedPropertyQueryCallback pPropQurey,
+                           v8::NamedPropertyGetterCallback pPropGet,
+                           v8::NamedPropertySetterCallback pPropPut,
+                           v8::NamedPropertyDeleterCallback pPropDel,
+                           v8::NamedPropertyEnumeratorCallback pPropEnum) {
     GetInstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration(
         pPropGet, pPropPut, pPropQurey, pPropDel, pPropEnum,
         v8::Local<v8::Value>(),
@@ -446,11 +445,11 @@
 
 void CFXJS_Engine::DefineObjAllProperties(
     uint32_t nObjDefnID,
-    v8::GenericNamedPropertyQueryCallback pPropQurey,
-    v8::GenericNamedPropertyGetterCallback pPropGet,
-    v8::GenericNamedPropertySetterCallback pPropPut,
-    v8::GenericNamedPropertyDeleterCallback pPropDel,
-    v8::GenericNamedPropertyEnumeratorCallback pPropEnum) {
+    v8::NamedPropertyQueryCallback pPropQurey,
+    v8::NamedPropertyGetterCallback pPropGet,
+    v8::NamedPropertySetterCallback pPropPut,
+    v8::NamedPropertyDeleterCallback pPropDel,
+    v8::NamedPropertyEnumeratorCallback pPropEnum) {
   v8::Isolate::Scope isolate_scope(GetIsolate());
   v8::HandleScope handle_scope(GetIsolate());
   FXJS_PerIsolateData* pIsolateData = FXJS_PerIsolateData::Get(GetIsolate());
diff --git a/fxjs/cfxjs_engine.h b/fxjs/cfxjs_engine.h
index 55ca561..d491686 100644
--- a/fxjs/cfxjs_engine.h
+++ b/fxjs/cfxjs_engine.h
@@ -110,13 +110,12 @@
                          const char* sPropName,
                          v8::AccessorNameGetterCallback pPropGet,
                          v8::AccessorNameSetterCallback pPropPut);
-  void DefineObjAllProperties(
-      uint32_t nObjDefnID,
-      v8::GenericNamedPropertyQueryCallback pPropQurey,
-      v8::GenericNamedPropertyGetterCallback pPropGet,
-      v8::GenericNamedPropertySetterCallback pPropPut,
-      v8::GenericNamedPropertyDeleterCallback pPropDel,
-      v8::GenericNamedPropertyEnumeratorCallback pPropEnum);
+  void DefineObjAllProperties(uint32_t nObjDefnID,
+                              v8::NamedPropertyQueryCallback pPropQurey,
+                              v8::NamedPropertyGetterCallback pPropGet,
+                              v8::NamedPropertySetterCallback pPropPut,
+                              v8::NamedPropertyDeleterCallback pPropDel,
+                              v8::NamedPropertyEnumeratorCallback pPropEnum);
   void DefineObjConst(uint32_t nObjDefnID,
                       const char* sConstName,
                       v8::Local<v8::Value> pDefault);
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index da99452..dd0e271 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -50,75 +50,95 @@
 }
 
 // static
-void CJS_Global::queryprop_static(
+v8::Intercepted CJS_Global::queryprop_static(
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Integer>& info) {
   auto pObj = JSGetObject<CJS_Global>(info.GetIsolate(), info.Holder());
-  if (!pObj)
-    return;
+  if (!pObj) {
+    return v8::Intercepted::kNo;
+  }
 
   ByteString bsProp = ByteStringFromV8Name(info.GetIsolate(), property);
-  if (pObj->HasProperty(bsProp))
-    info.GetReturnValue().Set(static_cast<int>(v8::PropertyAttribute::None));
+  if (!pObj->HasProperty(bsProp)) {
+    return v8::Intercepted::kNo;
+  }
+
+  info.GetReturnValue().Set(static_cast<int>(v8::PropertyAttribute::None));
+  return v8::Intercepted::kYes;
 }
 
 // static
-void CJS_Global::getprop_static(
+v8::Intercepted CJS_Global::getprop_static(
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Value>& info) {
   auto pObj = JSGetObject<CJS_Global>(info.GetIsolate(), info.Holder());
-  if (!pObj)
-    return;
+  if (!pObj) {
+    return v8::Intercepted::kNo;
+  }
 
   CJS_Runtime* pRuntime = pObj->GetRuntime();
-  if (!pRuntime)
-    return;
+  if (!pRuntime) {
+    return v8::Intercepted::kNo;
+  }
 
   ByteString bsProp = ByteStringFromV8Name(info.GetIsolate(), property);
   CJS_Result result = pObj->GetProperty(pRuntime, bsProp);
   if (result.HasError()) {
     pRuntime->Error(
         JSFormatErrorString("global", "GetProperty", result.Error()));
-    return;
+    return v8::Intercepted::kYes;
   }
-  if (result.HasReturn())
-    info.GetReturnValue().Set(result.Return());
+  if (!result.HasReturn()) {
+    return v8::Intercepted::kNo;
+  }
+
+  info.GetReturnValue().Set(result.Return());
+  return v8::Intercepted::kYes;
 }
 
 // static
-void CJS_Global::putprop_static(
+v8::Intercepted CJS_Global::putprop_static(
     v8::Local<v8::Name> property,
     v8::Local<v8::Value> value,
-    const v8::PropertyCallbackInfo<v8::Value>& info) {
+    const v8::PropertyCallbackInfo<void>& info) {
   auto pObj = JSGetObject<CJS_Global>(info.GetIsolate(), info.Holder());
-  if (!pObj)
-    return;
+  if (!pObj) {
+    return v8::Intercepted::kNo;
+  }
 
   CJS_Runtime* pRuntime = pObj->GetRuntime();
-  if (!pRuntime)
-    return;
+  if (!pRuntime) {
+    return v8::Intercepted::kNo;
+  }
 
   ByteString bsProp = ByteStringFromV8Name(info.GetIsolate(), property);
   CJS_Result result = pObj->SetProperty(pRuntime, bsProp, value);
   if (result.HasError()) {
     pRuntime->Error(
         JSFormatErrorString("global", "PutProperty", result.Error()));
-    return;
+    return v8::Intercepted::kYes;
   }
+
   info.GetReturnValue().Set(value);
+  return v8::Intercepted::kYes;
 }
 
 // static
-void CJS_Global::delprop_static(
+v8::Intercepted CJS_Global::delprop_static(
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Boolean>& info) {
   auto pObj = JSGetObject<CJS_Global>(info.GetIsolate(), info.Holder());
-  if (!pObj)
-    return;
+  if (!pObj) {
+    return v8::Intercepted::kNo;
+  }
 
   ByteString bsProp = ByteStringFromV8Name(info.GetIsolate(), property);
-  if (pObj->DelProperty(bsProp))
-    info.GetReturnValue().Set(true);
+  if (!pObj->DelProperty(bsProp)) {
+    return v8::Intercepted::kNo;
+  }
+
+  info.GetReturnValue().Set(true);
+  return v8::Intercepted::kYes;
 }
 
 void CJS_Global::enumprop_static(
diff --git a/fxjs/cjs_global.h b/fxjs/cjs_global.h
index c8c0907..2c53802 100644
--- a/fxjs/cjs_global.h
+++ b/fxjs/cjs_global.h
@@ -35,16 +35,19 @@
   static void DefineJSObjects(CFXJS_Engine* pEngine);
   static void DefineAllProperties(CFXJS_Engine* pEngine);
 
-  static void queryprop_static(
+  static v8::Intercepted queryprop_static(
       v8::Local<v8::Name> property,
       const v8::PropertyCallbackInfo<v8::Integer>& info);
-  static void getprop_static(v8::Local<v8::Name> property,
-                             const v8::PropertyCallbackInfo<v8::Value>& info);
-  static void putprop_static(v8::Local<v8::Name> property,
-                             v8::Local<v8::Value> value,
-                             const v8::PropertyCallbackInfo<v8::Value>& info);
-  static void delprop_static(v8::Local<v8::Name> property,
-                             const v8::PropertyCallbackInfo<v8::Boolean>& info);
+  static v8::Intercepted getprop_static(
+      v8::Local<v8::Name> property,
+      const v8::PropertyCallbackInfo<v8::Value>& info);
+  static v8::Intercepted putprop_static(
+      v8::Local<v8::Name> property,
+      v8::Local<v8::Value> value,
+      const v8::PropertyCallbackInfo<void>& info);
+  static v8::Intercepted delprop_static(
+      v8::Local<v8::Name> property,
+      const v8::PropertyCallbackInfo<v8::Boolean>& info);
   static void enumprop_static(const v8::PropertyCallbackInfo<v8::Array>& info);
 
   static void setPersistent_static(
diff --git a/fxjs/xfa/cfxjse_class.cpp b/fxjs/xfa/cfxjse_class.cpp
index ce1d465..64b1208 100644
--- a/fxjs/xfa/cfxjse_class.cpp
+++ b/fxjs/xfa/cfxjse_class.cpp
@@ -192,13 +192,14 @@
   return nPropType != FXJSE_ClassPropType::kNone;
 }
 
-void NamedPropertyQueryCallback(
+v8::Intercepted NamedPropertyQueryCallback(
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Integer>& info) {
   const FXJSE_CLASS_DESCRIPTOR* pClass =
       AsClassDescriptor(info.Data().As<v8::External>()->Value());
-  if (!pClass)
-    return;
+  if (!pClass) {
+    return v8::Intercepted::kNo;
+  }
 
   v8::HandleScope scope(info.GetIsolate());
   v8::String::Utf8Value szPropName(info.GetIsolate(), property);
@@ -206,35 +207,38 @@
   if (DynPropQueryAdapter(info.GetIsolate(), pClass, info.Holder(),
                           szFxPropName)) {
     info.GetReturnValue().Set(v8::DontDelete);
-    return;
+    return v8::Intercepted::kYes;
   }
-  const int32_t iV8Absent = 64;
-  info.GetReturnValue().Set(iV8Absent);
+
+  return v8::Intercepted::kNo;
 }
 
-void NamedPropertyGetterCallback(
+v8::Intercepted NamedPropertyGetterCallback(
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Value>& info) {
   const FXJSE_CLASS_DESCRIPTOR* pClass =
       AsClassDescriptor(info.Data().As<v8::External>()->Value());
-  if (!pClass)
-    return;
+  if (!pClass) {
+    return v8::Intercepted::kNo;
+  }
 
   v8::String::Utf8Value szPropName(info.GetIsolate(), property);
   ByteStringView szFxPropName(*szPropName, szPropName.length());
   std::unique_ptr<CFXJSE_Value> pNewValue = DynPropGetterAdapter(
       info.GetIsolate(), pClass, info.Holder(), szFxPropName);
   info.GetReturnValue().Set(pNewValue->DirectGetValue());
+  return v8::Intercepted::kYes;
 }
 
-void NamedPropertySetterCallback(
+v8::Intercepted NamedPropertySetterCallback(
     v8::Local<v8::Name> property,
     v8::Local<v8::Value> value,
-    const v8::PropertyCallbackInfo<v8::Value>& info) {
+    const v8::PropertyCallbackInfo<void>& info) {
   const FXJSE_CLASS_DESCRIPTOR* pClass =
       AsClassDescriptor(info.Data().As<v8::External>()->Value());
-  if (!pClass)
-    return;
+  if (!pClass) {
+    return v8::Intercepted::kNo;
+  }
 
   v8::String::Utf8Value szPropName(info.GetIsolate(), property);
   ByteStringView szFxPropName(*szPropName, szPropName.length());
@@ -242,6 +246,7 @@
   DynPropSetterAdapter(info.GetIsolate(), pClass, info.Holder(), szFxPropName,
                        pNewValue.get());
   info.GetReturnValue().Set(value);
+  return v8::Intercepted::kYes;
 }
 
 void NamedPropertyEnumeratorCallback(