Remove templates from JSSpecialProp methods.

They are only ever instantiated against class CJS_Global, so they
can be vastly simplified.

-- Add comments in header because the name "global" is confusing.

Change-Id: Ib38e7ebb9abc57e3361b2619836edb5c0618c849
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/66150
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 8ac3181..e5df506 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -29,11 +29,10 @@
   return WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
 }
 
-template <class Alt>
 void JSSpecialPropQuery(const char*,
                         v8::Local<v8::String> property,
                         const v8::PropertyCallbackInfo<v8::Integer>& info) {
-  auto pObj = JSGetObject<Alt>(info.Holder());
+  auto pObj = JSGetObject<CJS_Global>(info.Holder());
   if (!pObj)
     return;
 
@@ -47,11 +46,10 @@
   info.GetReturnValue().Set(!result.HasError() ? 4 : 0);
 }
 
-template <class Alt>
 void JSSpecialPropGet(const char* class_name,
                       v8::Local<v8::String> property,
                       const v8::PropertyCallbackInfo<v8::Value>& info) {
-  auto pObj = JSGetObject<Alt>(info.Holder());
+  auto pObj = JSGetObject<CJS_Global>(info.Holder());
   if (!pObj)
     return;
 
@@ -71,12 +69,11 @@
     info.GetReturnValue().Set(result.Return());
 }
 
-template <class Alt>
 void JSSpecialPropPut(const char* class_name,
                       v8::Local<v8::String> property,
                       v8::Local<v8::Value> value,
                       const v8::PropertyCallbackInfo<v8::Value>& info) {
-  auto pObj = JSGetObject<Alt>(info.Holder());
+  auto pObj = JSGetObject<CJS_Global>(info.Holder());
   if (!pObj)
     return;
 
@@ -93,11 +90,10 @@
   }
 }
 
-template <class Alt>
 void JSSpecialPropDel(const char* class_name,
                       v8::Local<v8::String> property,
                       const v8::PropertyCallbackInfo<v8::Boolean>& info) {
-  auto pObj = JSGetObject<Alt>(info.Holder());
+  auto pObj = JSGetObject<CJS_Global>(info.Holder());
   if (!pObj)
     return;
 
@@ -114,7 +110,7 @@
   }
 }
 
-template <class T>
+template <typename T>
 v8::Local<v8::String> GetV8StringFromProperty(v8::Local<v8::Name> property,
                                               const T& info) {
   return property->ToString(info.GetIsolate()->GetCurrentContext())
@@ -144,7 +140,7 @@
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Integer>& info) {
   ASSERT(property->IsString());
-  JSSpecialPropQuery<CJS_Global>(
+  JSSpecialPropQuery(
       "global",
       v8::Local<v8::String>::New(info.GetIsolate(),
                                  GetV8StringFromProperty(property, info)),
@@ -156,7 +152,7 @@
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Value>& info) {
   ASSERT(property->IsString());
-  JSSpecialPropGet<CJS_Global>(
+  JSSpecialPropGet(
       "global",
       v8::Local<v8::String>::New(info.GetIsolate(),
                                  GetV8StringFromProperty(property, info)),
@@ -169,7 +165,7 @@
     v8::Local<v8::Value> value,
     const v8::PropertyCallbackInfo<v8::Value>& info) {
   ASSERT(property->IsString());
-  JSSpecialPropPut<CJS_Global>(
+  JSSpecialPropPut(
       "global",
       v8::Local<v8::String>::New(info.GetIsolate(),
                                  GetV8StringFromProperty(property, info)),
@@ -181,7 +177,7 @@
     v8::Local<v8::Name> property,
     const v8::PropertyCallbackInfo<v8::Boolean>& info) {
   ASSERT(property->IsString());
-  JSSpecialPropDel<CJS_Global>(
+  JSSpecialPropDel(
       "global",
       v8::Local<v8::String>::New(info.GetIsolate(),
                                  GetV8StringFromProperty(property, info)),
diff --git a/fxjs/cjs_global.h b/fxjs/cjs_global.h
index 2c89188..893a69e 100644
--- a/fxjs/cjs_global.h
+++ b/fxjs/cjs_global.h
@@ -17,6 +17,16 @@
 
 class CFX_GlobalData;
 
+// The CJS_Global object is not the V8 global object (i.e. it is not |this|
+// in JavaScript outside of a bound function call). It is a facility for
+// sharing data amongst documents and persisting data within a document
+// between sessions. It is only partially implemented due to security and
+// privacy concerns. It provides access via properties in the usual manner,
+// execpt that these are stored on the C++ side rather than in V8 itself.
+// It is a static object that is available as "global" property of the V8
+// global object and can be manipulated from JavaScript as |global['foo']|
+// for example.
+
 class CJS_Global final : public CJS_Object {
  public:
   static int GetObjDefnID();