blob: 2d4508a30b60e8673b3bd001e395306d5887f393 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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 Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Dan Sinclaire0345a42017-10-30 20:20:42 +00007#include "fxjs/cjs_event.h"
Tom Sepez37458412015-10-06 11:33:46 -07008
Dan Sinclaire0345a42017-10-30 20:20:42 +00009#include "fxjs/JS_Define.h"
10#include "fxjs/cjs_event_context.h"
11#include "fxjs/cjs_eventhandler.h"
12#include "fxjs/cjs_field.h"
13#include "fxjs/cjs_object.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070014
Dan Sinclairc94a7932017-10-26 16:48:57 -040015const JSPropertySpec CJS_Event::PropertySpecs[] = {
Tom Sepez4d5b8c52017-02-21 15:17:07 -080016 {"change", get_change_static, set_change_static},
dan sinclaircbe23db2017-10-19 14:29:33 -040017 {"changeEx", get_change_ex_static, set_change_ex_static},
18 {"commitKey", get_commit_key_static, set_commit_key_static},
19 {"fieldFull", get_field_full_static, set_field_full_static},
20 {"keyDown", get_key_down_static, set_key_down_static},
Tom Sepez4d5b8c52017-02-21 15:17:07 -080021 {"modifier", get_modifier_static, set_modifier_static},
22 {"name", get_name_static, set_name_static},
23 {"rc", get_rc_static, set_rc_static},
dan sinclaircbe23db2017-10-19 14:29:33 -040024 {"richChange", get_rich_change_static, set_rich_change_static},
25 {"richChangeEx", get_rich_change_ex_static, set_rich_change_ex_static},
26 {"richValue", get_rich_value_static, set_rich_value_static},
27 {"selEnd", get_sel_end_static, set_sel_end_static},
28 {"selStart", get_sel_start_static, set_sel_start_static},
Tom Sepez4d5b8c52017-02-21 15:17:07 -080029 {"shift", get_shift_static, set_shift_static},
30 {"source", get_source_static, set_source_static},
31 {"target", get_target_static, set_target_static},
dan sinclaircbe23db2017-10-19 14:29:33 -040032 {"targetName", get_target_name_static, set_target_name_static},
Tom Sepez4d5b8c52017-02-21 15:17:07 -080033 {"type", get_type_static, set_type_static},
34 {"value", get_value_static, set_value_static},
dan sinclaircbe23db2017-10-19 14:29:33 -040035 {"willCommit", get_will_commit_static, set_will_commit_static},
Tom Sepez04557b82017-02-16 09:43:10 -080036 {0, 0, 0}};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070037
Dan Sinclairef299532017-10-26 16:48:30 -040038int CJS_Event::ObjDefnID = -1;
Dan Sinclair89d26c82017-10-26 12:21:28 -040039
Dan Sinclairef299532017-10-26 16:48:30 -040040// static
Dan Sinclairbef4d3e2017-10-26 16:49:38 -040041void CJS_Event::DefineJSObjects(CFXJS_Engine* pEngine) {
42 ObjDefnID = pEngine->DefineObj("event", FXJSOBJTYPE_STATIC,
43 JSConstructor<CJS_Event, event>,
44 JSDestructor<CJS_Event>);
Dan Sinclairef299532017-10-26 16:48:30 -040045 DefineProps(pEngine, ObjDefnID, PropertySpecs);
Dan Sinclair89d26c82017-10-26 12:21:28 -040046}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070047
Nico Weber9d8ec5a2015-08-04 13:00:21 -070048event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
49
Dan Sinclairf766ad22016-03-14 13:51:24 -040050event::~event() {}
Nico Weber9d8ec5a2015-08-04 13:00:21 -070051
Dan Sinclair8f524d62017-10-25 13:30:31 -040052CJS_Return event::get_change(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -080053 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -080054 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -040055 return CJS_Return(pRuntime->NewString(pEvent->Change().c_str()));
dan sinclaircbe23db2017-10-19 14:29:33 -040056}
57
Dan Sinclair8f524d62017-10-25 13:30:31 -040058CJS_Return event::set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
dan sinclaircbe23db2017-10-19 14:29:33 -040059 CJS_EventHandler* pEvent =
60 pRuntime->GetCurrentEventContext()->GetEventHandler();
61
dan sinclair80435cb2017-10-24 21:40:24 -040062 if (vp->IsString()) {
dan sinclaircbe23db2017-10-19 14:29:33 -040063 WideString& wChange = pEvent->Change();
dan sinclair80435cb2017-10-24 21:40:24 -040064 wChange = pRuntime->ToWideString(vp);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070065 }
Dan Sinclair8f524d62017-10-25 13:30:31 -040066 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070067}
68
Dan Sinclair8f524d62017-10-25 13:30:31 -040069CJS_Return event::get_change_ex(CJS_Runtime* pRuntime) {
dan sinclaircbe23db2017-10-19 14:29:33 -040070 CJS_EventHandler* pEvent =
71 pRuntime->GetCurrentEventContext()->GetEventHandler();
72
Dan Sinclair8f524d62017-10-25 13:30:31 -040073 return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().c_str()));
dan sinclaircbe23db2017-10-19 14:29:33 -040074}
75
Dan Sinclair8f524d62017-10-25 13:30:31 -040076CJS_Return event::set_change_ex(CJS_Runtime* pRuntime,
77 v8::Local<v8::Value> vp) {
78 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -040079}
80
Dan Sinclair8f524d62017-10-25 13:30:31 -040081CJS_Return event::get_commit_key(CJS_Runtime* pRuntime) {
dan sinclaircbe23db2017-10-19 14:29:33 -040082 CJS_EventHandler* pEvent =
83 pRuntime->GetCurrentEventContext()->GetEventHandler();
84
Dan Sinclair8f524d62017-10-25 13:30:31 -040085 return CJS_Return(pRuntime->NewNumber(pEvent->CommitKey()));
dan sinclaircbe23db2017-10-19 14:29:33 -040086}
87
Dan Sinclair8f524d62017-10-25 13:30:31 -040088CJS_Return event::set_commit_key(CJS_Runtime* pRuntime,
89 v8::Local<v8::Value> vp) {
90 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -040091}
92
Dan Sinclair8f524d62017-10-25 13:30:31 -040093CJS_Return event::get_field_full(CJS_Runtime* pRuntime) {
dan sinclaircbe23db2017-10-19 14:29:33 -040094 CJS_EventHandler* pEvent =
95 pRuntime->GetCurrentEventContext()->GetEventHandler();
96
97 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
Dan Sinclair8f524d62017-10-25 13:30:31 -040098 return CJS_Return(false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070099
Dan Sinclair8f524d62017-10-25 13:30:31 -0400100 return CJS_Return(pRuntime->NewBoolean(pEvent->FieldFull()));
dan sinclaircbe23db2017-10-19 14:29:33 -0400101}
102
Dan Sinclair8f524d62017-10-25 13:30:31 -0400103CJS_Return event::set_field_full(CJS_Runtime* pRuntime,
104 v8::Local<v8::Value> vp) {
105 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400106}
107
Dan Sinclair8f524d62017-10-25 13:30:31 -0400108CJS_Return event::get_key_down(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800109 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800110 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400111 return CJS_Return(pRuntime->NewBoolean(pEvent->KeyDown()));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700112}
113
Dan Sinclair8f524d62017-10-25 13:30:31 -0400114CJS_Return event::set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
115 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400116}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700117
Dan Sinclair8f524d62017-10-25 13:30:31 -0400118CJS_Return event::get_modifier(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800119 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800120 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400121 return CJS_Return(pRuntime->NewBoolean(pEvent->Modifier()));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700122}
123
Dan Sinclair8f524d62017-10-25 13:30:31 -0400124CJS_Return event::set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
125 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400126}
127
Dan Sinclair8f524d62017-10-25 13:30:31 -0400128CJS_Return event::get_name(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800129 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800130 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400131 return CJS_Return(pRuntime->NewString(pEvent->Name()));
tsepez4cf55152016-11-02 14:37:54 -0700132}
133
Dan Sinclair8f524d62017-10-25 13:30:31 -0400134CJS_Return event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
135 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400136}
tsepez4cf55152016-11-02 14:37:54 -0700137
Dan Sinclair8f524d62017-10-25 13:30:31 -0400138CJS_Return event::get_rc(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800139 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800140 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400141 return CJS_Return(pRuntime->NewBoolean(pEvent->Rc()));
tsepez4cf55152016-11-02 14:37:54 -0700142}
143
Dan Sinclair8f524d62017-10-25 13:30:31 -0400144CJS_Return event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800145 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800146 pRuntime->GetCurrentEventContext()->GetEventHandler();
dan sinclair80435cb2017-10-24 21:40:24 -0400147 pEvent->Rc() = pRuntime->ToBoolean(vp);
Dan Sinclair8f524d62017-10-25 13:30:31 -0400148 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -0700149}
150
Dan Sinclair8f524d62017-10-25 13:30:31 -0400151CJS_Return event::get_rich_change(CJS_Runtime* pRuntime) {
152 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -0700153}
154
Dan Sinclair8f524d62017-10-25 13:30:31 -0400155CJS_Return event::set_rich_change(CJS_Runtime* pRuntime,
156 v8::Local<v8::Value> vp) {
157 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -0700158}
159
Dan Sinclair8f524d62017-10-25 13:30:31 -0400160CJS_Return event::get_rich_change_ex(CJS_Runtime* pRuntime) {
161 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -0700162}
163
Dan Sinclair8f524d62017-10-25 13:30:31 -0400164CJS_Return event::set_rich_change_ex(CJS_Runtime* pRuntime,
165 v8::Local<v8::Value> vp) {
166 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -0700167}
168
Dan Sinclair8f524d62017-10-25 13:30:31 -0400169CJS_Return event::get_rich_value(CJS_Runtime* pRuntime) {
170 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -0700171}
172
Dan Sinclair8f524d62017-10-25 13:30:31 -0400173CJS_Return event::set_rich_value(CJS_Runtime* pRuntime,
174 v8::Local<v8::Value> vp) {
175 return CJS_Return(true);
dan sinclaircbe23db2017-10-19 14:29:33 -0400176}
177
Dan Sinclair8f524d62017-10-25 13:30:31 -0400178CJS_Return event::get_sel_end(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800179 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800180 pRuntime->GetCurrentEventContext()->GetEventHandler();
tsepez4cf55152016-11-02 14:37:54 -0700181
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800182 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400183 return CJS_Return(true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700184
Dan Sinclair8f524d62017-10-25 13:30:31 -0400185 return CJS_Return(pRuntime->NewNumber(pEvent->SelEnd()));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700186}
187
Dan Sinclair8f524d62017-10-25 13:30:31 -0400188CJS_Return event::set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800189 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800190 pRuntime->GetCurrentEventContext()->GetEventHandler();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700191
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800192 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400193 return CJS_Return(true);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800194
Lei Zhangfae5e262017-11-20 19:58:13 +0000195 pEvent->SetSelEnd(pRuntime->ToInt32(vp));
Dan Sinclair8f524d62017-10-25 13:30:31 -0400196 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700197}
198
Dan Sinclair8f524d62017-10-25 13:30:31 -0400199CJS_Return event::get_sel_start(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800200 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800201 pRuntime->GetCurrentEventContext()->GetEventHandler();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700202
dan sinclaircbe23db2017-10-19 14:29:33 -0400203 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400204 return CJS_Return(true);
dan sinclaircbe23db2017-10-19 14:29:33 -0400205
Dan Sinclair8f524d62017-10-25 13:30:31 -0400206 return CJS_Return(pRuntime->NewNumber(pEvent->SelStart()));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700207}
208
Dan Sinclair8f524d62017-10-25 13:30:31 -0400209CJS_Return event::set_sel_start(CJS_Runtime* pRuntime,
210 v8::Local<v8::Value> vp) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800211 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800212 pRuntime->GetCurrentEventContext()->GetEventHandler();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213
dan sinclaircbe23db2017-10-19 14:29:33 -0400214 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400215 return CJS_Return(true);
dan sinclaircbe23db2017-10-19 14:29:33 -0400216
Lei Zhangfae5e262017-11-20 19:58:13 +0000217 pEvent->SetSelStart(pRuntime->ToInt32(vp));
Dan Sinclair8f524d62017-10-25 13:30:31 -0400218 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700219}
220
Dan Sinclair8f524d62017-10-25 13:30:31 -0400221CJS_Return event::get_shift(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800222 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800223 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400224 return CJS_Return(pRuntime->NewBoolean(pEvent->Shift()));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700225}
226
Dan Sinclair8f524d62017-10-25 13:30:31 -0400227CJS_Return event::set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
228 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400229}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700230
Dan Sinclair8f524d62017-10-25 13:30:31 -0400231CJS_Return event::get_source(CJS_Runtime* pRuntime) {
Tom Sepezb1670b52017-02-16 17:01:00 -0800232 CJS_EventHandler* pEvent =
233 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400234 return CJS_Return(pEvent->Source()->GetJSObject()->ToV8Object());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700235}
236
Dan Sinclair8f524d62017-10-25 13:30:31 -0400237CJS_Return event::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
238 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400239}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700240
Dan Sinclair8f524d62017-10-25 13:30:31 -0400241CJS_Return event::get_target(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800242 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800243 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400244 return CJS_Return(pEvent->Target_Field()->GetJSObject()->ToV8Object());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700245}
246
Dan Sinclair8f524d62017-10-25 13:30:31 -0400247CJS_Return event::set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
248 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400249}
250
Dan Sinclair8f524d62017-10-25 13:30:31 -0400251CJS_Return event::get_target_name(CJS_Runtime* pRuntime) {
dan sinclaircbe23db2017-10-19 14:29:33 -0400252 CJS_EventHandler* pEvent =
253 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400254 return CJS_Return(pRuntime->NewString(pEvent->TargetName().c_str()));
dan sinclaircbe23db2017-10-19 14:29:33 -0400255}
256
Dan Sinclair8f524d62017-10-25 13:30:31 -0400257CJS_Return event::set_target_name(CJS_Runtime* pRuntime,
258 v8::Local<v8::Value> vp) {
259 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400260}
261
Dan Sinclair8f524d62017-10-25 13:30:31 -0400262CJS_Return event::get_type(CJS_Runtime* pRuntime) {
dan sinclaircbe23db2017-10-19 14:29:33 -0400263 CJS_EventHandler* pEvent =
264 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400265 return CJS_Return(pRuntime->NewString(pEvent->Type()));
dan sinclaircbe23db2017-10-19 14:29:33 -0400266}
267
Dan Sinclair8f524d62017-10-25 13:30:31 -0400268CJS_Return event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
269 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400270}
271
Dan Sinclair8f524d62017-10-25 13:30:31 -0400272CJS_Return event::get_value(CJS_Runtime* pRuntime) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800273 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800274 pRuntime->GetCurrentEventContext()->GetEventHandler();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700275
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700276 if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400277 return CJS_Return(false);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800278
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700279 if (!pEvent->m_pValue)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400280 return CJS_Return(false);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800281
Dan Sinclair8f524d62017-10-25 13:30:31 -0400282 return CJS_Return(pRuntime->NewString(pEvent->Value().c_str()));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700283}
284
Dan Sinclair8f524d62017-10-25 13:30:31 -0400285CJS_Return event::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800286 CJS_EventHandler* pEvent =
Tom Sepezb1670b52017-02-16 17:01:00 -0800287 pRuntime->GetCurrentEventContext()->GetEventHandler();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700288
dan sinclaircbe23db2017-10-19 14:29:33 -0400289 if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400290 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400291
292 if (!pEvent->m_pValue)
Dan Sinclair8f524d62017-10-25 13:30:31 -0400293 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400294
dan sinclair80435cb2017-10-24 21:40:24 -0400295 pEvent->Value() = pRuntime->ToWideString(vp);
Dan Sinclair8f524d62017-10-25 13:30:31 -0400296 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700297}
dan sinclaircbe23db2017-10-19 14:29:33 -0400298
Dan Sinclair8f524d62017-10-25 13:30:31 -0400299CJS_Return event::get_will_commit(CJS_Runtime* pRuntime) {
dan sinclaircbe23db2017-10-19 14:29:33 -0400300 CJS_EventHandler* pEvent =
301 pRuntime->GetCurrentEventContext()->GetEventHandler();
Dan Sinclair8f524d62017-10-25 13:30:31 -0400302 return CJS_Return(pRuntime->NewBoolean(pEvent->WillCommit()));
dan sinclaircbe23db2017-10-19 14:29:33 -0400303}
304
Dan Sinclair8f524d62017-10-25 13:30:31 -0400305CJS_Return event::set_will_commit(CJS_Runtime* pRuntime,
306 v8::Local<v8::Value> vp) {
307 return CJS_Return(false);
dan sinclaircbe23db2017-10-19 14:29:33 -0400308}