summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript
AgeCommit message (Collapse)Author
2017-10-26Remove unneeded DefineJSObject paramDan Sinclair
The second parameter to DefineJSObject is always set the same for each object type. Remove and put the value directly into the DefineObj calls. Change-Id: If939c57fe6ea3b985ab2337eb30f472c668cdc42 Reviewed-on: https://pdfium-review.googlesource.com/16911 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-26Make spec arrays constDan Sinclair
This CL marks all of the Spec arrays as const. Change-Id: Ie36f670a4230fcac2cba5544b9c6e5179b0c7073 Reviewed-on: https://pdfium-review.googlesource.com/16951 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-26Cleanup statics in JS classesDan Sinclair
This CL removes the static object IDs from each of the CJS_Object subclasses and moves them to anonymous namespaces. The Spec arrays are moved to private members of the object classes. Change-Id: I5dcdb87ef57e4b374b5431580fb55cb75023f8fb Reviewed-on: https://pdfium-review.googlesource.com/16950 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Remove g_pClassNameDan Sinclair
This CL removes the g_pClassName static member and uses the string directly where needed. Change-Id: I47f61442ced2ee1d6a607fb1a7d9bcaf000b8ee2 Reviewed-on: https://pdfium-review.googlesource.com/16931 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-26Cleanup JS define methodsDan Sinclair
This CL moves DefineProps, DefineMethods and DefineConsts to the CJS_Object and removes from the subclasses. The JSConstructor and JSDestructor are moved to be templated static methods in JS_Defines. Change-Id: Ibe5ee063a32ae2332b8affc843d97ee6da21f4ee Reviewed-on: https://pdfium-review.googlesource.com/16930 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Remove methods for empty const/method/property arraysDan Sinclair
This CL cleans up the methods and arrays for constants, methods and property definitions which are empty. Change-Id: I4a4d85cc139075de77d84a40182bd00341c31818 Reviewed-on: https://pdfium-review.googlesource.com/16910 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Remove JS macrosDan Sinclair
This CL removes the JS macros and inlines the code directly into the requisite classes. Change-Id: I514ca025be42cd46b041b4af271f7b1d1067ab42 Reviewed-on: https://pdfium-review.googlesource.com/16890 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Remove CJS_ArrayDan Sinclair
This CL removes the CJS_Array wrapper and uses the v8 objects directly. Change-Id: I904f76e59e27d65db4b4d0bbd503fddb3e8cfc6f Reviewed-on: https://pdfium-review.googlesource.com/16830 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Rename JS_EventHandlerdan sinclair
This Renames JS_EventHandler to cjs_eventhandler to match the class name. Change-Id: I30c7c4b92051b6d960ac7d8d8620d981f84e2142 Reviewed-on: https://pdfium-review.googlesource.com/16871 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Move global.{h|cpp} to match classdan sinclair
This CL moves global.{h|cpp} to cjs_global.{h|cpp} to match the internal class name. Change-Id: I58a0dfcb36ee35320a0ad0d134a544e615dc93bf Reviewed-on: https://pdfium-review.googlesource.com/16870 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Rename Annot to cjs_annotdan sinclair
Thist CL renames Annot.{h|cpp} to cjs_annot.{h|cpp} to better match the primary class. Change-Id: I9c3e2fcbb149d97e90098018f42205568ef179b1 Reviewed-on: https://pdfium-review.googlesource.com/16851 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-26Split Consts into individual filesdan sinclair
This CL splits the individual CJS classes out of the Consts.{cpp|h} files into their own files. Change-Id: I4497ee2dcb46205c1dc3f521d44a9046a8d7f067 Reviewed-on: https://pdfium-review.googlesource.com/16850 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-25Remove unused CJS_Object methodsDan Sinclair
The methods are unused, Removed. Change-Id: Icce60103bf0cc9364f3d5cc7c3032e959b9ffa09 Reviewed-on: https://pdfium-review.googlesource.com/16831 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-25Remove CJS_DateDan Sinclair
This CL removes the CJS_Date class and uses the v8::Local<v8::Date> directly. Change-Id: I4a59b0076bc0e5dc3142b36bd7125115605d416f Reviewed-on: https://pdfium-review.googlesource.com/16811 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-25Remove methods from CJS_DateDan Sinclair
This CL converts CJS_Date to a thin wrapper around a v8::Local<v8::Date>. Change-Id: I1510ae5ff7757677e4fe18deac4593cc75493c1b Reviewed-on: https://pdfium-review.googlesource.com/16810 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-25Remove CJS_ValueDan Sinclair
Not used anywhere, Removed. Change-Id: Idbdbe36e34fe97deceeb68601b0ceee31f4fdc35 Reviewed-on: https://pdfium-review.googlesource.com/16770 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-25Refactor JS method parameters and return values.Dan Sinclair
This CL removes the out parameters from the JS methods and changes the return from a |bool| to a |CJS_Return| value. The return value holds the returned v8 object, error string and a status code. Change-Id: I82488ff0d916475d7e3c8e51ed868639806181c9 Reviewed-on: https://pdfium-review.googlesource.com/16751 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-25Only set return value if one provideddan sinclair
This CL updates the javascript methods to only set the return value if the v8::Local is not empty. Change-Id: I1e0cac2d024671c3e217cb1b2292c40ed62484a4 Reviewed-on: https://pdfium-review.googlesource.com/16731 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-25Make NewNull return an actual Nulldan sinclair
This CL updates the CFXJS_Engine::NewNull method to return a real v8::Null instead of an empty v8::Local. This also adds a NewUndefined and returns undefined in most of the places null was returned previously. Change-Id: If1a96bf253057892a3b709cbc72f8825c52503c3 Reviewed-on: https://pdfium-review.googlesource.com/16730 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-25Convert JS input params to v8::Local<v8::Value>>sdan sinclair
This CL converts the JS set_* methods and the JSMethod methods to accept v8::Local<v8::Value> objects instead of CJS_Value objects. Change-Id: I6de41305deff458eba515bdc3462522b502f74ad Reviewed-on: https://pdfium-review.googlesource.com/16670 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-24Move MaybeCoerceToNumber to CJS_RuntimeDan Sinclair
This CL moves MaybeCoerceToNumber from CJS_Value to CJS_Runtime. Change-Id: I22bb605045daa63f405ef256e4b8a5c7ffb78425 Reviewed-on: https://pdfium-review.googlesource.com/16617 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-24Remove IsArrayObject and IsDateObject methodsDan Sinclair
This CL removes the IsArrayObject and IsDateObject methods and asks the v8 objects directly. Change-Id: I4e2b957dbdfcddb426270f72666fce83854d92e0 Reviewed-on: https://pdfium-review.googlesource.com/16616 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-24Remove GetType from CJS_ValueDan Sinclair
This CL removes the GetType method from CJS_Value and, instead, retrieves the value from the v8 object directly. Change-Id: Ia8390f3ead163c09a39cae493e75fccdd41a0961 Reviewed-on: https://pdfium-review.googlesource.com/16615 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-24Remove the CJS_Value To* methods.Dan Sinclair
This CL removes all of the To* methods on the CJS classes except for ToV8Value. Change-Id: If01263c8cfa557ef7b00f573ddbf68b591d5ae9a Reviewed-on: https://pdfium-review.googlesource.com/16614 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-24Remove CJS_Value constructorsDan Sinclair
This CL removes most of the CJS_Value constructors and leaves the v8::Local<v8::Value> constructor as the only non-default construtor. Change-Id: Ie98260d10eff645d0ca688b353e7d40ba1aac157 Reviewed-on: https://pdfium-review.googlesource.com/16611 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-24Remove most CJS_Value Set methodsDan Sinclair
This CL removes all of the Set(*) methods from CJS_Value except for Set(v8::Local<v8::Value>). All uses of Set are changed to convert to a v8::Value before setting. Change-Id: I6e4d2cebec42fce5c039dc0a3abe46086cfdd34f Reviewed-on: https://pdfium-review.googlesource.com/16610 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-23Cleanup some javascript color codeDan Sinclair
This CL changes the color conversion methods to return their result instead of taking an out param. Change-Id: I19ca2b395145866533c7f93cbad80cdf4d7df05d Reviewed-on: https://pdfium-review.googlesource.com/16530 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-23Cleaning up JS macrosDan Sinclair
This Cl moves JS_Defines macros with only one usage to be inline. Moves macros to where they're used and expands as needed. Change-Id: I7296aa0b7a815ef8f2a80dd813e7466056fe37af Reviewed-on: https://pdfium-review.googlesource.com/16510 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-23Remove CJS_PropValueDan Sinclair
This CL removes the CJS_PropValue class and uses CJS_Value directly. The various Set methods have been moved to CJS_Value and the runtime provided as needed. Change-Id: Ib5d3b9efc9b6cf8182be8f19af98599379c3d7db Reviewed-on: https://pdfium-review.googlesource.com/16431 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-23Cleanup CJS_Valuechromium/3248Dan Sinclair
This CL removes unused methods; renames Attach to Set and generally cleans up the CJS_Value classes. Change-Id: I858082100908f3bc51f4b58c11ceda3357fadc70 Reviewed-on: https://pdfium-review.googlesource.com/16430 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-19Cleanup not supported Field codedan sinclair
This CL removes the methods in Field which are marked Not Supported. This also removes the setting of the delay flags for those fields as the delay will do nothing. Change-Id: I5b6fd9d48d89e1e9287ed0b1aea0a24abd22f45d Reviewed-on: https://pdfium-review.googlesource.com/16390 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-19Cleanup visiblity in Fielddan sinclair
This CL shuffles some methods around in the Field declaration and cleans up the visibility as needed. Change-Id: Icff3bd791d734c3baa69fd092a2f96058eaf62fd Reviewed-on: https://pdfium-review.googlesource.com/16370 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-10-19Refactoring JS Callbacks.dan sinclair
This CL updates the fpdfsdk/javascript callbacks to have explicit get/set methods instead of one method which worked differently depending on the mode. This allows better ownership of the passed in params, (get takes a * and set takes a const&). The Value object was changed to have To* and Set methods to make the code clearer compared to the operator<< and operator>> overloading. Bug: Change-Id: Id6ff20a4e3252adfd0a78b643e50b9f095085018 Reviewed-on: https://pdfium-review.googlesource.com/16330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-18Refactor HasXFAField into HasFormInfoRyan Harrison
The existing API is too restrictive for collection the metrics information that we want. Specifically it only tells us if there are XFA forms in the document, but not AcroForms. This refactoring makes the method more general, so that non-XFA information is provided also. This change in semantics of the return value required some changes at the call sites of the API. BUG=chromium:775519 Change-Id: Id421c66c09b47196c252c64cdc2c711ca1911de0 Reviewed-on: https://pdfium-review.googlesource.com/16210 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-10-17Convert XFA Doc Types to be more preciseRyan Harrison
The existing types are PDF, Dynamic & Static, which are poorly named since they don't really convey the fundamental differences between the types. "PDF" is confusing because PDFium only handles PDFs, and "Dynamic" & "Static" describe what a form may do, not how it is specified or some other fundamental difference. The terms "Dynamic" and "Static" were especially confusing, since XFAF documents must be static by definition, whereas full XFA documents can be either dynamic or static, depending on whether or not they change their layout. The types have been renamed to be clear that they are talking about the type of PDF document being described. "PDF" becomes "None", since this is used to indicate that there are no XFA forms in the document. "Dynamic" becomes "Full", since this indicates that the entire XFA spec is being used for the forms, specifically display layout is in the XML. "Static" has become "ForegroundOnly", since the form is specified using the XFAF (XFA Foreground) subset of the spec. The terms Full & Foreground come from the XFA spec. I would have preferred XFAF to have a different name, since it is the display/foreground layer that isn't XFA when using it. BUG=pdfium:917 Change-Id: I4335958c4a11d77d3bbe63b93602dd5bc14acb57 Reviewed-on: https://pdfium-review.googlesource.com/16010 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-10-16Convert CPVT_Color to CFX_ColorDan Sinclair
This CL converts the use of CPVT_Color to CFX_Color and removes the CPVT_Color class. Change-Id: I86a2d06524cd8f0fbce2335f0185426cc41dbe84 Reviewed-on: https://pdfium-review.googlesource.com/16030 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-10-05Add ObservedPtr to catch Widget being killed by JSRyan Harrison
Another case of a call causing JS to run, which can remove a widget that is called later. BUG=chromium:771979 Change-Id: I5f25a38097662b70cfb777f76f0e3d50e7c11b1b Reviewed-on: https://pdfium-review.googlesource.com/15610 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-27Remove FXSYS_strlen and FXSYS_wcslenchromium/3226Ryan Harrison
With the conversion of internal string sizes to size_t, these wrappers are no longer needed. Replacing them with strlen and wcslen respectively. BUG=pdfium:828 Change-Id: Ia087ca2ddaf688a57ec9bd9ddfb8533cbe41510d Reviewed-on: https://pdfium-review.googlesource.com/14890 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-27Remove FX_STRSIZE and replace with size_tRyan Harrison
BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-27Cleanup FX macrosDan Sinclair
This CL renames the FX_OS defines to have _OS_ in their names and drops the _DESKTOP suffix. The FXM defines have been changed to just FX. Change-Id: Iab172fba541713b5f6d14fb8098baf68e3364c74 Reviewed-on: https://pdfium-review.googlesource.com/14833 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_UnownedPtr to UnownedPtrDan Sinclair
This CL moves CFX_UnownedPtr to UnownedPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I6d1fa463f365e5cb3aafa8c8a7a5f7eff62ed8e0 Reviewed-on: https://pdfium-review.googlesource.com/14620 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_Observable to ObservableDan Sinclair
This CL renames CFX_Observable to Observable and moves into the fxcrt namespace. The test suite names were updated to ObservedPtr from fxcrt. Bug: pdfium:898 Change-Id: Ia507482bc0a1d6d8bbf12c0c55c4a88f6c8910e2 Reviewed-on: https://pdfium-review.googlesource.com/14615 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_AutoRestorer to fxcrt::AutoRestorerDan Sinclair
This CL renames CFX_AutoRestorer to just AutoRestorer and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: Id9f36df94e95f3b2a55054bc198ca1bfd249ee3d Reviewed-on: https://pdfium-review.googlesource.com/14450 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-01Prepare for converting FX_STRSIZE int->size_tRyan Harrison
When turning on this conversion a number of typing issues and other nits where found in the code base that can be merged in without actually changing the underlying type. Landing these changes before the type change CL, since there is a high likelihood that the type change will need to be rolled back, since it is high risk. BUG=pdfium:828 Change-Id: I587443d9090055963446485a1aacb8772eb5ca64 Reviewed-on: https://pdfium-review.googlesource.com/12810 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-09-01Adjust loops in preperation for FX_STRSIZE int->size_tRyan Harrison
Adjust loop conditions and behaviours in preperation for convering the underlying type of FX_STRSIZE to size_t. These changes are not dependent on the type switch occuring, so can be landed before hand. BUG=pdfium:828 Change-Id: I5f950c99c10e5ef0836959e3b1dd2e09f8f5afc0 Reviewed-on: https://pdfium-review.googlesource.com/12750 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-08-31Remove fx_basic.hDan Sinclair
This CL removes the fx_basic.h header and fixes up includes as needed. Change-Id: I49af32a8327bdbcda40c50a61ffbd75d06609040 Reviewed-on: https://pdfium-review.googlesource.com/12670 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-30Add truly const versions of CPDF_Document getters.Lei Zhang
Instead of only having CPDF_Dictionary* GetRoot() const, provide const CPDF_Dictionary* GetRoot() const and CPDF_Dictionary* GetRoot(). Do the same for GetInfo(). Change-Id: I6eae1208d38327fcdc7d0cd75069a01c95f4a92a Reviewed-on: https://pdfium-review.googlesource.com/11671 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-08-30Move CFX_BinaryBuf out of fx_basicDan Sinclair
This CL splits the CFX_BinaryBuf out of fx_basic into its own files. The various includes have been updated. Change-Id: I0fa616eeb4df6dd229c02dc3a0597b3dced59425 Reviewed-on: https://pdfium-review.googlesource.com/12412 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-08-30Split auto restorer from fx_basicDan Sinclair
This CL moves CFX_AutoRestorer into its own file, separate from fx_basic.h. Change-Id: I415cb9207416bd4744b8ac8e2d7466852db53f0a Reviewed-on: https://pdfium-review.googlesource.com/12390 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>