diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-05-17 13:53:52 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-17 13:53:52 +0000 |
commit | dc5d88bcebbeeb696b405464e901add55d1efaf7 (patch) | |
tree | 54bc913015ea4d08b9fe46997f25a3153cbc70d7 /fxjs/ijs_runtime.h | |
parent | db3c6cefceddf25c25f1205d7b633f09e873bf98 (diff) | |
download | pdfium-dc5d88bcebbeeb696b405464e901add55d1efaf7.tar.xz |
Convert JS execute methods to return Optional<IJS_Runtime::JS_Error>
This CL changes several of the JS execution methods to to return an
Optional<IJS_Runtime::JS_Error> instead of a bool with a WideString
out param.
The IJS_Runtime::JS_Error will contain the line, column and exception message
if an error occurs during execution.
Change-Id: I37785ae6cd133a4c94ad8d25289473600b8a5d19
Reviewed-on: https://pdfium-review.googlesource.com/32614
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/ijs_runtime.h')
-rw-r--r-- | fxjs/ijs_runtime.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fxjs/ijs_runtime.h b/fxjs/ijs_runtime.h index cde31c6e52..a21aae86de 100644 --- a/fxjs/ijs_runtime.h +++ b/fxjs/ijs_runtime.h @@ -11,6 +11,7 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" +#include "third_party/base/optional.h" #ifdef PDF_ENABLE_XFA #include "fxjs/fxjse.h" @@ -25,6 +26,14 @@ class IJS_EventContext; // when JS is not present. class IJS_Runtime { public: + struct JS_Error { + int line; + int column; + WideString exception; + + JS_Error(int line, int column, const WideString& exception); + }; + static void Initialize(unsigned int slot, void* isolate); static void Destroy(); static std::unique_ptr<IJS_Runtime> Create( @@ -35,7 +44,7 @@ class IJS_Runtime { virtual IJS_EventContext* NewEventContext() = 0; virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0; virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0; - virtual int ExecuteScript(const WideString& script, WideString* info) = 0; + virtual Optional<JS_Error> ExecuteScript(const WideString& script) = 0; #ifdef PDF_ENABLE_XFA virtual bool GetValueByNameFromGlobalObject(const ByteStringView& utf8Name, @@ -45,7 +54,7 @@ class IJS_Runtime { #endif // PDF_ENABLE_XFA protected: - IJS_Runtime() {} + IJS_Runtime() = default; }; #endif // FXJS_IJS_RUNTIME_H_ |