xref: /aosp_15_r20/external/pdfium/fxjs/README (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1*3ac0a46fSAndroid Build Coastguard WorkerThere are two separate wrappers for V8 here.  One is called FXJS, and
2*3ac0a46fSAndroid Build Coastguard Workerit is used by the non-XFA code.  The other is called FXJSE, and it is
3*3ac0a46fSAndroid Build Coastguard Workerused only by the XFA code.  Additionally FXJSE may request services
4*3ac0a46fSAndroid Build Coastguard Workerfrom FXJS to bridge the two.
5*3ac0a46fSAndroid Build Coastguard Worker
6*3ac0a46fSAndroid Build Coastguard WorkerBoth the FXJS and FXJSE binding code needs to be replaced by something
7*3ac0a46fSAndroid Build Coastguard Workersaner, perhaps Gin or perhaps some IDL. See
8*3ac0a46fSAndroid Build Coastguard Worker  https://bugs.chromium.org/p/pdfium/issues/detail?id=716
9*3ac0a46fSAndroid Build Coastguard Workerfor progress on the issue.
10*3ac0a46fSAndroid Build Coastguard Worker
11*3ac0a46fSAndroid Build Coastguard WorkerFXJS binds objects by sticking a pointer to a CFXJS_PerObjectData in
12*3ac0a46fSAndroid Build Coastguard Workerthe V8 object's internal slot.  FXJSE binds objects by sticking a
13*3ac0a46fSAndroid Build Coastguard Workerpointer to either an actual v8 function object or a CFXJSE_HostObject
14*3ac0a46fSAndroid Build Coastguard Workerin the V8 object's internal slot, depending upon whether the object
15*3ac0a46fSAndroid Build Coastguard Workerrepresents (in some notion) a "class" or an "instance". Also, V8 objects
16*3ac0a46fSAndroid Build Coastguard Workerbound in one library may unexpectedly arrive at the other given a script
17*3ac0a46fSAndroid Build Coastguard Workerthat's trying to mess with us.
18*3ac0a46fSAndroid Build Coastguard Worker
19*3ac0a46fSAndroid Build Coastguard WorkerTo distinguish these cases, we use two internal slots for all bound
20*3ac0a46fSAndroid Build Coastguard Workerobjects, regardless of the FXJS/FXJSE distinction.  Slot 0 is the
21*3ac0a46fSAndroid Build Coastguard Workertag and contains either:
22*3ac0a46fSAndroid Build Coastguard Worker  kPerObjectDataTag for FXJS objects, or
23*3ac0a46fSAndroid Build Coastguard Worker  kFXJSEHostObjectTag for FXJSE Host objects, or
24*3ac0a46fSAndroid Build Coastguard Worker  kFXJSEProxyObjectTag for a global proxy object under FXJSE, or
25*3ac0a46fSAndroid Build Coastguard Worker  One of 4 specific FXJSE_CLASS_DESCRIPTOR globals for FXJSE classes:
26*3ac0a46fSAndroid Build Coastguard Worker    kGlobalClassDescriptor
27*3ac0a46fSAndroid Build Coastguard Worker    kNormalClassDescriptor
28*3ac0a46fSAndroid Build Coastguard Worker    kVariablesClassDescriptor
29*3ac0a46fSAndroid Build Coastguard Worker    kFormCalcDescriptor
30*3ac0a46fSAndroid Build Coastguard Worker
31*3ac0a46fSAndroid Build Coastguard WorkerSlot 1's contents are determined by these tags:
32*3ac0a46fSAndroid Build Coastguard Worker  kPerObjectDataTag means an aligned pointer to CFXJS_PerObjectData.
33*3ac0a46fSAndroid Build Coastguard Worker  kFXJSEHostObjectTag means an aligned pointer to CFXJSE_HostObject.
34*3ac0a46fSAndroid Build Coastguard Worker  kFXJSEProxyObjectTag means nullptr, and to check the prototype instead.
35*3ac0a46fSAndroid Build Coastguard Worker  A FXJSE_CLASS_DESCRIPTOR pointer means to expect an actual v8 function
36*3ac0a46fSAndroid Build Coastguard Worker  object (or a string naming that function), and not an aligned pointer.
37*3ac0a46fSAndroid Build Coastguard Worker
38*3ac0a46fSAndroid Build Coastguard WorkerBecause PDFium uses V8 for various unrelated purposes, there may be up to
39*3ac0a46fSAndroid Build Coastguard Workerfour v8::Contexts (JS Global Objects) associated with each document. One is
40*3ac0a46fSAndroid Build Coastguard Workerused by FXJS and holds objects as described by the js_api_reference.pdf
41*3ac0a46fSAndroid Build Coastguard Workerspecification. The others are used by FXJSE.
42