summaryrefslogtreecommitdiff
path: root/fxjs/cfxjse_engine.cpp
AgeCommit message (Collapse)Author
2018-10-18One more round of IWYU in fxjs/.Lei Zhang
Also get rid of CFXJSE_FormCalcContext::m_pFMClass, which mostly goes unused. Change-Id: Idad72afaf5796e6174a5f23ad0460a8e0a93f9ab Reviewed-on: https://pdfium-review.googlesource.com/c/44273 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-18Forward declare some fxjs/ classes.Lei Zhang
And remove unnecessary fxjs/ #includes in header files. Change-Id: If89dd2717b6ba93dbb7493e8ca80d78deaa64b06 Reviewed-on: https://pdfium-review.googlesource.com/c/44270 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-12Do IWYU in xfa.Lei Zhang
Change-Id: Ia104471caffe79f92d439920baeea37a71c71c50 Reviewed-on: https://pdfium-review.googlesource.com/c/43971 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-31Use more UnownedPtrs in CFXJSE_Engine.Lei Zhang
Change-Id: If577500905f5bc5bb631718e9c87aa03ee6bee5a Reviewed-on: https://pdfium-review.googlesource.com/41571 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-29Reduce the number of CFXJSE_ResolveProcessor::GetNodeHelper() calls.Lei Zhang
In CFXJSE_Engine::ResolveObjects(), all the calls are to the same object. Just grab a pointer and reuse that. Also make GetNodeHelper() non-const. Change-Id: I92a0bb1577a11d4d067e6d9beed27fcadeb694dc Reviewed-on: https://pdfium-review.googlesource.com/41573 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-28Stop using deprecated v8::ObjectTemplate::NewInstance().Lei Zhang
Fix nits in affected files. Change-Id: I3a0363c9b7c28359fd1c7cea305e4f7705a228c2 Reviewed-on: https://pdfium-review.googlesource.com/41355 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-28Initialize some CFXJSE_Engine members in the header.Lei Zhang
Change-Id: I6fd6004cb6c2e5a801fce0fbb43a6f7d65f560dd Reviewed-on: https://pdfium-review.googlesource.com/41354 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-23Fix shadowed variablesRyan Harrison
This CL fixes instances of variable shadowing that are discovered by turning on -Wshadow. BUG=pdfium:1137 Change-Id: I418d50de89ecbeb12e85b23a358bc61e8f16e888 Reviewed-on: https://pdfium-review.googlesource.com/41150 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-21Use UnownedPtr<> in xfa_resolvenode_rs.hTom Sepez
Change-Id: I4420fbf7402a8b08e33ca525e98690643d59efdf Reviewed-on: https://pdfium-review.googlesource.com/40930 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-17Rename CJS_Return to CJS_Result.Tom Sepez
"Return" is a verb, and "return" is a reserved-word at that, so avoid using it as part of a class name. Fully mechanical change apart from rename. Change-Id: I120e453e8ba001c4ab74a39e2da6aa6eb590835f Reviewed-on: https://pdfium-review.googlesource.com/40532 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-17Introduce safer CJS_Return::Success() and Failure().Tom Sepez
Avoid the possibility of ever re-introducing the issue noticed last week. Remove some redundant JSGetStringFromID() calls. Change-Id: I56687c2191bd72e378f747083f34080e50cbe490 Reviewed-on: https://pdfium-review.googlesource.com/40490 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-16Remove optional argument from ResolveNodes_GetParent().Tom Sepez
Conformity with standards. Change-Id: Ia718700526477fd1826eb4900ab333ebf4c8a517 Reviewed-on: https://pdfium-review.googlesource.com/40353 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-14Remove optional argument from GetVariablesThis().Tom Sepez
Change-Id: Ie0e8e83e0380c323d8d12e82e50126b85d34405c Reviewed-on: https://pdfium-review.googlesource.com/40191 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Remove more default arg = nullptr cases.Tom Sepez
Bring in line with standards. Remove argument entirely for mac code that is always nullptr. Change-Id: I0710bdbd51fc0bc2e1d428ef44976be39a631147 Reviewed-on: https://pdfium-review.googlesource.com/40091 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-27Tag XFA data bound to V8 Objects.Tom Sepez
Because we don't want to trust anything V8 gives us back. Use a deep namespace so we can have a short declaration in the structs, but avoid collisions. Change-Id: Ibb832a5dcd34c652159c3343dd70c9e2ee561537 Reviewed-on: https://pdfium-review.googlesource.com/38972 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-25Move CXFA_ThisProxy helper to CXFA_Object.Tom Sepez
Because the other helpers are declared here. Rename VariablesThis to ThisProxy in a few places; VariablesThis is a slightly different concept (see GetVariablesThis()). Then introduce helper for CXFA_List subclass as well. Remove unused const version of some helpers. Change-Id: Ia328d8cd170a8b97015e98c1c770fa8a44810455 Reviewed-on: https://pdfium-review.googlesource.com/38670 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-24Remove lpClass argument from FXJSE_RetrieveObjectBinding()Tom Sepez
In turn, it too is always nullptr. This shows that the V8 side check for hasInstance() was never being applied. We will augment this with C++ side checks down the road, since we don't want to trust V8 anyways. Change-Id: Iee38f32af9561783dbf253d798bd975029f3a4a2 Reviewed-on: https://pdfium-review.googlesource.com/38594 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-23Tighten up ThisProxy casts.Tom Sepez
Previous CLs have shown that the "lpClass" checks aren't sufficient here, so ensure we are always checking C++ enum value before downcasting this type. Change-Id: I418127c5e7131e0a3363363a60d1976719d6837c Reviewed-on: https://pdfium-review.googlesource.com/38550 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-23Remove argument from CFXJSE_Value::ToHostObject()Tom Sepez
Like the other cases, it is always nullptr. Change-Id: I280f25899ffbe5e35f4ef3342aec7896edf3e1f2 Reviewed-on: https://pdfium-review.googlesource.com/38592 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-23Remove second argument to CFXJSE_Engine::ToObject()Tom Sepez
It, too, is always passed as nullptr. Change-Id: I2573bea4cc33f48c13979026ea8ae42b368ce8a5 Reviewed-on: https://pdfium-review.googlesource.com/38590 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-23Replace CFXJSE_HostObject::type_ with polymorphic conversion methodsTom Sepez
More foolproof technique, and saves one word in every instance at a cost of two pointers in every subclass vtable. Change-Id: Ied4f91d4d203b5e6d83abe751159eb7e55489bb5 Reviewed-on: https://pdfium-review.googlesource.com/38530 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-03Use unowned ptr to Node from outside XFA node tree.chromium/3481Tom Sepez
Change-Id: Idcd992224fc5411c97f3001293af83a6c581e695 Reviewed-on: https://pdfium-review.googlesource.com/36991 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-08Ensure CJS_Return() with error always includes a message.Tom Sepez
Change the signature of the constructors to make it impossible to do this otherwise. Change-Id: I14e88d98a1128f2d599459ce9337cd6d079469fe Reviewed-on: https://pdfium-review.googlesource.com/34531 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-07Remove v8::Context slot usage entierly from fxjsTom Sepez
Its no longer required. Change-Id: I180ca99817352a91b6d9d7c9b45985cd96dc730e Reviewed-on: https://pdfium-review.googlesource.com/34290 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-05Introduce IJS_Runtime::ScopedEventContext helper class.chromium/3451Tom Sepez
This proves that m_EventContextArray is, in fact, a stack. Tidy one function by using AutoRestorer while at it. Change-Id: I319538b4eadcd9ce83319aa73861635dd5eb8c36 Reviewed-on: https://pdfium-review.googlesource.com/33970 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-05[xfa] Make the event context available when calling back in XFADan Sinclair
When calling into the XFA JS engine with a request for a non-XFA JS call which accesses the EventContext we would get a crash in XFA as we never set the context. This CL changes the XFA code to accept the CJS_Runtime instead of the CFXJS_Engine and then calls NewEventContext before executing JS scripts. This will correctly setup the event context as needed for any JS callbacks. Bug: pdfium:1003 Change-Id: Icf202252b2e6e56afdf0d1766a32a893935a2fd3 Reviewed-on: https://pdfium-review.googlesource.com/33930 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-04[xfa] Get properties from the non-xfa global if possibleDan Sinclair
When script variables are used the methods are set on the non-xfa global object. This CL updates the NormalPropertyGetter to check the non-xfa global object for methods which allows the variables methods to be found. Bug: pdfium:1097 Change-Id: I13d9d49ad654cad776883aef74de6250de5e756b Reviewed-on: https://pdfium-review.googlesource.com/33433 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-31Make FXJSE variable context compatible with FXJS.Tom Sepez
Allows FXJS to be entered directly from V8 when the variable context gets a reference to an FXJS object. Bug: pdfium:1066 Change-Id: I48e39ed9104cc6df31c19d94fa7e0f8c7760932f Reviewed-on: https://pdfium-review.googlesource.com/33450 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-25[xfa] Allow accessing the event changed parameter from JS.Dan Sinclair
This CL updates the CFXJSE_Engine code to access the defined properties of a class if we fail to find the property in any other way. This fixes up an issue where we were unable to read the 'change' property of the CJX_EventPseudoModel because we could not find the 'change' property. Bug: 1066 Change-Id: I4ad205bc527beeca1c3e24a36cdde0c21287d9fb Reviewed-on: https://pdfium-review.googlesource.com/32930 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-05Make Internal field usage in cfxjs_engine match README.docTom Sepez
As it turns out, this doesn't cause any bugs with the FXJS/FXJSE interaction since the magic values will never be present in the other slot, but the code looks wrong wrt. the document. Also fix an assert in FXJSE that our objects have two slots, and null appropriately (just a defensive measure). Also assert that one of our casts is valid. Change-Id: I3146fe58350da5e9b76e711d81480565dabd587f Reviewed-on: https://pdfium-review.googlesource.com/29859 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-03-27Remove CXFA_FFNotify proxy methodsDan Sinclair
This CL removes proxy methods from CXFA_FFNotify and calls them directly. Change-Id: I1fecc625e0b81b659baeffc9ca567c5c20e12c23 Reviewed-on: https://pdfium-review.googlesource.com/29252 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-02-26Get rid of some static variables.Tom Sepez
These are generally cheap enough to compute as needed, rather than keeping around in memory all the time (plus the memory for the static flag the compiler generates to check if initialized). Change-Id: If3a5365521f6a7781e66fb11f04883a5c673ee11 Reviewed-on: https://pdfium-review.googlesource.com/27150 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-02-09Rename fxjs_v8.{h,cpp} to cfxjs_engine.{h,cpp}Tom Sepez
Place the template map definitions entirely in .cpp file. Change-Id: I2643f1b99f5582b69aa985857c4aa6f9b5ab57c8 Reviewed-on: https://pdfium-review.googlesource.com/26150 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-02-08Move cjs_v8.cpp to cfx_v8.cppTom Sepez
The layering should be CJS => CFXJS => CFX_V8 with the CJS name being higher up. Change-Id: Ic130f248906e9c4df641dd508389b0555786b999 Reviewed-on: https://pdfium-review.googlesource.com/26051 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-02-08Move XFA-specific methods out of CJS_V8.Tom Sepez
These belong more properly in CFXJS_Engine, and a small amount of casting is required to get to the sub-class. Change-Id: Id954d182b7a7d51fe0a522c04a50a1b362746c72 Reviewed-on: https://pdfium-review.googlesource.com/26050 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-02-02Make global object function names clearer.Tom Sepez
Also tidy some sub-expressions. Change-Id: Ieabd5f6cea60e8ec03c8ce5ebe372fc80b05a7bb Reviewed-on: https://pdfium-review.googlesource.com/25150 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-02-01Make CFXJSE-created contexts refer to their CFXJS counteparts.chromium/3337Tom Sepez
Bug: 773229 Change-Id: Ic3774c7f6abe3a195bbe09b91d91c549d4d7ac46 Reviewed-on: https://pdfium-review.googlesource.com/25110 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-02-01Make FXJSE_Engine constructed from FXJS_Engine.Tom Sepez
No change in functionality yet, just passing higher level object. Precursor to maybe sharing v8 context between fxjs / fxjse. Mark unimplemented ctors / assignment operator as "delete". Change-Id: I100de7755909eec2eed96f6f51216d85923ffbb2 Reviewed-on: https://pdfium-review.googlesource.com/25050 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-01-10Remove CXFA_Node::GetNodeItemDan Sinclair
This CL removes the generic CXFA_Node::GetNodeItem(type) method for specific calls to get the parent, child or siblings. Change-Id: Ief68284ac7b954aaa4ed7120dd82a39f8b52656a Reviewed-on: https://pdfium-review.googlesource.com/22650 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-01-10Make methods which create nodes more obviousDan Sinclair
This CL converts the various methods Get methods which take a boolean value to explicit Get* and GetOrCreate* methods to make the usage clearer. Change-Id: I2af68448b1b69b95713e739bf7fe14a4336d2b65 Reviewed-on: https://pdfium-review.googlesource.com/22590 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-01-05Convert GetSOMExpression methods to return WideStringRyan Harrison
Change-Id: I34eb40ff1c14e7b9362d4e52166243eacc6710da Reviewed-on: https://pdfium-review.googlesource.com/22270 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-01-05Convert CXFA_NodeHelper::GetNameExpression to return WideStringRyan Harrison
Change-Id: Id762e195632a691c392873113f01852686bbb55f Reviewed-on: https://pdfium-review.googlesource.com/22262 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-01-04Convert usages of pdfium::Optional to OptionalRyan Harrison
Change-Id: I29769f78eaad10c6a8b79e27524336c4f330377e Reviewed-on: https://pdfium-review.googlesource.com/22258 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-12-14Add type information to CJX_Object::GetPropertyDan Sinclair
This CL adds a type template to the CJX_Object::GetProperty method so we can have the correct types returned. Change-Id: Ieda8ec4bd31d26a1e71af30f08b48eb826f5993d Reviewed-on: https://pdfium-review.googlesource.com/21250 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-12-14Fold CXFA_ScriptData into CXFA_ScriptDan Sinclair
This CL removes the CXFA_ScriptData wrapper and uses CXFA_Script directly. Change-Id: I1f1932ef96ee4a24407de7eb1d68b8631a5a67ea Reviewed-on: https://pdfium-review.googlesource.com/21173 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-12-13Methods are on CJX_Object not CJX_Node nowDan Sinclair
This CL converts all of the JSNode() to JSObject() calls as all of the original CJX_Node methods have been moved to CJX_Object. This fixes potential bad casts from things like CJX_Content which do not inhert from CJX_Node. Bug: pdfium:793372 Change-Id: I6c7f63a78f3d47bb6bad74faed3fd8c535bf095e Reviewed-on: https://pdfium-review.googlesource.com/21090 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-12-11[xfa] Refactor CJX method signatures.Dan Sinclair
This CL changes the CJX methods from void (*)(CFXJSE_Arguments*) to CJS_Return (*)(CJS_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) which is closer to how CJS works in practice. Change-Id: I3a3129268acfe4262dfeb04179919ed19f6c24e1 Reviewed-on: https://pdfium-review.googlesource.com/20491 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-12-07[xfa] Move JS method information to files.chromium/3288Dan Sinclair
This CL moves the XFA SOM JS Method information out of the c-array and into individual CJX class files. Change-Id: I401046a06aacaf1f04e5a51eb899e479de012e15 Reviewed-on: https://pdfium-review.googlesource.com/20450 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-12-04Remove SetResultCreateNodeDan Sinclair
This CL removes the SetResultCreateNode method and inlines into the one caller. The XFA_RESOLVENODE_RSTYPE enum is also renamed XFA_ResolveNode_RSType to make it easier to find XFA_RESOLVENODE_RS objects. Change-Id: I937b612be062c5b7b05fd8d2822cd12cb882ba06 Reviewed-on: https://pdfium-review.googlesource.com/20370 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-12-04Cleanup ResolveObjects params and returnDan Sinclair
The return value of ResolveObjects is always used as a boolean, so change from int32_t. The XFA_RESOLVENODE_RS object was made a pointer from a ref. Change-Id: I030036c01101680e36f4ddf524b468354a2e6850 Reviewed-on: https://pdfium-review.googlesource.com/20331 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>