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