John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/javascript/event.h" |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 8 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 9 | #include "fpdfsdk/javascript/Field.h" |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 10 | #include "fpdfsdk/javascript/JS_Define.h" |
| 11 | #include "fpdfsdk/javascript/JS_EventHandler.h" |
| 12 | #include "fpdfsdk/javascript/JS_Object.h" |
| 13 | #include "fpdfsdk/javascript/JS_Value.h" |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 14 | #include "fpdfsdk/javascript/cjs_event_context.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 15 | |
Tom Sepez | 04557b8 | 2017-02-16 09:43:10 -0800 | [diff] [blame] | 16 | JSConstSpec CJS_Event::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 17 | |
Tom Sepez | 04557b8 | 2017-02-16 09:43:10 -0800 | [diff] [blame] | 18 | JSPropertySpec CJS_Event::PropertySpecs[] = { |
Tom Sepez | 4d5b8c5 | 2017-02-21 15:17:07 -0800 | [diff] [blame^] | 19 | {"change", get_change_static, set_change_static}, |
| 20 | {"changeEx", get_changeEx_static, set_changeEx_static}, |
| 21 | {"commitKey", get_commitKey_static, set_commitKey_static}, |
| 22 | {"fieldFull", get_fieldFull_static, set_fieldFull_static}, |
| 23 | {"keyDown", get_keyDown_static, set_keyDown_static}, |
| 24 | {"modifier", get_modifier_static, set_modifier_static}, |
| 25 | {"name", get_name_static, set_name_static}, |
| 26 | {"rc", get_rc_static, set_rc_static}, |
| 27 | {"richChange", get_richChange_static, set_richChange_static}, |
| 28 | {"richChangeEx", get_richChangeEx_static, set_richChangeEx_static}, |
| 29 | {"richValue", get_richValue_static, set_richValue_static}, |
| 30 | {"selEnd", get_selEnd_static, set_selEnd_static}, |
| 31 | {"selStart", get_selStart_static, set_selStart_static}, |
| 32 | {"shift", get_shift_static, set_shift_static}, |
| 33 | {"source", get_source_static, set_source_static}, |
| 34 | {"target", get_target_static, set_target_static}, |
| 35 | {"targetName", get_targetName_static, set_targetName_static}, |
| 36 | {"type", get_type_static, set_type_static}, |
| 37 | {"value", get_value_static, set_value_static}, |
| 38 | {"willCommit", get_willCommit_static, set_willCommit_static}, |
Tom Sepez | 04557b8 | 2017-02-16 09:43:10 -0800 | [diff] [blame] | 39 | {0, 0, 0}}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 40 | |
Tom Sepez | 04557b8 | 2017-02-16 09:43:10 -0800 | [diff] [blame] | 41 | JSMethodSpec CJS_Event::MethodSpecs[] = {{0, 0}}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 42 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 43 | IMPLEMENT_JS_CLASS(CJS_Event, event) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 44 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 45 | event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {} |
| 46 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 47 | event::~event() {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 48 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 49 | bool event::change(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 50 | CJS_PropValue& vp, |
| 51 | CFX_WideString& sError) { |
| 52 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 53 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 54 | CFX_WideString& wChange = pEvent->Change(); |
| 55 | if (vp.IsSetting()) { |
tsepez | f3dc8c6 | 2016-08-10 06:29:29 -0700 | [diff] [blame] | 56 | if (vp.GetJSValue()->GetType() == CJS_Value::VT_string) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 57 | vp >> wChange; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 58 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 59 | } |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 60 | vp << wChange; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 61 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 64 | bool event::changeEx(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 65 | CJS_PropValue& vp, |
| 66 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 67 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 68 | return false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 69 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 70 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 71 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | |
| 73 | vp << pEvent->ChangeEx(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 74 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 77 | bool event::commitKey(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 78 | CJS_PropValue& vp, |
| 79 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 80 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 81 | return false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 82 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 83 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 84 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 85 | |
| 86 | vp << pEvent->CommitKey(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 87 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 90 | bool event::fieldFull(CJS_Runtime* pRuntime, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 91 | CJS_PropValue& vp, |
| 92 | CFX_WideString& sError) { |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 93 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 94 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 95 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 96 | if (!vp.IsGetting() && |
| 97 | wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) |
| 98 | return false; |
| 99 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 100 | vp << pEvent->FieldFull(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 101 | return true; |
| 102 | } |
| 103 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 104 | bool event::keyDown(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 105 | CJS_PropValue& vp, |
| 106 | CFX_WideString& sError) { |
| 107 | if (!vp.IsGetting()) |
| 108 | return false; |
| 109 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 110 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 111 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 112 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 113 | vp << pEvent->KeyDown(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 114 | return true; |
| 115 | } |
| 116 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 117 | bool event::modifier(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 118 | CJS_PropValue& vp, |
| 119 | CFX_WideString& sError) { |
| 120 | if (!vp.IsGetting()) |
| 121 | return false; |
| 122 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 123 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 124 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 125 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 126 | vp << pEvent->Modifier(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 127 | return true; |
| 128 | } |
| 129 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 130 | bool event::name(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 131 | CJS_PropValue& vp, |
| 132 | CFX_WideString& sError) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 133 | if (!vp.IsGetting()) |
| 134 | return false; |
| 135 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 136 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 137 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 138 | |
| 139 | vp << pEvent->Name(); |
| 140 | return true; |
| 141 | } |
| 142 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 143 | bool event::rc(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 144 | CJS_PropValue& vp, |
| 145 | CFX_WideString& sError) { |
| 146 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 147 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 148 | |
| 149 | bool& bRc = pEvent->Rc(); |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 150 | if (vp.IsSetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 151 | vp >> bRc; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 152 | else |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 153 | vp << bRc; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 154 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 155 | return true; |
| 156 | } |
| 157 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 158 | bool event::richChange(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 159 | CJS_PropValue& vp, |
| 160 | CFX_WideString& sError) { |
| 161 | return true; |
| 162 | } |
| 163 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 164 | bool event::richChangeEx(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 165 | CJS_PropValue& vp, |
| 166 | CFX_WideString& sError) { |
| 167 | return true; |
| 168 | } |
| 169 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 170 | bool event::richValue(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 171 | CJS_PropValue& vp, |
| 172 | CFX_WideString& sError) { |
| 173 | return true; |
| 174 | } |
| 175 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 176 | bool event::selEnd(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 177 | CJS_PropValue& vp, |
| 178 | CFX_WideString& sError) { |
| 179 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 180 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 181 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 182 | if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 183 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 184 | |
| 185 | int& iSelEnd = pEvent->SelEnd(); |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 186 | if (vp.IsSetting()) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 187 | vp >> iSelEnd; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 188 | else |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 189 | vp << iSelEnd; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 190 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 191 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 194 | bool event::selStart(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 195 | CJS_PropValue& vp, |
| 196 | CFX_WideString& sError) { |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 197 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 198 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 199 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 200 | if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 201 | return true; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 202 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 203 | int& iSelStart = pEvent->SelStart(); |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 204 | if (vp.IsSetting()) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 205 | vp >> iSelStart; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 206 | else |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 207 | vp << iSelStart; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 208 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 209 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 212 | bool event::shift(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 213 | CJS_PropValue& vp, |
| 214 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 215 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 216 | return false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 217 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 218 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 219 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 220 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 221 | vp << pEvent->Shift(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 222 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 225 | bool event::source(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 226 | CJS_PropValue& vp, |
| 227 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 228 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 229 | return false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 230 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 231 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 232 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 233 | |
| 234 | vp << pEvent->Source()->GetJSObject(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 235 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 238 | bool event::target(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 239 | CJS_PropValue& vp, |
| 240 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 241 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 242 | return false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 243 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 244 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 245 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 246 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 247 | vp << pEvent->Target_Field()->GetJSObject(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 248 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 251 | bool event::targetName(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 252 | CJS_PropValue& vp, |
| 253 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 254 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 255 | return false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 256 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 257 | CJS_EventHandler* pEvent = |
| 258 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 259 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 260 | vp << pEvent->TargetName(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 261 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 264 | bool event::type(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 265 | CJS_PropValue& vp, |
| 266 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 267 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 268 | return false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 269 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 270 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 271 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 272 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 273 | vp << pEvent->Type(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 274 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 277 | bool event::value(CJS_Runtime* pRuntime, |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 278 | CJS_PropValue& vp, |
| 279 | CFX_WideString& sError) { |
| 280 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 281 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 282 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 283 | if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 284 | return false; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 285 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 286 | if (!pEvent->m_pValue) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 287 | return false; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 288 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 289 | CFX_WideString& val = pEvent->Value(); |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 290 | if (vp.IsSetting()) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 291 | vp >> val; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 292 | else |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 293 | vp << val; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 294 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 295 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 298 | bool event::willCommit(CJS_Runtime* pRuntime, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 299 | CJS_PropValue& vp, |
| 300 | CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 301 | if (!vp.IsGetting()) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 302 | return false; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 303 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 304 | CJS_EventHandler* pEvent = |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 305 | pRuntime->GetCurrentEventContext()->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 306 | |
Tom Sepez | b1670b5 | 2017-02-16 17:01:00 -0800 | [diff] [blame] | 307 | vp << pEvent->WillCommit(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 308 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 309 | } |