summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/cjs_event.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-30 18:12:32 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-10-30 18:12:32 +0000
commit4ab6b380624b3eaad7b17874e92e10e3feaa5cd9 (patch)
tree82d3e8c2eab5d8ed1a98eb059adc7798c7d1a89a /fpdfsdk/javascript/cjs_event.cpp
parentba9b9c3bd88817a47df1bbba16d58e7b504aef46 (diff)
downloadpdfium-4ab6b380624b3eaad7b17874e92e10e3feaa5cd9.tar.xz
Rename event to cjs_event
This CL renames the event.{cpp|h} files to cjs_event.{cpp|h} to match the internal class. Change-Id: I0e41a7ee068829f2bc8d94ff926edcf49b3a3c9f Reviewed-on: https://pdfium-review.googlesource.com/17043 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/cjs_event.cpp')
-rw-r--r--fpdfsdk/javascript/cjs_event.cpp308
1 files changed, 308 insertions, 0 deletions
diff --git a/fpdfsdk/javascript/cjs_event.cpp b/fpdfsdk/javascript/cjs_event.cpp
new file mode 100644
index 0000000000..28756a45b4
--- /dev/null
+++ b/fpdfsdk/javascript/cjs_event.cpp
@@ -0,0 +1,308 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/javascript/cjs_event.h"
+
+#include "fpdfsdk/javascript/JS_Define.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
+#include "fpdfsdk/javascript/cjs_eventhandler.h"
+#include "fpdfsdk/javascript/cjs_field.h"
+#include "fpdfsdk/javascript/cjs_object.h"
+
+const JSPropertySpec CJS_Event::PropertySpecs[] = {
+ {"change", get_change_static, set_change_static},
+ {"changeEx", get_change_ex_static, set_change_ex_static},
+ {"commitKey", get_commit_key_static, set_commit_key_static},
+ {"fieldFull", get_field_full_static, set_field_full_static},
+ {"keyDown", get_key_down_static, set_key_down_static},
+ {"modifier", get_modifier_static, set_modifier_static},
+ {"name", get_name_static, set_name_static},
+ {"rc", get_rc_static, set_rc_static},
+ {"richChange", get_rich_change_static, set_rich_change_static},
+ {"richChangeEx", get_rich_change_ex_static, set_rich_change_ex_static},
+ {"richValue", get_rich_value_static, set_rich_value_static},
+ {"selEnd", get_sel_end_static, set_sel_end_static},
+ {"selStart", get_sel_start_static, set_sel_start_static},
+ {"shift", get_shift_static, set_shift_static},
+ {"source", get_source_static, set_source_static},
+ {"target", get_target_static, set_target_static},
+ {"targetName", get_target_name_static, set_target_name_static},
+ {"type", get_type_static, set_type_static},
+ {"value", get_value_static, set_value_static},
+ {"willCommit", get_will_commit_static, set_will_commit_static},
+ {0, 0, 0}};
+
+int CJS_Event::ObjDefnID = -1;
+
+// static
+void CJS_Event::DefineJSObjects(CFXJS_Engine* pEngine) {
+ ObjDefnID = pEngine->DefineObj("event", FXJSOBJTYPE_STATIC,
+ JSConstructor<CJS_Event, event>,
+ JSDestructor<CJS_Event>);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
+}
+
+event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
+
+event::~event() {}
+
+CJS_Return event::get_change(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewString(pEvent->Change().c_str()));
+}
+
+CJS_Return event::set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (vp->IsString()) {
+ WideString& wChange = pEvent->Change();
+ wChange = pRuntime->ToWideString(vp);
+ }
+ return CJS_Return(true);
+}
+
+CJS_Return event::get_change_ex(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().c_str()));
+}
+
+CJS_Return event::set_change_ex(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_commit_key(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ return CJS_Return(pRuntime->NewNumber(pEvent->CommitKey()));
+}
+
+CJS_Return event::set_commit_key(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_field_full(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
+ return CJS_Return(false);
+
+ return CJS_Return(pRuntime->NewBoolean(pEvent->FieldFull()));
+}
+
+CJS_Return event::set_field_full(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_key_down(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewBoolean(pEvent->KeyDown()));
+}
+
+CJS_Return event::set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_modifier(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewBoolean(pEvent->Modifier()));
+}
+
+CJS_Return event::set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_name(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewString(pEvent->Name()));
+}
+
+CJS_Return event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_rc(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewBoolean(pEvent->Rc()));
+}
+
+CJS_Return 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(true);
+}
+
+CJS_Return event::get_rich_change(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
+}
+
+CJS_Return event::set_rich_change(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
+}
+
+CJS_Return event::get_rich_change_ex(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
+}
+
+CJS_Return event::set_rich_change_ex(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
+}
+
+CJS_Return event::get_rich_value(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
+}
+
+CJS_Return event::set_rich_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
+}
+
+CJS_Return event::get_sel_end(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
+ return CJS_Return(true);
+
+ return CJS_Return(pRuntime->NewNumber(pEvent->SelEnd()));
+}
+
+CJS_Return event::set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
+ return CJS_Return(true);
+
+ pEvent->SelEnd() = pRuntime->ToInt32(vp);
+ return CJS_Return(true);
+}
+
+CJS_Return event::get_sel_start(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
+ return CJS_Return(true);
+
+ return CJS_Return(pRuntime->NewNumber(pEvent->SelStart()));
+}
+
+CJS_Return event::set_sel_start(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
+ return CJS_Return(true);
+
+ pEvent->SelStart() = pRuntime->ToInt32(vp);
+ return CJS_Return(true);
+}
+
+CJS_Return event::get_shift(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewBoolean(pEvent->Shift()));
+}
+
+CJS_Return event::set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_source(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pEvent->Source()->GetJSObject()->ToV8Object());
+}
+
+CJS_Return event::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_target(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pEvent->Target_Field()->GetJSObject()->ToV8Object());
+}
+
+CJS_Return event::set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_target_name(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewString(pEvent->TargetName().c_str()));
+}
+
+CJS_Return event::set_target_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_type(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewString(pEvent->Type()));
+}
+
+CJS_Return event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}
+
+CJS_Return event::get_value(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
+ return CJS_Return(false);
+
+ if (!pEvent->m_pValue)
+ return CJS_Return(false);
+
+ return CJS_Return(pRuntime->NewString(pEvent->Value().c_str()));
+}
+
+CJS_Return event::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+
+ if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
+ return CJS_Return(false);
+
+ if (!pEvent->m_pValue)
+ return CJS_Return(false);
+
+ pEvent->Value() = pRuntime->ToWideString(vp);
+ return CJS_Return(true);
+}
+
+CJS_Return event::get_will_commit(CJS_Runtime* pRuntime) {
+ CJS_EventHandler* pEvent =
+ pRuntime->GetCurrentEventContext()->GetEventHandler();
+ return CJS_Return(pRuntime->NewBoolean(pEvent->WillCommit()));
+}
+
+CJS_Return event::set_will_commit(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
+}