summaryrefslogtreecommitdiff
path: root/fxjs/cjs_event.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/cjs_event.cpp')
-rw-r--r--fxjs/cjs_event.cpp121
1 files changed, 55 insertions, 66 deletions
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index 9594f13477..f00f07c3b9 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -55,10 +55,10 @@ CJS_Event::CJS_Event(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_Event::~CJS_Event() = default;
CJS_Return CJS_Event::get_change(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Change().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->Change().AsStringView()));
}
CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
@@ -72,123 +72,116 @@ CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
WideString& wChange = pEvent->Change();
wChange = pRuntime->ToWideString(vp);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
-
- return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
}
CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_commit_key(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
-
- return CJS_Return(pRuntime->NewNumber(pEvent->CommitKey()));
+ return CJS_Return::Success(pRuntime->NewNumber(pEvent->CommitKey()));
}
CJS_Return CJS_Event::set_commit_key(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_field_full(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
-
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return(L"unrecognized event");
+ return CJS_Return::Failure(L"unrecognized event");
- return CJS_Return(pRuntime->NewBoolean(pEvent->FieldFull()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->FieldFull()));
}
CJS_Return CJS_Event::set_field_full(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_key_down(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->KeyDown()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->KeyDown()));
}
CJS_Return CJS_Event::set_key_down(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_modifier(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->Modifier()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Modifier()));
}
CJS_Return CJS_Event::set_modifier(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_name(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Name()));
+ return CJS_Return::Success(pRuntime->NewString(pEvent->Name()));
}
CJS_Return CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_rc(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->Rc()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Rc()));
}
CJS_Return CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
pEvent->Rc() = pRuntime->ToBoolean(vp);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_rich_change(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::set_rich_change(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_rich_change_ex(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::set_rich_change_ex(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_rich_value(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::set_rich_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
@@ -196,9 +189,9 @@ CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ return CJS_Return::Success();
- return CJS_Return(pRuntime->NewNumber(pEvent->SelEnd()));
+ return CJS_Return::Success(pRuntime->NewNumber(pEvent->SelEnd()));
}
CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
@@ -206,11 +199,10 @@ CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") == 0)
+ pEvent->SetSelEnd(pRuntime->ToInt32(vp));
- pEvent->SetSelEnd(pRuntime->ToInt32(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
@@ -218,9 +210,9 @@ CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ return CJS_Return::Success();
- return CJS_Return(pRuntime->NewNumber(pEvent->SelStart()));
+ return CJS_Return::Success(pRuntime->NewNumber(pEvent->SelStart()));
}
CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
@@ -228,84 +220,81 @@ CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") == 0)
+ pEvent->SetSelStart(pRuntime->ToInt32(vp));
- pEvent->SetSelStart(pRuntime->ToInt32(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_shift(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->Shift()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Shift()));
}
CJS_Return CJS_Event::set_shift(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_source(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pEvent->Source()->ToV8Object());
+ return CJS_Return::Success(pEvent->Source()->ToV8Object());
}
CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pEvent->Target_Field()->ToV8Object());
+ return CJS_Return::Success(pEvent->Target_Field()->ToV8Object());
}
CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->TargetName().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->TargetName().AsStringView()));
}
CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_type(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Type()));
+ return CJS_Return::Success(pRuntime->NewString(pEvent->Type()));
}
CJS_Return CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
- return CJS_Return(L"Bad event type.");
+ return CJS_Return::Failure(L"Bad event type.");
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(pEvent->Value().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->Value().AsStringView()));
}
CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
@@ -316,13 +305,13 @@ CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
- return CJS_Return(L"Bad event type.");
+ return CJS_Return::Failure(L"Bad event type.");
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pEvent->Value() = pRuntime->ToWideString(vp);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
@@ -330,10 +319,10 @@ CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->WillCommit()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->WillCommit()));
}
CJS_Return CJS_Event::set_will_commit(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}