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