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 | |
Lei Zhang | bde53d2 | 2015-11-12 22:21:30 -0800 | [diff] [blame] | 9 | #include "fpdfsdk/include/javascript/IJavaScript.h" |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame^] | 10 | #include "fpdfsdk/javascript/Field.h" |
| 11 | #include "fpdfsdk/javascript/JS_Context.h" |
| 12 | #include "fpdfsdk/javascript/JS_Define.h" |
| 13 | #include "fpdfsdk/javascript/JS_EventHandler.h" |
| 14 | #include "fpdfsdk/javascript/JS_Object.h" |
| 15 | #include "fpdfsdk/javascript/JS_Value.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 16 | |
| 17 | /* -------------------------- event -------------------------- */ |
| 18 | |
| 19 | BEGIN_JS_STATIC_CONST(CJS_Event) |
| 20 | END_JS_STATIC_CONST() |
| 21 | |
| 22 | BEGIN_JS_STATIC_PROP(CJS_Event) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 23 | JS_STATIC_PROP_ENTRY(change) |
| 24 | JS_STATIC_PROP_ENTRY(changeEx) |
| 25 | JS_STATIC_PROP_ENTRY(commitKey) |
| 26 | JS_STATIC_PROP_ENTRY(fieldFull) |
| 27 | JS_STATIC_PROP_ENTRY(keyDown) |
| 28 | JS_STATIC_PROP_ENTRY(modifier) |
| 29 | JS_STATIC_PROP_ENTRY(name) |
| 30 | JS_STATIC_PROP_ENTRY(rc) |
| 31 | JS_STATIC_PROP_ENTRY(richChange) |
| 32 | JS_STATIC_PROP_ENTRY(richChangeEx) |
| 33 | JS_STATIC_PROP_ENTRY(richValue) |
| 34 | JS_STATIC_PROP_ENTRY(selEnd) |
| 35 | JS_STATIC_PROP_ENTRY(selStart) |
| 36 | JS_STATIC_PROP_ENTRY(shift) |
| 37 | JS_STATIC_PROP_ENTRY(source) |
| 38 | JS_STATIC_PROP_ENTRY(target) |
| 39 | JS_STATIC_PROP_ENTRY(targetName) |
| 40 | JS_STATIC_PROP_ENTRY(type) |
| 41 | JS_STATIC_PROP_ENTRY(value) |
| 42 | JS_STATIC_PROP_ENTRY(willCommit) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 43 | END_JS_STATIC_PROP() |
| 44 | |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 45 | BEGIN_JS_STATIC_METHOD(CJS_Event) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 46 | END_JS_STATIC_METHOD() |
| 47 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 48 | IMPLEMENT_JS_CLASS(CJS_Event, event) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 49 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 50 | event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {} |
| 51 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame^] | 52 | event::~event() {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 53 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 54 | FX_BOOL event::change(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 55 | CJS_PropValue& vp, |
| 56 | CFX_WideString& sError) { |
| 57 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 58 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 59 | CFX_WideString& wChange = pEvent->Change(); |
| 60 | if (vp.IsSetting()) { |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 61 | if (vp.GetType() == CJS_Value::VT_string) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 62 | vp >> wChange; |
| 63 | } else { |
| 64 | vp << wChange; |
| 65 | } |
| 66 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 69 | FX_BOOL event::changeEx(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 70 | CJS_PropValue& vp, |
| 71 | CFX_WideString& sError) { |
| 72 | if (!vp.IsGetting()) |
| 73 | return FALSE; |
| 74 | |
| 75 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 76 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 77 | |
| 78 | vp << pEvent->ChangeEx(); |
| 79 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 82 | FX_BOOL event::commitKey(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 83 | CJS_PropValue& vp, |
| 84 | CFX_WideString& sError) { |
| 85 | if (!vp.IsGetting()) |
| 86 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 87 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 88 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 89 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 90 | |
| 91 | vp << pEvent->CommitKey(); |
| 92 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 95 | FX_BOOL event::fieldFull(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 96 | CJS_PropValue& vp, |
| 97 | CFX_WideString& sError) { |
| 98 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 99 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 100 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 101 | if (!vp.IsGetting() && |
| 102 | wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) |
| 103 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 104 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 105 | if (pEvent->FieldFull()) |
| 106 | vp << TRUE; |
| 107 | else |
| 108 | vp << FALSE; |
| 109 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 112 | FX_BOOL event::keyDown(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 113 | CJS_PropValue& vp, |
| 114 | CFX_WideString& sError) { |
| 115 | if (!vp.IsGetting()) |
| 116 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 117 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 118 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 119 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 120 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 121 | if (pEvent->KeyDown()) |
| 122 | vp << TRUE; |
| 123 | else |
| 124 | vp << FALSE; |
| 125 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 128 | FX_BOOL event::modifier(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 129 | CJS_PropValue& vp, |
| 130 | CFX_WideString& sError) { |
| 131 | if (!vp.IsGetting()) |
| 132 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 133 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 134 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 135 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 136 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 137 | if (pEvent->Modifier()) |
| 138 | vp << TRUE; |
| 139 | else |
| 140 | vp << FALSE; |
| 141 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 142 | } |
| 143 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 144 | FX_BOOL event::name(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 145 | CJS_PropValue& vp, |
| 146 | CFX_WideString& sError) { |
| 147 | if (!vp.IsGetting()) |
| 148 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 149 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 150 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 151 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 152 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 153 | vp << pEvent->Name(); |
| 154 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 157 | FX_BOOL event::rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 158 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 159 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 160 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 161 | FX_BOOL& bRc = pEvent->Rc(); |
| 162 | if (vp.IsSetting()) { |
| 163 | vp >> bRc; |
| 164 | } else { |
| 165 | vp << bRc; |
| 166 | } |
| 167 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 170 | FX_BOOL event::richChange(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | CJS_PropValue& vp, |
| 172 | CFX_WideString& sError) { |
| 173 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 176 | FX_BOOL event::richChangeEx(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 177 | CJS_PropValue& vp, |
| 178 | CFX_WideString& sError) { |
| 179 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 182 | FX_BOOL event::richValue(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 183 | CJS_PropValue& vp, |
| 184 | CFX_WideString& sError) { |
| 185 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 188 | FX_BOOL event::selEnd(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 189 | CJS_PropValue& vp, |
| 190 | CFX_WideString& sError) { |
| 191 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 192 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 193 | |
| 194 | if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { |
| 195 | return TRUE; |
| 196 | } |
| 197 | |
| 198 | int& iSelEnd = pEvent->SelEnd(); |
| 199 | if (vp.IsSetting()) { |
| 200 | vp >> iSelEnd; |
| 201 | } else { |
| 202 | vp << iSelEnd; |
| 203 | } |
| 204 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 207 | FX_BOOL event::selStart(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 208 | CJS_PropValue& vp, |
| 209 | CFX_WideString& sError) { |
| 210 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 211 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 212 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 213 | if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { |
| 214 | return TRUE; |
| 215 | } |
| 216 | int& iSelStart = pEvent->SelStart(); |
| 217 | if (vp.IsSetting()) { |
| 218 | vp >> iSelStart; |
| 219 | } else { |
| 220 | vp << iSelStart; |
| 221 | } |
| 222 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 225 | FX_BOOL event::shift(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 226 | CJS_PropValue& vp, |
| 227 | CFX_WideString& sError) { |
| 228 | if (!vp.IsGetting()) |
| 229 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 230 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 231 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 232 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 233 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 234 | if (pEvent->Shift()) |
| 235 | vp << TRUE; |
| 236 | else |
| 237 | vp << FALSE; |
| 238 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 241 | FX_BOOL event::source(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 242 | CJS_PropValue& vp, |
| 243 | CFX_WideString& sError) { |
| 244 | if (!vp.IsGetting()) |
| 245 | return FALSE; |
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 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 248 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 249 | |
| 250 | vp << pEvent->Source()->GetJSObject(); |
| 251 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 254 | FX_BOOL event::target(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 255 | CJS_PropValue& vp, |
| 256 | CFX_WideString& sError) { |
| 257 | if (!vp.IsGetting()) |
| 258 | return FALSE; |
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 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 261 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 262 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 263 | vp << pEvent->Target_Field()->GetJSObject(); |
| 264 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 267 | FX_BOOL event::targetName(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 268 | CJS_PropValue& vp, |
| 269 | CFX_WideString& sError) { |
| 270 | if (!vp.IsGetting()) |
| 271 | return FALSE; |
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 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 274 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 275 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 276 | vp << pEvent->TargetName(); |
| 277 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 280 | FX_BOOL event::type(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 281 | CJS_PropValue& vp, |
| 282 | CFX_WideString& sError) { |
| 283 | if (!vp.IsGetting()) |
| 284 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 285 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 286 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 287 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 288 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 289 | vp << pEvent->Type(); |
| 290 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 293 | FX_BOOL event::value(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 294 | CJS_PropValue& vp, |
| 295 | CFX_WideString& sError) { |
| 296 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 297 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 298 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 299 | if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) |
| 300 | return FALSE; |
| 301 | if (!pEvent->m_pValue) |
| 302 | return FALSE; |
| 303 | CFX_WideString& val = pEvent->Value(); |
| 304 | if (vp.IsSetting()) { |
| 305 | vp >> val; |
| 306 | } else { |
| 307 | vp << val; |
| 308 | } |
| 309 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 312 | FX_BOOL event::willCommit(IJS_Context* cc, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 313 | CJS_PropValue& vp, |
| 314 | CFX_WideString& sError) { |
| 315 | if (!vp.IsGetting()) |
| 316 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 317 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 318 | CJS_Context* pContext = (CJS_Context*)cc; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 319 | CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 320 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 321 | if (pEvent->WillCommit()) |
| 322 | vp << TRUE; |
| 323 | else |
| 324 | vp << FALSE; |
| 325 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 326 | } |