From 4ab6b380624b3eaad7b17874e92e10e3feaa5cd9 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 30 Oct 2017 18:12:32 +0000 Subject: 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 Commit-Queue: dsinclair --- BUILD.gn | 4 +- fpdfsdk/javascript/cjs_event.cpp | 308 +++++++++++++++++++++++++++++++++++++ fpdfsdk/javascript/cjs_event.h | 111 +++++++++++++ fpdfsdk/javascript/cjs_runtime.cpp | 2 +- fpdfsdk/javascript/event.cpp | 308 ------------------------------------- fpdfsdk/javascript/event.h | 111 ------------- 6 files changed, 422 insertions(+), 422 deletions(-) create mode 100644 fpdfsdk/javascript/cjs_event.cpp create mode 100644 fpdfsdk/javascript/cjs_event.h delete mode 100644 fpdfsdk/javascript/event.cpp delete mode 100644 fpdfsdk/javascript/event.h diff --git a/BUILD.gn b/BUILD.gn index 5666c24492..db940dfe16 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1212,6 +1212,8 @@ static_library("javascript") { "fpdfsdk/javascript/cjs_document.h", "fpdfsdk/javascript/cjs_embedobj.cpp", "fpdfsdk/javascript/cjs_embedobj.h", + "fpdfsdk/javascript/cjs_event.cpp", + "fpdfsdk/javascript/cjs_event.h", "fpdfsdk/javascript/cjs_event_context.cpp", "fpdfsdk/javascript/cjs_event_context.h", "fpdfsdk/javascript/cjs_eventhandler.cpp", @@ -1252,8 +1254,6 @@ static_library("javascript") { "fpdfsdk/javascript/cjs_timerobj.h", "fpdfsdk/javascript/cjs_zoomtype.cpp", "fpdfsdk/javascript/cjs_zoomtype.h", - "fpdfsdk/javascript/event.cpp", - "fpdfsdk/javascript/event.h", "fpdfsdk/javascript/global_timer.cpp", "fpdfsdk/javascript/global_timer.h", "fpdfsdk/javascript/report.cpp", 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, + JSDestructor); + 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 vp) { + return CJS_Return(false); +} diff --git a/fpdfsdk/javascript/cjs_event.h b/fpdfsdk/javascript/cjs_event.h new file mode 100644 index 0000000000..27e158926b --- /dev/null +++ b/fpdfsdk/javascript/cjs_event.h @@ -0,0 +1,111 @@ +// 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 + +#ifndef FPDFSDK_JAVASCRIPT_CJS_EVENT_H_ +#define FPDFSDK_JAVASCRIPT_CJS_EVENT_H_ + +#include "fpdfsdk/javascript/JS_Define.h" + +class event : public CJS_EmbedObj { + public: + explicit event(CJS_Object* pJSObject); + ~event() override; + + CJS_Return get_change(CJS_Runtime* pRuntime); + CJS_Return set_change(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_change_ex(CJS_Runtime* pRuntime); + CJS_Return set_change_ex(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_commit_key(CJS_Runtime* pRuntime); + CJS_Return set_commit_key(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_field_full(CJS_Runtime* pRuntime); + CJS_Return set_field_full(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_key_down(CJS_Runtime* pRuntime); + CJS_Return set_key_down(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_modifier(CJS_Runtime* pRuntime); + CJS_Return set_modifier(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_name(CJS_Runtime* pRuntime); + CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_rc(CJS_Runtime* pRuntime); + CJS_Return set_rc(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_rich_change(CJS_Runtime* pRuntime); + CJS_Return set_rich_change(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_rich_change_ex(CJS_Runtime* pRuntime); + CJS_Return set_rich_change_ex(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_rich_value(CJS_Runtime* pRuntime); + CJS_Return set_rich_value(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_sel_end(CJS_Runtime* pRuntime); + CJS_Return set_sel_end(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_sel_start(CJS_Runtime* pRuntime); + CJS_Return set_sel_start(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_shift(CJS_Runtime* pRuntime); + CJS_Return set_shift(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_source(CJS_Runtime* pRuntime); + CJS_Return set_source(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_target(CJS_Runtime* pRuntime); + CJS_Return set_target(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_target_name(CJS_Runtime* pRuntime); + CJS_Return set_target_name(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_type(CJS_Runtime* pRuntime); + CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_value(CJS_Runtime* pRuntime); + CJS_Return set_value(CJS_Runtime* pRuntime, v8::Local vp); + + CJS_Return get_will_commit(CJS_Runtime* pRuntime); + CJS_Return set_will_commit(CJS_Runtime* pRuntime, v8::Local vp); +}; + +class CJS_Event : public CJS_Object { + public: + static void DefineJSObjects(CFXJS_Engine* pEngine); + + explicit CJS_Event(v8::Local pObject) : CJS_Object(pObject) {} + ~CJS_Event() override {} + + JS_STATIC_PROP(change, change, event); + JS_STATIC_PROP(changeEx, change_ex, event); + JS_STATIC_PROP(commitKey, commit_key, event); + JS_STATIC_PROP(fieldFull, field_full, event); + JS_STATIC_PROP(keyDown, key_down, event); + JS_STATIC_PROP(modifier, modifier, event); + JS_STATIC_PROP(name, name, event); + JS_STATIC_PROP(rc, rc, event); + JS_STATIC_PROP(richChange, rich_change, event); + JS_STATIC_PROP(richChangeEx, rich_change_ex, event); + JS_STATIC_PROP(richValue, rich_value, event); + JS_STATIC_PROP(selEnd, sel_end, event); + JS_STATIC_PROP(selStart, sel_start, event); + JS_STATIC_PROP(shift, shift, event); + JS_STATIC_PROP(source, source, event); + JS_STATIC_PROP(target, target, event); + JS_STATIC_PROP(targetName, target_name, event); + JS_STATIC_PROP(type, type, event); + JS_STATIC_PROP(value, value, event); + JS_STATIC_PROP(willCommit, will_commit, event); + + private: + static int ObjDefnID; + static const JSPropertySpec PropertySpecs[]; +}; + +#endif // FPDFSDK_JAVASCRIPT_CJS_EVENT_H_ diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp index 581d5c70a8..2c71b013dd 100644 --- a/fpdfsdk/javascript/cjs_runtime.cpp +++ b/fpdfsdk/javascript/cjs_runtime.cpp @@ -18,6 +18,7 @@ #include "fpdfsdk/javascript/cjs_console.h" #include "fpdfsdk/javascript/cjs_display.h" #include "fpdfsdk/javascript/cjs_document.h" +#include "fpdfsdk/javascript/cjs_event.h" #include "fpdfsdk/javascript/cjs_event_context.h" #include "fpdfsdk/javascript/cjs_eventhandler.h" #include "fpdfsdk/javascript/cjs_field.h" @@ -36,7 +37,6 @@ #include "fpdfsdk/javascript/cjs_style.h" #include "fpdfsdk/javascript/cjs_timerobj.h" #include "fpdfsdk/javascript/cjs_zoomtype.h" -#include "fpdfsdk/javascript/event.h" #include "fpdfsdk/javascript/report.h" #include "fpdfsdk/javascript/util.h" #include "public/fpdf_formfill.h" diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp deleted file mode 100644 index 22aaa04315..0000000000 --- a/fpdfsdk/javascript/event.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// 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/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, - JSDestructor); - 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 vp) { - return CJS_Return(false); -} diff --git a/fpdfsdk/javascript/event.h b/fpdfsdk/javascript/event.h deleted file mode 100644 index 8aa7c0e639..0000000000 --- a/fpdfsdk/javascript/event.h +++ /dev/null @@ -1,111 +0,0 @@ -// 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 - -#ifndef FPDFSDK_JAVASCRIPT_EVENT_H_ -#define FPDFSDK_JAVASCRIPT_EVENT_H_ - -#include "fpdfsdk/javascript/JS_Define.h" - -class event : public CJS_EmbedObj { - public: - explicit event(CJS_Object* pJSObject); - ~event() override; - - CJS_Return get_change(CJS_Runtime* pRuntime); - CJS_Return set_change(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_change_ex(CJS_Runtime* pRuntime); - CJS_Return set_change_ex(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_commit_key(CJS_Runtime* pRuntime); - CJS_Return set_commit_key(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_field_full(CJS_Runtime* pRuntime); - CJS_Return set_field_full(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_key_down(CJS_Runtime* pRuntime); - CJS_Return set_key_down(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_modifier(CJS_Runtime* pRuntime); - CJS_Return set_modifier(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_name(CJS_Runtime* pRuntime); - CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_rc(CJS_Runtime* pRuntime); - CJS_Return set_rc(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_rich_change(CJS_Runtime* pRuntime); - CJS_Return set_rich_change(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_rich_change_ex(CJS_Runtime* pRuntime); - CJS_Return set_rich_change_ex(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_rich_value(CJS_Runtime* pRuntime); - CJS_Return set_rich_value(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_sel_end(CJS_Runtime* pRuntime); - CJS_Return set_sel_end(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_sel_start(CJS_Runtime* pRuntime); - CJS_Return set_sel_start(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_shift(CJS_Runtime* pRuntime); - CJS_Return set_shift(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_source(CJS_Runtime* pRuntime); - CJS_Return set_source(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_target(CJS_Runtime* pRuntime); - CJS_Return set_target(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_target_name(CJS_Runtime* pRuntime); - CJS_Return set_target_name(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_type(CJS_Runtime* pRuntime); - CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_value(CJS_Runtime* pRuntime); - CJS_Return set_value(CJS_Runtime* pRuntime, v8::Local vp); - - CJS_Return get_will_commit(CJS_Runtime* pRuntime); - CJS_Return set_will_commit(CJS_Runtime* pRuntime, v8::Local vp); -}; - -class CJS_Event : public CJS_Object { - public: - static void DefineJSObjects(CFXJS_Engine* pEngine); - - explicit CJS_Event(v8::Local pObject) : CJS_Object(pObject) {} - ~CJS_Event() override {} - - JS_STATIC_PROP(change, change, event); - JS_STATIC_PROP(changeEx, change_ex, event); - JS_STATIC_PROP(commitKey, commit_key, event); - JS_STATIC_PROP(fieldFull, field_full, event); - JS_STATIC_PROP(keyDown, key_down, event); - JS_STATIC_PROP(modifier, modifier, event); - JS_STATIC_PROP(name, name, event); - JS_STATIC_PROP(rc, rc, event); - JS_STATIC_PROP(richChange, rich_change, event); - JS_STATIC_PROP(richChangeEx, rich_change_ex, event); - JS_STATIC_PROP(richValue, rich_value, event); - JS_STATIC_PROP(selEnd, sel_end, event); - JS_STATIC_PROP(selStart, sel_start, event); - JS_STATIC_PROP(shift, shift, event); - JS_STATIC_PROP(source, source, event); - JS_STATIC_PROP(target, target, event); - JS_STATIC_PROP(targetName, target_name, event); - JS_STATIC_PROP(type, type, event); - JS_STATIC_PROP(value, value, event); - JS_STATIC_PROP(willCommit, will_commit, event); - - private: - static int ObjDefnID; - static const JSPropertySpec PropertySpecs[]; -}; - -#endif // FPDFSDK_JAVASCRIPT_EVENT_H_ -- cgit v1.2.3