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