7#include "fxjs/xfa/cjx_eventpseudomodel.h"
11#include "core/fxcrt/notreached.h"
12#include "core/fxcrt/numerics/safe_conversions.h"
13#include "core/fxcrt/span.h"
15#include "fxjs/xfa/cfxjse_engine.h"
16#include "v8/include/v8-primitive.h"
17#include "xfa/fxfa/cxfa_eventparam.h"
18#include "xfa/fxfa/cxfa_ffnotify.h"
19#include "xfa/fxfa/parser/cscript_eventpseudomodel.h"
23void StringProperty(
v8::Isolate* pIsolate,
24 v8::Local<v8::Value>* pReturn,
28 *wsValue = fxv8::ReentrantToWideStringHelper(pIsolate, *pReturn);
31 *pReturn = fxv8::NewStringHelper(pIsolate, wsValue
->ToUTF8().AsStringView());
34void IntegerProperty(
v8::Isolate* pIsolate,
35 v8::Local<v8::Value>* pReturn,
39 *iValue = fxv8::ReentrantToInt32Helper(pIsolate, *pReturn);
42 *pReturn = fxv8::NewNumberHelper(pIsolate, *iValue);
45void BooleanProperty(
v8::Isolate* pIsolate,
46 v8::Local<v8::Value>* pReturn,
50 *bValue = fxv8::ReentrantToBooleanHelper(pIsolate, *pReturn);
53 *pReturn = fxv8::NewBooleanHelper(pIsolate, *bValue);
59 {
"emit", emit_static},
60 {
"reset", reset_static}};
62CJX_EventPseudoModel::CJX_EventPseudoModel(CScript_EventPseudoModel* model)
64 DefineMethods(MethodSpecs);
73void CJX_EventPseudoModel::cancelAction(
v8::Isolate* pIsolate,
74 v8::Local<v8::Value>* pValue,
77 Property(pIsolate, pValue, XFA_Event::CancelAction, bSetting);
80void CJX_EventPseudoModel::change(
v8::Isolate* pIsolate,
81 v8::Local<v8::Value>* pValue,
84 Property(pIsolate, pValue, XFA_Event::Change, bSetting);
87void CJX_EventPseudoModel::commitKey(
v8::Isolate* pIsolate,
88 v8::Local<v8::Value>* pValue,
91 Property(pIsolate, pValue, XFA_Event::CommitKey, bSetting);
94void CJX_EventPseudoModel::fullText(
v8::Isolate* pIsolate,
95 v8::Local<v8::Value>* pValue,
98 Property(pIsolate, pValue, XFA_Event::FullText, bSetting);
101void CJX_EventPseudoModel::keyDown(
v8::Isolate* pIsolate,
102 v8::Local<v8::Value>* pValue,
105 Property(pIsolate, pValue, XFA_Event::Keydown, bSetting);
108void CJX_EventPseudoModel::modifier(
v8::Isolate* pIsolate,
109 v8::Local<v8::Value>* pValue,
112 Property(pIsolate, pValue, XFA_Event::Modifier, bSetting);
115void CJX_EventPseudoModel::newContentType(
v8::Isolate* pIsolate,
116 v8::Local<v8::Value>* pValue,
119 Property(pIsolate, pValue, XFA_Event::NewContentType, bSetting);
122void CJX_EventPseudoModel::newText(
v8::Isolate* pIsolate,
123 v8::Local<v8::Value>* pValue,
130 GetDocument()->GetScriptContext()->GetEventParam();
134 *pValue = fxv8::NewStringHelper(
138void CJX_EventPseudoModel::prevContentType(
v8::Isolate* pIsolate,
139 v8::Local<v8::Value>* pValue,
142 Property(pIsolate, pValue, XFA_Event::PreviousContentType, bSetting);
145void CJX_EventPseudoModel::prevText(
v8::Isolate* pIsolate,
146 v8::Local<v8::Value>* pValue,
149 Property(pIsolate, pValue, XFA_Event::PreviousText, bSetting);
152void CJX_EventPseudoModel::reenter(
v8::Isolate* pIsolate,
153 v8::Local<v8::Value>* pValue,
156 Property(pIsolate, pValue, XFA_Event::Reenter, bSetting);
159void CJX_EventPseudoModel::selEnd(
v8::Isolate* pIsolate,
160 v8::Local<v8::Value>* pValue,
163 Property(pIsolate, pValue, XFA_Event::SelectionEnd, bSetting);
166void CJX_EventPseudoModel::selStart(
v8::Isolate* pIsolate,
167 v8::Local<v8::Value>* pValue,
170 Property(pIsolate, pValue, XFA_Event::SelectionStart, bSetting);
173void CJX_EventPseudoModel::shift(
v8::Isolate* pIsolate,
174 v8::Local<v8::Value>* pValue,
177 Property(pIsolate, pValue, XFA_Event::Shift, bSetting);
180void CJX_EventPseudoModel::soapFaultCode(
v8::Isolate* pIsolate,
181 v8::Local<v8::Value>* pValue,
184 Property(pIsolate, pValue, XFA_Event::SoapFaultCode, bSetting);
187void CJX_EventPseudoModel::soapFaultString(
v8::Isolate* pIsolate,
188 v8::Local<v8::Value>* pValue,
191 Property(pIsolate, pValue, XFA_Event::SoapFaultString, bSetting);
194void CJX_EventPseudoModel::target(
v8::Isolate* pIsolate,
195 v8::Local<v8::Value>* pValue,
198 Property(pIsolate, pValue, XFA_Event::Target, bSetting);
203 pdfium::span<v8::Local<v8::Value>> params) {
218 pdfium::span<v8::Local<v8::Value>> params) {
226void CJX_EventPseudoModel::Property(
v8::Isolate* pIsolate,
227 v8::Local<v8::Value>* pValue,
248 StringProperty(pIsolate, pValue, &pEventParam->m_wsChange, bSetting);
251 IntegerProperty(pIsolate, pValue, &pEventParam
->m_iCommitKey, bSetting);
254 StringProperty(pIsolate, pValue, &pEventParam->m_wsFullText, bSetting);
257 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bKeyDown, bSetting);
260 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bModifier, bSetting);
263 StringProperty(pIsolate, pValue, &pEventParam->m_wsNewContentType,
269 StringProperty(pIsolate, pValue, &pEventParam->m_wsPrevContentType,
273 StringProperty(pIsolate, pValue, &pEventParam->m_wsPrevText, bSetting);
276 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bReenter, bSetting);
279 IntegerProperty(pIsolate, pValue, &pEventParam
->m_iSelEnd, bSetting);
284 pdfium::checked_cast<int32_t>(pEventParam->m_wsPrevText.GetLength()));
289 IntegerProperty(pIsolate, pValue, &pEventParam
->m_iSelStart, bSetting);
293 pdfium::checked_cast<int32_t>(pEventParam->m_wsPrevText.GetLength()));
298 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bShift, bSetting);
301 StringProperty(pIsolate, pValue, &pEventParam->m_wsSoapFaultCode,
305 StringProperty(pIsolate, pValue, &pEventParam->m_wsSoapFaultString,
CXFA_Node * GetEventTarget() const
CXFA_EventParam * GetEventParam() const
friend class EventParamScope
static CJS_Result Success()
bool DynamicTypeIs(TypeTag eType) const override
~CJX_EventPseudoModel() override
CXFA_Document * GetDocument() const
virtual bool DynamicTypeIs(TypeTag eType) const
WideString GetNewText() const
CXFA_EventParam & operator=(CXFA_EventParam &&other) noexcept
CXFA_EventParam(XFA_EVENTTYPE type)
void HandleWidgetEvent(CXFA_Node *pNode, CXFA_EventParam *pParam)
ByteString ToUTF8() const
#define NOTREACHED_NORETURN()
fxcrt::WideString WideString