From cbe23dbdff3f6e41843fd99cbf615000b52727ed Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 19 Oct 2017 14:29:33 -0400 Subject: Refactoring JS Callbacks. 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 Commit-Queue: dsinclair --- fpdfsdk/javascript/event.h | 185 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 143 insertions(+), 42 deletions(-) (limited to 'fpdfsdk/javascript/event.h') diff --git a/fpdfsdk/javascript/event.h b/fpdfsdk/javascript/event.h index 857423784e..e67aa2b8af 100644 --- a/fpdfsdk/javascript/event.h +++ b/fpdfsdk/javascript/event.h @@ -15,28 +15,129 @@ class event : public CJS_EmbedObj { ~event() override; public: - bool change(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool changeEx(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool commitKey(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool fieldFull(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool keyDown(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool modifier(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool name(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool rc(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool richChange(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool richChangeEx(CJS_Runtime* pRuntime, - CJS_PropValue& vp, - WideString& sError); - bool richValue(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool selEnd(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool selStart(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool shift(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool source(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool target(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool targetName(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool type(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool value(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); - bool willCommit(CJS_Runtime* pRuntime, CJS_PropValue& vp, WideString& sError); + bool get_change(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_change(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_change_ex(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_change_ex(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_commit_key(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_commit_key(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_field_full(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_field_full(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_key_down(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_key_down(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_modifier(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_modifier(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_name(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_name(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_rc(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_rc(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_rich_change(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_rich_change(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_rich_change_ex(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_rich_change_ex(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_rich_value(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_rich_value(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_sel_end(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_sel_end(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_sel_start(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_sel_start(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_shift(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_shift(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_source(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_source(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_target(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_target(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_target_name(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_target_name(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_type(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_type(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_value(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool set_value(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); + + bool get_will_commit(CJS_Runtime* pRuntime, + CJS_PropValue* vp, + WideString* sError); + bool set_will_commit(CJS_Runtime* pRuntime, + const CJS_PropValue& vp, + WideString* sError); }; class CJS_Event : public CJS_Object { @@ -45,26 +146,26 @@ class CJS_Event : public CJS_Object { ~CJS_Event() override {} DECLARE_JS_CLASS(); - JS_STATIC_PROP(change, event); - JS_STATIC_PROP(changeEx, event); - JS_STATIC_PROP(commitKey, event); - JS_STATIC_PROP(fieldFull, event); - JS_STATIC_PROP(keyDown, event); - JS_STATIC_PROP(modifier, event); - JS_STATIC_PROP(name, event); - JS_STATIC_PROP(rc, event); - JS_STATIC_PROP(richChange, event); - JS_STATIC_PROP(richChangeEx, event); - JS_STATIC_PROP(richValue, event); - JS_STATIC_PROP(selEnd, event); - JS_STATIC_PROP(selStart, event); - JS_STATIC_PROP(shift, event); - JS_STATIC_PROP(source, event); - JS_STATIC_PROP(target, event); - JS_STATIC_PROP(targetName, event); - JS_STATIC_PROP(type, event); - JS_STATIC_PROP(value, event); - JS_STATIC_PROP(willCommit, event); + JS_STATIC_PROP(change, change, event); + JS_STATIC_PROP(changeEx, change_ex, event); + JS_STATIC_PROP(commitKey, commit_key, event); + JS_STATIC_PROP(fieldFull, field_full, event); + JS_STATIC_PROP(keyDown, key_down, event); + JS_STATIC_PROP(modifier, modifier, event); + JS_STATIC_PROP(name, name, event); + JS_STATIC_PROP(rc, rc, event); + JS_STATIC_PROP(richChange, rich_change, event); + JS_STATIC_PROP(richChangeEx, rich_change_ex, event); + JS_STATIC_PROP(richValue, rich_value, event); + JS_STATIC_PROP(selEnd, sel_end, event); + JS_STATIC_PROP(selStart, sel_start, event); + JS_STATIC_PROP(shift, shift, event); + JS_STATIC_PROP(source, source, event); + JS_STATIC_PROP(target, target, event); + JS_STATIC_PROP(targetName, target_name, event); + JS_STATIC_PROP(type, type, event); + JS_STATIC_PROP(value, value, event); + JS_STATIC_PROP(willCommit, will_commit, event); }; #endif // FPDFSDK_JAVASCRIPT_EVENT_H_ -- cgit v1.2.3