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

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

Issue 1395713002: Merge to XFA: Rename IFXJS_Runtime and IFXJS_Context to IJS_. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 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
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "event.h" 7 #include "event.h"
8 8
9 #include "../../include/javascript/IJavaScript.h" 9 #include "../../include/javascript/IJavaScript.h"
10 #include "JS_Define.h" 10 #include "JS_Define.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 BEGIN_JS_STATIC_METHOD(CJS_Event) 45 BEGIN_JS_STATIC_METHOD(CJS_Event)
46 END_JS_STATIC_METHOD() 46 END_JS_STATIC_METHOD()
47 47
48 IMPLEMENT_JS_CLASS(CJS_Event, event) 48 IMPLEMENT_JS_CLASS(CJS_Event, event)
49 49
50 event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {} 50 event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
51 51
52 event::~event() { 52 event::~event() {
53 } 53 }
54 54
55 FX_BOOL event::change(IFXJS_Context* cc, 55 FX_BOOL event::change(IJS_Context* cc,
56 CJS_PropValue& vp, 56 CJS_PropValue& vp,
57 CFX_WideString& sError) { 57 CFX_WideString& sError) {
58 CJS_Context* pContext = (CJS_Context*)cc; 58 CJS_Context* pContext = (CJS_Context*)cc;
59 ASSERT(pContext != NULL); 59 ASSERT(pContext != NULL);
60 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 60 CJS_EventHandler* pEvent = pContext->GetEventHandler();
61 ASSERT(pEvent != NULL); 61 ASSERT(pEvent != NULL);
62 62
63 CFX_WideString& wChange = pEvent->Change(); 63 CFX_WideString& wChange = pEvent->Change();
64 if (vp.IsSetting()) { 64 if (vp.IsSetting()) {
65 if (vp.GetType() == CJS_Value::VT_string) 65 if (vp.GetType() == CJS_Value::VT_string)
66 vp >> wChange; 66 vp >> wChange;
67 } else { 67 } else {
68 vp << wChange; 68 vp << wChange;
69 } 69 }
70 return TRUE; 70 return TRUE;
71 } 71 }
72 72
73 FX_BOOL event::changeEx(IFXJS_Context* cc, 73 FX_BOOL event::changeEx(IJS_Context* cc,
74 CJS_PropValue& vp, 74 CJS_PropValue& vp,
75 CFX_WideString& sError) { 75 CFX_WideString& sError) {
76 if (!vp.IsGetting()) 76 if (!vp.IsGetting())
77 return FALSE; 77 return FALSE;
78 78
79 CJS_Context* pContext = (CJS_Context*)cc; 79 CJS_Context* pContext = (CJS_Context*)cc;
80 ASSERT(pContext != NULL); 80 ASSERT(pContext != NULL);
81 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 81 CJS_EventHandler* pEvent = pContext->GetEventHandler();
82 ASSERT(pEvent != NULL); 82 ASSERT(pEvent != NULL);
83 83
84 vp << pEvent->ChangeEx(); 84 vp << pEvent->ChangeEx();
85 return TRUE; 85 return TRUE;
86 } 86 }
87 87
88 FX_BOOL event::commitKey(IFXJS_Context* cc, 88 FX_BOOL event::commitKey(IJS_Context* cc,
89 CJS_PropValue& vp, 89 CJS_PropValue& vp,
90 CFX_WideString& sError) { 90 CFX_WideString& sError) {
91 if (!vp.IsGetting()) 91 if (!vp.IsGetting())
92 return FALSE; 92 return FALSE;
93 93
94 CJS_Context* pContext = (CJS_Context*)cc; 94 CJS_Context* pContext = (CJS_Context*)cc;
95 ASSERT(pContext != NULL); 95 ASSERT(pContext != NULL);
96 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 96 CJS_EventHandler* pEvent = pContext->GetEventHandler();
97 ASSERT(pEvent != NULL); 97 ASSERT(pEvent != NULL);
98 98
99 vp << pEvent->CommitKey(); 99 vp << pEvent->CommitKey();
100 return TRUE; 100 return TRUE;
101 } 101 }
102 102
103 FX_BOOL event::fieldFull(IFXJS_Context* cc, 103 FX_BOOL event::fieldFull(IJS_Context* cc,
104 CJS_PropValue& vp, 104 CJS_PropValue& vp,
105 CFX_WideString& sError) { 105 CFX_WideString& sError) {
106 CJS_Context* pContext = (CJS_Context*)cc; 106 CJS_Context* pContext = (CJS_Context*)cc;
107 ASSERT(pContext != NULL); 107 ASSERT(pContext != NULL);
108 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 108 CJS_EventHandler* pEvent = pContext->GetEventHandler();
109 ASSERT(pEvent != NULL); 109 ASSERT(pEvent != NULL);
110 110
111 if (!vp.IsGetting() && 111 if (!vp.IsGetting() &&
112 wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) 112 wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
113 return FALSE; 113 return FALSE;
114 114
115 if (pEvent->FieldFull()) 115 if (pEvent->FieldFull())
116 vp << TRUE; 116 vp << TRUE;
117 else 117 else
118 vp << FALSE; 118 vp << FALSE;
119 return TRUE; 119 return TRUE;
120 } 120 }
121 121
122 FX_BOOL event::keyDown(IFXJS_Context* cc, 122 FX_BOOL event::keyDown(IJS_Context* cc,
123 CJS_PropValue& vp, 123 CJS_PropValue& vp,
124 CFX_WideString& sError) { 124 CFX_WideString& sError) {
125 if (!vp.IsGetting()) 125 if (!vp.IsGetting())
126 return FALSE; 126 return FALSE;
127 127
128 CJS_Context* pContext = (CJS_Context*)cc; 128 CJS_Context* pContext = (CJS_Context*)cc;
129 ASSERT(pContext != NULL); 129 ASSERT(pContext != NULL);
130 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 130 CJS_EventHandler* pEvent = pContext->GetEventHandler();
131 ASSERT(pEvent != NULL); 131 ASSERT(pEvent != NULL);
132 132
133 if (pEvent->KeyDown()) 133 if (pEvent->KeyDown())
134 vp << TRUE; 134 vp << TRUE;
135 else 135 else
136 vp << FALSE; 136 vp << FALSE;
137 return TRUE; 137 return TRUE;
138 } 138 }
139 139
140 FX_BOOL event::modifier(IFXJS_Context* cc, 140 FX_BOOL event::modifier(IJS_Context* cc,
141 CJS_PropValue& vp, 141 CJS_PropValue& vp,
142 CFX_WideString& sError) { 142 CFX_WideString& sError) {
143 if (!vp.IsGetting()) 143 if (!vp.IsGetting())
144 return FALSE; 144 return FALSE;
145 145
146 CJS_Context* pContext = (CJS_Context*)cc; 146 CJS_Context* pContext = (CJS_Context*)cc;
147 ASSERT(pContext != NULL); 147 ASSERT(pContext != NULL);
148 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 148 CJS_EventHandler* pEvent = pContext->GetEventHandler();
149 ASSERT(pEvent != NULL); 149 ASSERT(pEvent != NULL);
150 150
151 if (pEvent->Modifier()) 151 if (pEvent->Modifier())
152 vp << TRUE; 152 vp << TRUE;
153 else 153 else
154 vp << FALSE; 154 vp << FALSE;
155 return TRUE; 155 return TRUE;
156 } 156 }
157 157
158 FX_BOOL event::name(IFXJS_Context* cc, 158 FX_BOOL event::name(IJS_Context* cc,
159 CJS_PropValue& vp, 159 CJS_PropValue& vp,
160 CFX_WideString& sError) { 160 CFX_WideString& sError) {
161 if (!vp.IsGetting()) 161 if (!vp.IsGetting())
162 return FALSE; 162 return FALSE;
163 163
164 CJS_Context* pContext = (CJS_Context*)cc; 164 CJS_Context* pContext = (CJS_Context*)cc;
165 ASSERT(pContext != NULL); 165 ASSERT(pContext != NULL);
166 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 166 CJS_EventHandler* pEvent = pContext->GetEventHandler();
167 ASSERT(pEvent != NULL); 167 ASSERT(pEvent != NULL);
168 168
169 vp << pEvent->Name(); 169 vp << pEvent->Name();
170 return TRUE; 170 return TRUE;
171 } 171 }
172 172
173 FX_BOOL event::rc(IFXJS_Context* cc, 173 FX_BOOL event::rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
174 CJS_PropValue& vp,
175 CFX_WideString& sError) {
176 CJS_Context* pContext = (CJS_Context*)cc; 174 CJS_Context* pContext = (CJS_Context*)cc;
177 ASSERT(pContext != NULL); 175 ASSERT(pContext != NULL);
178 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 176 CJS_EventHandler* pEvent = pContext->GetEventHandler();
179 ASSERT(pEvent != NULL); 177 ASSERT(pEvent != NULL);
180 178
181 FX_BOOL& bRc = pEvent->Rc(); 179 FX_BOOL& bRc = pEvent->Rc();
182 if (vp.IsSetting()) { 180 if (vp.IsSetting()) {
183 vp >> bRc; 181 vp >> bRc;
184 } else { 182 } else {
185 vp << bRc; 183 vp << bRc;
186 } 184 }
187 return TRUE; 185 return TRUE;
188 } 186 }
189 187
190 FX_BOOL event::richChange(IFXJS_Context* cc, 188 FX_BOOL event::richChange(IJS_Context* cc,
191 CJS_PropValue& vp, 189 CJS_PropValue& vp,
192 CFX_WideString& sError) { 190 CFX_WideString& sError) {
193 return TRUE; 191 return TRUE;
194 if (vp.IsSetting()) { 192 if (vp.IsSetting()) {
195 } else { 193 } else {
196 ; 194 ;
197 } 195 }
198 return TRUE; 196 return TRUE;
199 } 197 }
200 198
201 FX_BOOL event::richChangeEx(IFXJS_Context* cc, 199 FX_BOOL event::richChangeEx(IJS_Context* cc,
202 CJS_PropValue& vp, 200 CJS_PropValue& vp,
203 CFX_WideString& sError) { 201 CFX_WideString& sError) {
204 return TRUE; 202 return TRUE;
205 if (vp.IsSetting()) { 203 if (vp.IsSetting()) {
206 } else { 204 } else {
207 ; 205 ;
208 } 206 }
209 return TRUE; 207 return TRUE;
210 } 208 }
211 209
212 FX_BOOL event::richValue(IFXJS_Context* cc, 210 FX_BOOL event::richValue(IJS_Context* cc,
213 CJS_PropValue& vp, 211 CJS_PropValue& vp,
214 CFX_WideString& sError) { 212 CFX_WideString& sError) {
215 return TRUE; 213 return TRUE;
216 if (vp.IsSetting()) { 214 if (vp.IsSetting()) {
217 } else { 215 } else {
218 ; 216 ;
219 } 217 }
220 return TRUE; 218 return TRUE;
221 } 219 }
222 220
223 FX_BOOL event::selEnd(IFXJS_Context* cc, 221 FX_BOOL event::selEnd(IJS_Context* cc,
224 CJS_PropValue& vp, 222 CJS_PropValue& vp,
225 CFX_WideString& sError) { 223 CFX_WideString& sError) {
226 CJS_Context* pContext = (CJS_Context*)cc; 224 CJS_Context* pContext = (CJS_Context*)cc;
227 ASSERT(pContext != NULL); 225 ASSERT(pContext != NULL);
228 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 226 CJS_EventHandler* pEvent = pContext->GetEventHandler();
229 ASSERT(pEvent != NULL); 227 ASSERT(pEvent != NULL);
230 228
231 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { 229 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
232 return TRUE; 230 return TRUE;
233 } 231 }
234 232
235 int& iSelEnd = pEvent->SelEnd(); 233 int& iSelEnd = pEvent->SelEnd();
236 if (vp.IsSetting()) { 234 if (vp.IsSetting()) {
237 vp >> iSelEnd; 235 vp >> iSelEnd;
238 } else { 236 } else {
239 vp << iSelEnd; 237 vp << iSelEnd;
240 } 238 }
241 return TRUE; 239 return TRUE;
242 } 240 }
243 241
244 FX_BOOL event::selStart(IFXJS_Context* cc, 242 FX_BOOL event::selStart(IJS_Context* cc,
245 CJS_PropValue& vp, 243 CJS_PropValue& vp,
246 CFX_WideString& sError) { 244 CFX_WideString& sError) {
247 CJS_Context* pContext = (CJS_Context*)cc; 245 CJS_Context* pContext = (CJS_Context*)cc;
248 ASSERT(pContext != NULL); 246 ASSERT(pContext != NULL);
249 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 247 CJS_EventHandler* pEvent = pContext->GetEventHandler();
250 ASSERT(pEvent != NULL); 248 ASSERT(pEvent != NULL);
251 249
252 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { 250 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
253 return TRUE; 251 return TRUE;
254 } 252 }
255 int& iSelStart = pEvent->SelStart(); 253 int& iSelStart = pEvent->SelStart();
256 if (vp.IsSetting()) { 254 if (vp.IsSetting()) {
257 vp >> iSelStart; 255 vp >> iSelStart;
258 } else { 256 } else {
259 vp << iSelStart; 257 vp << iSelStart;
260 } 258 }
261 return TRUE; 259 return TRUE;
262 } 260 }
263 261
264 FX_BOOL event::shift(IFXJS_Context* cc, 262 FX_BOOL event::shift(IJS_Context* cc,
265 CJS_PropValue& vp, 263 CJS_PropValue& vp,
266 CFX_WideString& sError) { 264 CFX_WideString& sError) {
267 if (!vp.IsGetting()) 265 if (!vp.IsGetting())
268 return FALSE; 266 return FALSE;
269 267
270 CJS_Context* pContext = (CJS_Context*)cc; 268 CJS_Context* pContext = (CJS_Context*)cc;
271 ASSERT(pContext != NULL); 269 ASSERT(pContext != NULL);
272 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 270 CJS_EventHandler* pEvent = pContext->GetEventHandler();
273 ASSERT(pEvent != NULL); 271 ASSERT(pEvent != NULL);
274 272
275 if (pEvent->Shift()) 273 if (pEvent->Shift())
276 vp << TRUE; 274 vp << TRUE;
277 else 275 else
278 vp << FALSE; 276 vp << FALSE;
279 return TRUE; 277 return TRUE;
280 } 278 }
281 279
282 FX_BOOL event::source(IFXJS_Context* cc, 280 FX_BOOL event::source(IJS_Context* cc,
283 CJS_PropValue& vp, 281 CJS_PropValue& vp,
284 CFX_WideString& sError) { 282 CFX_WideString& sError) {
285 if (!vp.IsGetting()) 283 if (!vp.IsGetting())
286 return FALSE; 284 return FALSE;
287 285
288 CJS_Context* pContext = (CJS_Context*)cc; 286 CJS_Context* pContext = (CJS_Context*)cc;
289 ASSERT(pContext != NULL); 287 ASSERT(pContext != NULL);
290 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 288 CJS_EventHandler* pEvent = pContext->GetEventHandler();
291 ASSERT(pEvent != NULL); 289 ASSERT(pEvent != NULL);
292 290
293 vp << pEvent->Source()->GetJSObject(); 291 vp << pEvent->Source()->GetJSObject();
294 return TRUE; 292 return TRUE;
295 } 293 }
296 294
297 FX_BOOL event::target(IFXJS_Context* cc, 295 FX_BOOL event::target(IJS_Context* cc,
298 CJS_PropValue& vp, 296 CJS_PropValue& vp,
299 CFX_WideString& sError) { 297 CFX_WideString& sError) {
300 if (!vp.IsGetting()) 298 if (!vp.IsGetting())
301 return FALSE; 299 return FALSE;
302 300
303 CJS_Context* pContext = (CJS_Context*)cc; 301 CJS_Context* pContext = (CJS_Context*)cc;
304 ASSERT(pContext != NULL); 302 ASSERT(pContext != NULL);
305 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 303 CJS_EventHandler* pEvent = pContext->GetEventHandler();
306 ASSERT(pEvent != NULL); 304 ASSERT(pEvent != NULL);
307 305
308 vp << pEvent->Target_Field()->GetJSObject(); 306 vp << pEvent->Target_Field()->GetJSObject();
309 return TRUE; 307 return TRUE;
310 } 308 }
311 309
312 FX_BOOL event::targetName(IFXJS_Context* cc, 310 FX_BOOL event::targetName(IJS_Context* cc,
313 CJS_PropValue& vp, 311 CJS_PropValue& vp,
314 CFX_WideString& sError) { 312 CFX_WideString& sError) {
315 if (!vp.IsGetting()) 313 if (!vp.IsGetting())
316 return FALSE; 314 return FALSE;
317 315
318 CJS_Context* pContext = (CJS_Context*)cc; 316 CJS_Context* pContext = (CJS_Context*)cc;
319 ASSERT(pContext != NULL); 317 ASSERT(pContext != NULL);
320 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 318 CJS_EventHandler* pEvent = pContext->GetEventHandler();
321 ASSERT(pEvent != NULL); 319 ASSERT(pEvent != NULL);
322 320
323 vp << pEvent->TargetName(); 321 vp << pEvent->TargetName();
324 return TRUE; 322 return TRUE;
325 } 323 }
326 324
327 FX_BOOL event::type(IFXJS_Context* cc, 325 FX_BOOL event::type(IJS_Context* cc,
328 CJS_PropValue& vp, 326 CJS_PropValue& vp,
329 CFX_WideString& sError) { 327 CFX_WideString& sError) {
330 if (!vp.IsGetting()) 328 if (!vp.IsGetting())
331 return FALSE; 329 return FALSE;
332 330
333 CJS_Context* pContext = (CJS_Context*)cc; 331 CJS_Context* pContext = (CJS_Context*)cc;
334 ASSERT(pContext != NULL); 332 ASSERT(pContext != NULL);
335 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 333 CJS_EventHandler* pEvent = pContext->GetEventHandler();
336 ASSERT(pEvent != NULL); 334 ASSERT(pEvent != NULL);
337 335
338 vp << pEvent->Type(); 336 vp << pEvent->Type();
339 return TRUE; 337 return TRUE;
340 } 338 }
341 339
342 FX_BOOL event::value(IFXJS_Context* cc, 340 FX_BOOL event::value(IJS_Context* cc,
343 CJS_PropValue& vp, 341 CJS_PropValue& vp,
344 CFX_WideString& sError) { 342 CFX_WideString& sError) {
345 CJS_Context* pContext = (CJS_Context*)cc; 343 CJS_Context* pContext = (CJS_Context*)cc;
346 ASSERT(pContext != NULL); 344 ASSERT(pContext != NULL);
347 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 345 CJS_EventHandler* pEvent = pContext->GetEventHandler();
348 ASSERT(pEvent != NULL); 346 ASSERT(pEvent != NULL);
349 347
350 if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) 348 if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
351 return FALSE; 349 return FALSE;
352 if (!pEvent->m_pValue) 350 if (!pEvent->m_pValue)
353 return FALSE; 351 return FALSE;
354 CFX_WideString& val = pEvent->Value(); 352 CFX_WideString& val = pEvent->Value();
355 if (vp.IsSetting()) { 353 if (vp.IsSetting()) {
356 vp >> val; 354 vp >> val;
357 } else { 355 } else {
358 vp << val; 356 vp << val;
359 } 357 }
360 return TRUE; 358 return TRUE;
361 } 359 }
362 360
363 FX_BOOL event::willCommit(IFXJS_Context* cc, 361 FX_BOOL event::willCommit(IJS_Context* cc,
364 CJS_PropValue& vp, 362 CJS_PropValue& vp,
365 CFX_WideString& sError) { 363 CFX_WideString& sError) {
366 if (!vp.IsGetting()) 364 if (!vp.IsGetting())
367 return FALSE; 365 return FALSE;
368 366
369 CJS_Context* pContext = (CJS_Context*)cc; 367 CJS_Context* pContext = (CJS_Context*)cc;
370 ASSERT(pContext != NULL); 368 ASSERT(pContext != NULL);
371 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 369 CJS_EventHandler* pEvent = pContext->GetEventHandler();
372 ASSERT(pEvent != NULL); 370 ASSERT(pEvent != NULL);
373 371
374 if (pEvent->WillCommit()) 372 if (pEvent->WillCommit())
375 vp << TRUE; 373 vp << TRUE;
376 else 374 else
377 vp << FALSE; 375 vp << FALSE;
378 return TRUE; 376 return TRUE;
379 } 377 }
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