Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: fpdfsdk/src/javascript/event.cpp

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/event.h ('k') | fpdfsdk/src/javascript/global.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fpdfsdk/src/javascript/event.h"
8
9 #include "fpdfsdk/include/javascript/IJavaScript.h"
10 #include "fpdfsdk/src/javascript/Field.h"
11 #include "fpdfsdk/src/javascript/JS_Context.h"
12 #include "fpdfsdk/src/javascript/JS_Define.h"
13 #include "fpdfsdk/src/javascript/JS_EventHandler.h"
14 #include "fpdfsdk/src/javascript/JS_Object.h"
15 #include "fpdfsdk/src/javascript/JS_Value.h"
16
17 /* -------------------------- event -------------------------- */
18
19 BEGIN_JS_STATIC_CONST(CJS_Event)
20 END_JS_STATIC_CONST()
21
22 BEGIN_JS_STATIC_PROP(CJS_Event)
23 JS_STATIC_PROP_ENTRY(change)
24 JS_STATIC_PROP_ENTRY(changeEx)
25 JS_STATIC_PROP_ENTRY(commitKey)
26 JS_STATIC_PROP_ENTRY(fieldFull)
27 JS_STATIC_PROP_ENTRY(keyDown)
28 JS_STATIC_PROP_ENTRY(modifier)
29 JS_STATIC_PROP_ENTRY(name)
30 JS_STATIC_PROP_ENTRY(rc)
31 JS_STATIC_PROP_ENTRY(richChange)
32 JS_STATIC_PROP_ENTRY(richChangeEx)
33 JS_STATIC_PROP_ENTRY(richValue)
34 JS_STATIC_PROP_ENTRY(selEnd)
35 JS_STATIC_PROP_ENTRY(selStart)
36 JS_STATIC_PROP_ENTRY(shift)
37 JS_STATIC_PROP_ENTRY(source)
38 JS_STATIC_PROP_ENTRY(target)
39 JS_STATIC_PROP_ENTRY(targetName)
40 JS_STATIC_PROP_ENTRY(type)
41 JS_STATIC_PROP_ENTRY(value)
42 JS_STATIC_PROP_ENTRY(willCommit)
43 END_JS_STATIC_PROP()
44
45 BEGIN_JS_STATIC_METHOD(CJS_Event)
46 END_JS_STATIC_METHOD()
47
48 IMPLEMENT_JS_CLASS(CJS_Event, event)
49
50 event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
51
52 event::~event() {
53 }
54
55 FX_BOOL event::change(IJS_Context* cc,
56 CJS_PropValue& vp,
57 CFX_WideString& sError) {
58 CJS_Context* pContext = (CJS_Context*)cc;
59 CJS_EventHandler* pEvent = pContext->GetEventHandler();
60 CFX_WideString& wChange = pEvent->Change();
61 if (vp.IsSetting()) {
62 if (vp.GetType() == CJS_Value::VT_string)
63 vp >> wChange;
64 } else {
65 vp << wChange;
66 }
67 return TRUE;
68 }
69
70 FX_BOOL event::changeEx(IJS_Context* cc,
71 CJS_PropValue& vp,
72 CFX_WideString& sError) {
73 if (!vp.IsGetting())
74 return FALSE;
75
76 CJS_Context* pContext = (CJS_Context*)cc;
77 CJS_EventHandler* pEvent = pContext->GetEventHandler();
78
79 vp << pEvent->ChangeEx();
80 return TRUE;
81 }
82
83 FX_BOOL event::commitKey(IJS_Context* cc,
84 CJS_PropValue& vp,
85 CFX_WideString& sError) {
86 if (!vp.IsGetting())
87 return FALSE;
88
89 CJS_Context* pContext = (CJS_Context*)cc;
90 CJS_EventHandler* pEvent = pContext->GetEventHandler();
91
92 vp << pEvent->CommitKey();
93 return TRUE;
94 }
95
96 FX_BOOL event::fieldFull(IJS_Context* cc,
97 CJS_PropValue& vp,
98 CFX_WideString& sError) {
99 CJS_Context* pContext = (CJS_Context*)cc;
100 CJS_EventHandler* pEvent = pContext->GetEventHandler();
101
102 if (!vp.IsGetting() &&
103 wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
104 return FALSE;
105
106 if (pEvent->FieldFull())
107 vp << TRUE;
108 else
109 vp << FALSE;
110 return TRUE;
111 }
112
113 FX_BOOL event::keyDown(IJS_Context* cc,
114 CJS_PropValue& vp,
115 CFX_WideString& sError) {
116 if (!vp.IsGetting())
117 return FALSE;
118
119 CJS_Context* pContext = (CJS_Context*)cc;
120 CJS_EventHandler* pEvent = pContext->GetEventHandler();
121
122 if (pEvent->KeyDown())
123 vp << TRUE;
124 else
125 vp << FALSE;
126 return TRUE;
127 }
128
129 FX_BOOL event::modifier(IJS_Context* cc,
130 CJS_PropValue& vp,
131 CFX_WideString& sError) {
132 if (!vp.IsGetting())
133 return FALSE;
134
135 CJS_Context* pContext = (CJS_Context*)cc;
136 CJS_EventHandler* pEvent = pContext->GetEventHandler();
137
138 if (pEvent->Modifier())
139 vp << TRUE;
140 else
141 vp << FALSE;
142 return TRUE;
143 }
144
145 FX_BOOL event::name(IJS_Context* cc,
146 CJS_PropValue& vp,
147 CFX_WideString& sError) {
148 if (!vp.IsGetting())
149 return FALSE;
150
151 CJS_Context* pContext = (CJS_Context*)cc;
152 CJS_EventHandler* pEvent = pContext->GetEventHandler();
153
154 vp << pEvent->Name();
155 return TRUE;
156 }
157
158 FX_BOOL event::rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
159 CJS_Context* pContext = (CJS_Context*)cc;
160 CJS_EventHandler* pEvent = pContext->GetEventHandler();
161
162 FX_BOOL& bRc = pEvent->Rc();
163 if (vp.IsSetting()) {
164 vp >> bRc;
165 } else {
166 vp << bRc;
167 }
168 return TRUE;
169 }
170
171 FX_BOOL event::richChange(IJS_Context* cc,
172 CJS_PropValue& vp,
173 CFX_WideString& sError) {
174 return TRUE;
175 }
176
177 FX_BOOL event::richChangeEx(IJS_Context* cc,
178 CJS_PropValue& vp,
179 CFX_WideString& sError) {
180 return TRUE;
181 }
182
183 FX_BOOL event::richValue(IJS_Context* cc,
184 CJS_PropValue& vp,
185 CFX_WideString& sError) {
186 return TRUE;
187 }
188
189 FX_BOOL event::selEnd(IJS_Context* cc,
190 CJS_PropValue& vp,
191 CFX_WideString& sError) {
192 CJS_Context* pContext = (CJS_Context*)cc;
193 CJS_EventHandler* pEvent = pContext->GetEventHandler();
194
195 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
196 return TRUE;
197 }
198
199 int& iSelEnd = pEvent->SelEnd();
200 if (vp.IsSetting()) {
201 vp >> iSelEnd;
202 } else {
203 vp << iSelEnd;
204 }
205 return TRUE;
206 }
207
208 FX_BOOL event::selStart(IJS_Context* cc,
209 CJS_PropValue& vp,
210 CFX_WideString& sError) {
211 CJS_Context* pContext = (CJS_Context*)cc;
212 CJS_EventHandler* pEvent = pContext->GetEventHandler();
213
214 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
215 return TRUE;
216 }
217 int& iSelStart = pEvent->SelStart();
218 if (vp.IsSetting()) {
219 vp >> iSelStart;
220 } else {
221 vp << iSelStart;
222 }
223 return TRUE;
224 }
225
226 FX_BOOL event::shift(IJS_Context* cc,
227 CJS_PropValue& vp,
228 CFX_WideString& sError) {
229 if (!vp.IsGetting())
230 return FALSE;
231
232 CJS_Context* pContext = (CJS_Context*)cc;
233 CJS_EventHandler* pEvent = pContext->GetEventHandler();
234
235 if (pEvent->Shift())
236 vp << TRUE;
237 else
238 vp << FALSE;
239 return TRUE;
240 }
241
242 FX_BOOL event::source(IJS_Context* cc,
243 CJS_PropValue& vp,
244 CFX_WideString& sError) {
245 if (!vp.IsGetting())
246 return FALSE;
247
248 CJS_Context* pContext = (CJS_Context*)cc;
249 CJS_EventHandler* pEvent = pContext->GetEventHandler();
250
251 vp << pEvent->Source()->GetJSObject();
252 return TRUE;
253 }
254
255 FX_BOOL event::target(IJS_Context* cc,
256 CJS_PropValue& vp,
257 CFX_WideString& sError) {
258 if (!vp.IsGetting())
259 return FALSE;
260
261 CJS_Context* pContext = (CJS_Context*)cc;
262 CJS_EventHandler* pEvent = pContext->GetEventHandler();
263
264 vp << pEvent->Target_Field()->GetJSObject();
265 return TRUE;
266 }
267
268 FX_BOOL event::targetName(IJS_Context* cc,
269 CJS_PropValue& vp,
270 CFX_WideString& sError) {
271 if (!vp.IsGetting())
272 return FALSE;
273
274 CJS_Context* pContext = (CJS_Context*)cc;
275 CJS_EventHandler* pEvent = pContext->GetEventHandler();
276
277 vp << pEvent->TargetName();
278 return TRUE;
279 }
280
281 FX_BOOL event::type(IJS_Context* cc,
282 CJS_PropValue& vp,
283 CFX_WideString& sError) {
284 if (!vp.IsGetting())
285 return FALSE;
286
287 CJS_Context* pContext = (CJS_Context*)cc;
288 CJS_EventHandler* pEvent = pContext->GetEventHandler();
289
290 vp << pEvent->Type();
291 return TRUE;
292 }
293
294 FX_BOOL event::value(IJS_Context* cc,
295 CJS_PropValue& vp,
296 CFX_WideString& sError) {
297 CJS_Context* pContext = (CJS_Context*)cc;
298 CJS_EventHandler* pEvent = pContext->GetEventHandler();
299
300 if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
301 return FALSE;
302 if (!pEvent->m_pValue)
303 return FALSE;
304 CFX_WideString& val = pEvent->Value();
305 if (vp.IsSetting()) {
306 vp >> val;
307 } else {
308 vp << val;
309 }
310 return TRUE;
311 }
312
313 FX_BOOL event::willCommit(IJS_Context* cc,
314 CJS_PropValue& vp,
315 CFX_WideString& sError) {
316 if (!vp.IsGetting())
317 return FALSE;
318
319 CJS_Context* pContext = (CJS_Context*)cc;
320 CJS_EventHandler* pEvent = pContext->GetEventHandler();
321
322 if (pEvent->WillCommit())
323 vp << TRUE;
324 else
325 vp << FALSE;
326 return TRUE;
327 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/event.h ('k') | fpdfsdk/src/javascript/global.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698