summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript
AgeCommit message (Collapse)Author
2015-04-30Provide an array buffer allocator to V8.chromium/2395chromium/2394chromium/2393chromium/2392chromium/2391chromium/2390chromium/2389chromium/2388Tom Sepez
This allows PDFium to work with current V8, so unpin v8 in the pdfium DEPS file. (I also re-ordered one field in CJS_Runtime, just to put two bools together (may pack tighter), and to put all the v8 stuff together). BUG=pdfium:146 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1118043002
2015-04-27Reduce usage of operator LPCWSTR from CFX_WideString().Tom Sepez
This involves adding some explicit c_str() calls. Doing so flagged PDF_EncodeText() and FindOptionValue() as having suboptimal signatures, in that we are often throwing away a perfectly fine length and recomputing it. There are still some platform-specific code that needs the operator. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1101933003
2015-04-27Revert "Kill operator LPCWSTR from CFX_WideString()."Tom Sepez
This reverts commit 15a62973b9b89c3e229cc0ab501c45967f91b325. Reason for revert: broke build on windows, mac. I must have missed some platform-specific conversions. TBR=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1108883002
2015-04-27Kill operator LPCWSTR from CFX_WideString().Tom Sepez
This involves adding some explicit c_str() calls. Doing so flagged PDF_EncodeText() and FindOptionValue() as having suboptimal signatures, in that we are often throwing away a perfectly fine length and recomputing it. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1101933003
2015-04-23Remove unused nParamNum values from JS method tables.Tom Sepez
The code to validate the number of parameters happens inside each particular method, rather than prior to method dispatch. As such, there's no point in having this number take up space in the table. Add some test to cover at least some of the per-method validations, and update error messages to be more useful. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1084183008
2015-04-23Kill overloaded cast operators in CJS_Value.Tom Sepez
The red-flag here is the explicit invocation of things like params[1].operator CFX_WideString() rather than static_cast<CFX_WideString>(params[1]) to invoke the conversion. Turns out the above won't compile due to ambiguity given the number of implicit constructors for widestrings. CJS_Value has both constructors and assignment operators for the primitive types, which means that conversions can take place unexpectedly in both directions, a second red flag. We don't want the compiler invoking these at will since it may hide bugs. In fact, when they are removed, three such places were discovered. Also rename ToJSValue to ToV8Value to match the other ToV8xxxxx functions added. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1096813008
2015-04-06fix missing semicolonsJUN FANG
TBR=tsepez@chromium.org BUG=N/A Review URL: https://codereview.chromium.org/1068513002
2015-04-06Fix a fatal error due to cloning a global document objectJUN FANG
BUG=454595 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1053373002
2015-04-01doc.external - Check direction of property access before blindly getting.Tom Sepez
BUG=https://code.google.com/p/pdfium/issues/detail?id=137 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1039063002
2015-03-02Kill off JS_ErrorString type.Tom Sepez
This provides no benefit, and reduces transparency. Along the way: Kill off some unused/commented-out code. Return void where a bool return doesn't make sense. Remove a pointless template type. Remove now unused constants and types. R=thestig@chromium.org Review URL: https://codereview.chromium.org/971033002
2015-03-02Return error information from pdfium to JS.Tom Sepez
This implements the previously unimplemented JS_Error() function. Along the way: - fix some IWYU when the include order in global.cpp was perturbed. - remove some uses of JS_ErrorString, to increase transparency. - use vp.IsSetting() in place of !vp.IsGetting() for clarity. - specify an error string on several error return paths. - add an error string for writing readonly properties. - rename an error string constant to reflect the actual message. - replace calls to variadic Format() with a function doing string appends. - remove unused JS_GetClassName() R=thestig@chromium.org Review URL: https://codereview.chromium.org/963193003
2015-02-27Remove unused IDS_ constants from pdfium.Tom Sepez
Along the way, I noticed that one of these is used in a header file that isn't included anywhere and describes no actual code (JS_Console.h). Also add missing header guards, and IWYU to resources.h Also move a static function from a header to the new resources.cpp file. Also fix the grammar on some of the error messages. Most of these appear to be JS error messages destined for a JS error handler or (someday) a console (which can remain in english), and oddly, some appear to be about failed form validation, which smells user-facing. Also check that the message makes sense for the point the C++ code wants to use it, and reword accordingly. As it turns out, these currently don't make it back to JS due to the unimplemented JS_Error() function; this is an enabling step towards implementing it. R=thestig@chromium.org Review URL: https://codereview.chromium.org/955273003
2015-02-25Kill off unused IFXJS interface methods.Tom Sepez
Re-work of original CL at: https://codereview.chromium.org/933043002/ Much of the IFXJS interface appears completely unused, so Kill off unused IFXJS interface methods. The code itself appears incomplete against all of the objects present in the paths that actually do register objects with JS. R=thestig@chromium.org Review URL: https://codereview.chromium.org/954923004
2015-02-17Tidy up JS_Defines.hTom Sepez
This is a purely mechanical change, no new functionality. - Expand some macros which were merely a short-cut to save typing but reduced transparency. - Put GET_VALUE_TYPE() implementation into a .cpp file. This is a portion of the patch from issue 908033002 at patchset 40001 (http://crrev.com/908033002#ps40001) R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/927263003
2015-02-05Kill off some more unreachable fopen's.Tom Sepez
The bstring's read from file is unused. The load from file paths aren't taken. R=jam@chromium.org Review URL: https://codereview.chromium.org/902943003
2015-02-05Merge to master: Kill off some dodgy JS callbacksTom Sepez
Note that this work was done opposite the usual branch order, because I didn't want to kill things in master that turned out to be in use in XFA. Original Review URL: https://codereview.chromium.org/883393007 TBR=jam@chromium.org Review URL: https://codereview.chromium.org/903893002
2015-02-05Add namespace and-re-arrange PDFium's local copy of chromium /base.Tom Sepez
Any projects DEPS'd into chromium and requiring a /base subset should have a local copy of that subset in a separate namespace. This will avoid future naming conflicts. Re-arrange the directory structure to better identify what came from chromium's base, and to make drop-in replacement easier for files that contain hard-coded "base/" in their #include directives. R=jam@chromium.org Review URL: https://codereview.chromium.org/900753002
2015-02-04Initialize V8 outside of PDFium.John Abd-El-Malek
This is similar to how we initialize ICU for V8 inside PDFium. BUG=455399 R=wfh@chromium.org Review URL: https://codereview.chromium.org/897973002
2015-01-05Cleanup: Get rid of CRLF line endings.Lei Zhang
R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/837533003
2015-01-05Remove run-time calculation of hash constants in pdfium.Bruce Dawson
PDFium static initializers must go. Static initializers are prohibited by the style guide. They have negative consequences including increased startup time (from pulling in additional code pages) and reduced sharing of data pages (since the variables can't go in the read-only data segment). This change uses a template struct and typed enums to reproduce JS_CalcHash at run-time. An unsigned long long constant and masking with 0xFFFFFFFF are used to avoid compile errors due to integer overflow of compile-time constants. The HashVerify class is used to check the results, necessary since none of the functions in global.cpp are called when pdfium_test.exe runs. const_expr would be a much cleaner way to implement this change but it is not yet widely supported. On the Windows release build this reduces the code size (.text virtual size) by 0x240 (576) bytes, the .data section by 0x20 bytes (for eight unsigned globals), and the .rdata section by 0x20 bytes (the unneeded string savings, minus the eight unsigned globals now being there). BUG=441899 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/792043005
2015-01-05Get rid of fifteen copies of m_sTimeMap and their initializers.Bruce Dawson
m_sTimeMap is a global variable with a constructor and destructor, which is not allowed. This change moves it to a function with a static pointer so that it is constructed on demand and then leaked, thus avoiding having startup and shutdown code. This also fixes a worrisome bug caused by having m_sTimeMap defined in a header file. Because m_sTimeMap was defined (and marked as static) in a header file there were fifteen separate copies of it, one for each source file which included the header file. This could easily lead to bugs because a timer that was added from one source file would be invisible to other source files. Each instance of m_sTimeMap added four entries to the dump-static-initializers.py report, for a total of sixty, so this fix significantly cleans up that report. BUG=441899 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/831903002
2014-12-30Get rid of FX_LPCSTR cast.Bo Xu
Follow up on https://codereview.chromium.org/733693003 R=brucedawson@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/809993004
2014-12-12Avoid duplicate definitions of JSCONST_n*Hash and QeTable variables.Bruce Dawson
QeTable is a 752 byte array that was defined in a header file. This caused it to be instantiated by the VC++ compiler 12 times, wasting 8,272 bytes of space in the data segment. Because 'const' implies 'static' this did not cause any duplicate symbol errors. JSCONST_n*HASH are a set of eight variables that are defined in a header file. This causes them to be replicated 15 times. The variables themselves are tiny but they are dynamically initialized and this dynamic initialization code is replicated 15 times. When tested on pdfium_test.exe the effect of this change is to: Reduce the .text (code) segment by 3,616 bytes. Reduce the .rdata section by 8,656 bytes. Reduce the total binary file size by 13312 bytes. These are the worst offenders for pdf.dll as shown in: https://drive.google.com/open?id=1BvubxoA2SU_2e4T5cq7jHTjc1TlT0qOndpIfX3DMeA8&authuser=0 This will also drastically simplify the list of work to be done for bug 441899 (getting rid of initializers). BUG=441988 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/802013002
2014-12-12Simplify PDFium by removing code that's not used in the open source repo.John Abd-El-Malek
-remove parameter from FPDF_InitLibrary -remove a bunch of ifdefs that are unused R=tsepez@chromium.org Review URL: https://codereview.chromium.org/801913002
2014-12-08Replace manual/error-prone/hard-to-verify arraysize calculations with safe ↵Bruce Dawson
FX_ArraySize macro. pdfium has numerous places where the number of elements in an array is calculated with expressions like: sizeof(cFormats)/sizeof(FX_LPCWSTR) This is suboptimal because it is verbose, it is easy to get wrong, and it cannot be determined through casual inspection whether the code is correct. It will give incorrect results if cFormats is a pointer instead of an array and it will give incorrect results if FX_LPCWSTR is not the type of the array elements. The FX_WSTRC macro in fx_string.h which I fixed was particularly scary because it would silently misbehave if passed a pointer. The FX_ArraySize macro which I have added and started using (taken from arraysize in v8's macros.h) is easier to use and will always give correct results. If passed a pointer it will fail to compile. For this change I only fixed instances of sizeof(FX_LPCWSTR). There appear to be about 150 other places in the pdfium code that could benefit from using FX_ArraySize. R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/729293003
2014-12-08Getting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this.Bruce Dawson
Since casts to FX_LPCWSTR have been shown to hide bugs I tried removing more of them, targeting those places where a cast was used to force a conversion from CFX_WideString to FX_LPCWSTR, replacing these casts with calls to the newly added .c_str() function. This revealed two places where the cast was hiding a bug -- where ->c_str() was required instead! This removes ~33 FX_LPCWSTR casts and there are ~31 left, many of which will go away in some future change. Also includes this change: Removing unnecessary casts from wchar_t* to wchar_t*, by various names. Original patch from Bruce Dawson(brucedawson@chromium.org) R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/733693003
2014-11-17Removing unnecessary casts from wchar_t* to wchar_t*, by various names.Bruce Dawson
Remove casts that merely cast from wchar_t* to wchar_t*. Sometimes the types or casts are FX_LPCWSTR but the idea is the same. Excess casts can (and have) hidden bugs so removing these may prevent future problems. Original patch from Bruce Dawson(brucedawson@chromium.org) R=bo_xu@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/730993002
2014-11-14Remove FX_LPCWSTR cast to wchar_t* literalsBo Xu
BUG=https://code.google.com/p/pdfium/issues/detail?id=78 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/726143002
2014-11-14Change from 'this' to L'this' and remove the cast that was hiding this mismatch.Bo Xu
Found by VC++'s /analyze. Warning was: fpdfsdk\src\javascript\js_runtime.cpp(352) : warning C6276: Cast between semantically different string types: char * to wchar_t *. Use of invalid string can lead to undefined behavior. This mismatch has been there as far back as the history goes (to May of this year). It looks like a real bug to me. However I don't know the implications of this bug and why it would not have been noticed at run-time. The code has been this way as far back as the git history goes, but that is only to May 2014. Original patch from Bruce Dawson(brucedawson@chromium.org) BUG=427616 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/705503004
2014-10-30For v8 Global Object, do not copy in CJS_Value constructor.Tom Sepez
BUG=425129 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/688303003
2014-09-22Invoke V8::Initialize() explicitly during V8 setupchromium/2168chromium/2167Jochen Eisinger
BUG=none R=jam@chromium.org Review URL: https://codereview.chromium.org/581413002
2014-08-22Fix confusion between length in bytes and length in characters in ↵Tom Sepez
app::response(). I also clean up the code while we are here, rewriting a strange switch statement and tidying whitespace. BUG=406142 R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/498773004
2014-08-13Remove try/catch blockBo Xu
BUG=pdfium:28 R=thakis@chromium.org Review URL: https://codereview.chromium.org/472563002
2014-07-31Fix a few more -Wreorder warnings.Nico Weber
No intended behavior change. BUG=pdfium:29 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/436483002
2014-07-30Remove a few unused variables, functions, and member variables.Nico Weber
No intended behavior change. BUG=pdfium:29 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/426763003
2014-07-30Add missing braces for aggregate initializers.Nico Weber
No intended behavior change. BUG=pdfium:29 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/426763004
2014-07-29Tidy up app::response().Tom Sepez
Follow-up from https://codereview.chromium.org/424883002/ - Remove some stray whitespace. - Fix "else after return". - Remove unused swResponse local. - Treat unexpectedly large responses as errors. BUG= R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/423953002
2014-07-29Fix a few more warnings in chromium_code mode.Nico Weber
No intended behavior change. - Remove more unused variables, functions, member variables. - Put a few constructor initializers in the order they execute in. - Add braces for subobject initializers. - Fix a handful of signed / unsigned comparisons. BUG=pdfium:29 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/429593005
2014-07-23Fix potential memory violation in CJS_PublicMethods::StrRTrim()Tom Sepez
BUG=395266 R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/411713003
2014-07-23Fix lookahead beyond bounds in CJS_PublicMethods::MakeFormatDate().Tom Sepez
BUG=396255 R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/407243003
2014-07-18Fix bounds checking in CJS_PublicMethods::MakeRegularDate().Tom Sepez
The function is looking ahead N characters at both its "format" and "value" strings without validating that accesses are in bounds. Add those validations. There are also duplicate checks in the else-branches which re-test the inverse of the if-branch. These are removed for simplicity. I also tidied some stray whitespace in the function while I was at it. BUG=393831 R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/395303004
2014-07-17Hook up the default v8::Platform implementation to pdfiumJochen Eisinger
It remains to call the PumpMessageLoop() method at a regular interval, however, since nothing posts to the loop yet, that shouldn't be a problem. BUG=25 R=jam@chromium.org Review URL: https://codereview.chromium.org/374123002
2014-07-14Fix an out-of-boundary issue for wide stringBo Xu
BUG=381521 R=palmer@chromium.org Review URL: https://codereview.chromium.org/383563002
2014-06-26Import Chromium base/numerics to resolve integer overflow.Chris Palmer
We'll use this for integer overflows going forward. BUG=382606 R=jam@chromium.org Review URL: https://codereview.chromium.org/349363005
2014-06-23Revert "Import Chromium base/numerics to resolve integer overflow."John Abd-El-Malek
This reverts commit d9713f05fdcecab8428d39034c6b84cd0bbd2920. This is breaking compile.
2014-06-20Import Chromium base/numerics to resolve integer overflow.Chris Palmer
We'll use this for integer overflows going forward. BUG=382606 R=bo_xu@foxitsoftware.com, jschuh@chromium.org Review URL: https://codereview.chromium.org/341533007
2014-05-23Convert all line endings to LF.John Abd-El-Malek
2014-05-20Add some blank lines at the end of 3 files to remove the "no newlines at end ↵John Abd-El-Malek
of file" warning.
2014-05-20Remove "using namespace v8" in header. This allows us to turn all warnings ↵John Abd-El-Malek
into errors. It also makes it clearer to find usage of v8 in the library.
2014-05-17Initial commit.John Abd-El-Malek