7#include "fxjs/xfa/cjx_eventpseudomodel.h"
13#include "fxjs/xfa/cfxjse_engine.h"
14#include "third_party/base/containers/span.h"
15#include "third_party/base/notreached.h"
16#include "third_party/base/numerics/safe_conversions.h"
17#include "v8/include/v8-primitive.h"
18#include "xfa/fxfa/cxfa_eventparam.h"
19#include "xfa/fxfa/cxfa_ffnotify.h"
20#include "xfa/fxfa/parser/cscript_eventpseudomodel.h"
24void StringProperty(
v8::Isolate* pIsolate,
25 v8::Local<v8::Value>* pReturn,
29 *wsValue = fxv8::ReentrantToWideStringHelper(pIsolate, *pReturn);
32 *pReturn = fxv8::NewStringHelper(pIsolate, wsValue
->ToUTF8().AsStringView());
35void IntegerProperty(
v8::Isolate* pIsolate,
36 v8::Local<v8::Value>* pReturn,
40 *iValue = fxv8::ReentrantToInt32Helper(pIsolate, *pReturn);
43 *pReturn = fxv8::NewNumberHelper(pIsolate, *iValue);
46void BooleanProperty(
v8::Isolate* pIsolate,
47 v8::Local<v8::Value>* pReturn,
51 *bValue = fxv8::ReentrantToBooleanHelper(pIsolate, *pReturn);
54 *pReturn = fxv8::NewBooleanHelper(pIsolate, *bValue);
60 {
"emit", emit_static},
61 {
"reset", reset_static}};
63CJX_EventPseudoModel::CJX_EventPseudoModel(CScript_EventPseudoModel* model)
74void CJX_EventPseudoModel::cancelAction(
v8::Isolate* pIsolate,
75 v8::Local<v8::Value>* pValue,
78 Property(pIsolate, pValue, XFA_Event::CancelAction, bSetting);
81void CJX_EventPseudoModel::change(
v8::Isolate* pIsolate,
82 v8::Local<v8::Value>* pValue,
85 Property(pIsolate, pValue, XFA_Event::Change, bSetting);
88void CJX_EventPseudoModel::commitKey(
v8::Isolate* pIsolate,
89 v8::Local<v8::Value>* pValue,
92 Property(pIsolate, pValue, XFA_Event::CommitKey, bSetting);
95void CJX_EventPseudoModel::fullText(
v8::Isolate* pIsolate,
96 v8::Local<v8::Value>* pValue,
99 Property(pIsolate, pValue, XFA_Event::FullText, bSetting);
102void CJX_EventPseudoModel::keyDown(
v8::Isolate* pIsolate,
103 v8::Local<v8::Value>* pValue,
106 Property(pIsolate, pValue, XFA_Event::Keydown, bSetting);
109void CJX_EventPseudoModel::modifier(
v8::Isolate* pIsolate,
110 v8::Local<v8::Value>* pValue,
113 Property(pIsolate, pValue, XFA_Event::Modifier, bSetting);
116void CJX_EventPseudoModel::newContentType(
v8::Isolate* pIsolate,
117 v8::Local<v8::Value>* pValue,
120 Property(pIsolate, pValue, XFA_Event::NewContentType, bSetting);
123void CJX_EventPseudoModel::newText(
v8::Isolate* pIsolate,
124 v8::Local<v8::Value>* pValue,
131 GetDocument()->GetScriptContext()->GetEventParam();
135 *pValue = fxv8::NewStringHelper(
139void CJX_EventPseudoModel::prevContentType(
v8::Isolate* pIsolate,
140 v8::Local<v8::Value>* pValue,
143 Property(pIsolate, pValue, XFA_Event::PreviousContentType, bSetting);
146void CJX_EventPseudoModel::prevText(
v8::Isolate* pIsolate,
147 v8::Local<v8::Value>* pValue,
150 Property(pIsolate, pValue, XFA_Event::PreviousText, bSetting);
153void CJX_EventPseudoModel::reenter(
v8::Isolate* pIsolate,
154 v8::Local<v8::Value>* pValue,
157 Property(pIsolate, pValue, XFA_Event::Reenter, bSetting);
160void CJX_EventPseudoModel::selEnd(
v8::Isolate* pIsolate,
161 v8::Local<v8::Value>* pValue,
164 Property(pIsolate, pValue, XFA_Event::SelectionEnd, bSetting);
167void CJX_EventPseudoModel::selStart(
v8::Isolate* pIsolate,
168 v8::Local<v8::Value>* pValue,
171 Property(pIsolate, pValue, XFA_Event::SelectionStart, bSetting);
174void CJX_EventPseudoModel::shift(
v8::Isolate* pIsolate,
175 v8::Local<v8::Value>* pValue,
178 Property(pIsolate, pValue, XFA_Event::Shift, bSetting);
181void CJX_EventPseudoModel::soapFaultCode(
v8::Isolate* pIsolate,
182 v8::Local<v8::Value>* pValue,
185 Property(pIsolate, pValue, XFA_Event::SoapFaultCode, bSetting);
188void CJX_EventPseudoModel::soapFaultString(
v8::Isolate* pIsolate,
189 v8::Local<v8::Value>* pValue,
192 Property(pIsolate, pValue, XFA_Event::SoapFaultString, bSetting);
195void CJX_EventPseudoModel::target(
v8::Isolate* pIsolate,
196 v8::Local<v8::Value>* pValue,
199 Property(pIsolate, pValue, XFA_Event::Target, bSetting);
204 pdfium::span<v8::Local<v8::Value>> params) {
219 pdfium::span<v8::Local<v8::Value>> params) {
227void CJX_EventPseudoModel::Property(
v8::Isolate* pIsolate,
228 v8::Local<v8::Value>* pValue,
249 StringProperty(pIsolate, pValue, &pEventParam->m_wsChange, bSetting);
252 IntegerProperty(pIsolate, pValue, &pEventParam
->m_iCommitKey, bSetting);
255 StringProperty(pIsolate, pValue, &pEventParam->m_wsFullText, bSetting);
258 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bKeyDown, bSetting);
261 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bModifier, bSetting);
264 StringProperty(pIsolate, pValue, &pEventParam->m_wsNewContentType,
268 NOTREACHED_NORETURN();
270 StringProperty(pIsolate, pValue, &pEventParam->m_wsPrevContentType,
274 StringProperty(pIsolate, pValue, &pEventParam->m_wsPrevText, bSetting);
277 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bReenter, bSetting);
280 IntegerProperty(pIsolate, pValue, &pEventParam
->m_iSelEnd, bSetting);
284 pEventParam
->m_iSelEnd, pdfium::base::checked_cast<int32_t>(
285 pEventParam->m_wsPrevText.GetLength()));
290 IntegerProperty(pIsolate, pValue, &pEventParam
->m_iSelStart, bSetting);
293 pEventParam
->m_iSelStart, pdfium::base::checked_cast<int32_t>(
294 pEventParam->m_wsPrevText.GetLength()));
299 BooleanProperty(pIsolate, pValue, &pEventParam
->m_bShift, bSetting);
302 StringProperty(pIsolate, pValue, &pEventParam->m_wsSoapFaultCode,
306 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
void DefineMethods(pdfium::span< const CJX_MethodSpec > methods)
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