aboutsummaryrefslogtreecommitdiff
path: root/fxjs/cjs_event.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/cjs_event.cpp')
-rw-r--r--fxjs/cjs_event.cpp71
1 files changed, 24 insertions, 47 deletions
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index a16ee6c53..6b8903838 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -1,4 +1,4 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,6 @@
#include "fxjs/cjs_event.h"
#include "fxjs/cjs_event_context.h"
-#include "fxjs/cjs_eventrecorder.h"
#include "fxjs/cjs_field.h"
#include "fxjs/cjs_object.h"
#include "fxjs/js_define.h"
@@ -34,11 +33,11 @@ const JSPropertySpec CJS_Event::PropertySpecs[] = {
{"value", get_value_static, set_value_static},
{"willCommit", get_will_commit_static, set_will_commit_static}};
-int CJS_Event::ObjDefnID = -1;
+uint32_t CJS_Event::ObjDefnID = 0;
const char CJS_Event::kName[] = "event";
// static
-int CJS_Event::GetObjDefnID() {
+uint32_t CJS_Event::GetObjDefnID() {
return ObjDefnID;
}
@@ -55,27 +54,22 @@ CJS_Event::CJS_Event(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_Event::~CJS_Event() = default;
CJS_Result CJS_Event::get_change(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(
pRuntime->NewString(pEvent->Change().AsStringView()));
}
CJS_Result CJS_Event::set_change(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
-
if (vp->IsString()) {
- WideString& wChange = pEvent->Change();
- wChange = pRuntime->ToWideString(vp);
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
+ pEvent->Change() = pRuntime->ToWideString(vp);
}
return CJS_Result::Success();
}
CJS_Result CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(
pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
}
@@ -86,8 +80,7 @@ CJS_Result CJS_Event::set_change_ex(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_commit_key(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewNumber(pEvent->CommitKey()));
}
@@ -97,8 +90,7 @@ CJS_Result CJS_Event::set_commit_key(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_field_full(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() != "Keystroke")
return CJS_Result::Failure(L"unrecognized event");
@@ -111,8 +103,7 @@ CJS_Result CJS_Event::set_field_full(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_key_down(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->KeyDown()));
}
@@ -122,8 +113,7 @@ CJS_Result CJS_Event::set_key_down(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_modifier(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Modifier()));
}
@@ -133,8 +123,7 @@ CJS_Result CJS_Event::set_modifier(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_name(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewString(pEvent->Name()));
}
@@ -143,14 +132,12 @@ CJS_Result CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
}
CJS_Result CJS_Event::get_rc(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Rc()));
}
CJS_Result CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
pEvent->Rc() = pRuntime->ToBoolean(vp);
return CJS_Result::Success();
}
@@ -183,8 +170,7 @@ CJS_Result CJS_Event::set_rich_value(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() != "Keystroke")
return CJS_Result::Success();
@@ -193,8 +179,7 @@ CJS_Result CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
CJS_Result CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() == "Keystroke")
pEvent->SetSelEnd(pRuntime->ToInt32(vp));
@@ -202,8 +187,7 @@ CJS_Result CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() != "Keystroke")
return CJS_Result::Success();
@@ -212,8 +196,7 @@ CJS_Result CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
CJS_Result CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Name() == "Keystroke")
pEvent->SetSelStart(pRuntime->ToInt32(vp));
@@ -221,8 +204,7 @@ CJS_Result CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_shift(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Shift()));
}
@@ -256,8 +238,7 @@ CJS_Result CJS_Event::set_target(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(
pRuntime->NewString(pEvent->TargetName().AsStringView()));
}
@@ -268,8 +249,7 @@ CJS_Result CJS_Event::set_target_name(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_type(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewString(pEvent->Type()));
}
@@ -278,8 +258,7 @@ CJS_Result CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
}
CJS_Result CJS_Event::get_value(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Type() != "Field")
return CJS_Result::Failure(L"Bad event type.");
@@ -292,8 +271,7 @@ CJS_Result CJS_Event::get_value(CJS_Runtime* pRuntime) {
CJS_Result CJS_Event::set_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
if (pEvent->Type() != "Field")
return CJS_Result::Failure(L"Bad event type.");
@@ -311,8 +289,7 @@ CJS_Result CJS_Event::set_value(CJS_Runtime* pRuntime,
}
CJS_Result CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
- CJS_EventRecorder* pEvent =
- pRuntime->GetCurrentEventContext()->GetEventRecorder();
+ CJS_EventContext* pEvent = pRuntime->GetCurrentEventContext();
return CJS_Result::Success(pRuntime->NewBoolean(pEvent->WillCommit()));
}