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

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

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month 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/javascript/event.h ('k') | fpdfsdk/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 "fpdfsdk/javascript/event.h" 7 #include "fpdfsdk/javascript/event.h"
8 8
9 #include "fpdfsdk/javascript/Field.h" 9 #include "fpdfsdk/javascript/Field.h"
10 #include "fpdfsdk/javascript/JS_Define.h" 10 #include "fpdfsdk/javascript/JS_Define.h"
(...skipping 30 matching lines...) Expand all
41 41
42 BEGIN_JS_STATIC_METHOD(CJS_Event) 42 BEGIN_JS_STATIC_METHOD(CJS_Event)
43 END_JS_STATIC_METHOD() 43 END_JS_STATIC_METHOD()
44 44
45 IMPLEMENT_JS_CLASS(CJS_Event, event) 45 IMPLEMENT_JS_CLASS(CJS_Event, event)
46 46
47 event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {} 47 event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
48 48
49 event::~event() {} 49 event::~event() {}
50 50
51 FX_BOOL event::change(IJS_Context* cc, 51 bool event::change(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
52 CJS_PropValue& vp,
53 CFX_WideString& sError) {
54 CJS_Context* pContext = (CJS_Context*)cc; 52 CJS_Context* pContext = (CJS_Context*)cc;
55 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 53 CJS_EventHandler* pEvent = pContext->GetEventHandler();
56 CFX_WideString& wChange = pEvent->Change(); 54 CFX_WideString& wChange = pEvent->Change();
57 if (vp.IsSetting()) { 55 if (vp.IsSetting()) {
58 if (vp.GetJSValue()->GetType() == CJS_Value::VT_string) 56 if (vp.GetJSValue()->GetType() == CJS_Value::VT_string)
59 vp >> wChange; 57 vp >> wChange;
60 } else { 58 } else {
61 vp << wChange; 59 vp << wChange;
62 } 60 }
63 return TRUE; 61 return true;
64 } 62 }
65 63
66 FX_BOOL event::changeEx(IJS_Context* cc, 64 bool event::changeEx(IJS_Context* cc,
67 CJS_PropValue& vp, 65 CJS_PropValue& vp,
68 CFX_WideString& sError) { 66 CFX_WideString& sError) {
69 if (!vp.IsGetting()) 67 if (!vp.IsGetting())
70 return FALSE; 68 return false;
71 69
72 CJS_Context* pContext = (CJS_Context*)cc; 70 CJS_Context* pContext = (CJS_Context*)cc;
73 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 71 CJS_EventHandler* pEvent = pContext->GetEventHandler();
74 72
75 vp << pEvent->ChangeEx(); 73 vp << pEvent->ChangeEx();
76 return TRUE; 74 return true;
77 } 75 }
78 76
79 FX_BOOL event::commitKey(IJS_Context* cc, 77 bool event::commitKey(IJS_Context* cc,
80 CJS_PropValue& vp, 78 CJS_PropValue& vp,
81 CFX_WideString& sError) { 79 CFX_WideString& sError) {
82 if (!vp.IsGetting()) 80 if (!vp.IsGetting())
83 return FALSE; 81 return false;
84 82
85 CJS_Context* pContext = (CJS_Context*)cc; 83 CJS_Context* pContext = (CJS_Context*)cc;
86 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 84 CJS_EventHandler* pEvent = pContext->GetEventHandler();
87 85
88 vp << pEvent->CommitKey(); 86 vp << pEvent->CommitKey();
89 return TRUE; 87 return true;
90 } 88 }
91 89
92 FX_BOOL event::fieldFull(IJS_Context* cc, 90 bool event::fieldFull(IJS_Context* cc,
93 CJS_PropValue& vp, 91 CJS_PropValue& vp,
94 CFX_WideString& sError) { 92 CFX_WideString& sError) {
95 CJS_Context* pContext = (CJS_Context*)cc; 93 CJS_Context* pContext = (CJS_Context*)cc;
96 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 94 CJS_EventHandler* pEvent = pContext->GetEventHandler();
97 95
98 if (!vp.IsGetting() && 96 if (!vp.IsGetting() &&
99 wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) 97 wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
100 return FALSE; 98 return false;
101 99
102 if (pEvent->FieldFull()) 100 if (pEvent->FieldFull())
103 vp << TRUE; 101 vp << true;
104 else 102 else
105 vp << FALSE; 103 vp << false;
106 return TRUE; 104 return true;
107 } 105 }
108 106
109 FX_BOOL event::keyDown(IJS_Context* cc, 107 bool event::keyDown(IJS_Context* cc,
110 CJS_PropValue& vp, 108 CJS_PropValue& vp,
111 CFX_WideString& sError) { 109 CFX_WideString& sError) {
112 if (!vp.IsGetting()) 110 if (!vp.IsGetting())
113 return FALSE; 111 return false;
114 112
115 CJS_Context* pContext = (CJS_Context*)cc; 113 CJS_Context* pContext = (CJS_Context*)cc;
116 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 114 CJS_EventHandler* pEvent = pContext->GetEventHandler();
117 115
118 if (pEvent->KeyDown()) 116 if (pEvent->KeyDown())
119 vp << TRUE; 117 vp << true;
120 else 118 else
121 vp << FALSE; 119 vp << false;
122 return TRUE; 120 return true;
123 } 121 }
124 122
125 FX_BOOL event::modifier(IJS_Context* cc, 123 bool event::modifier(IJS_Context* cc,
126 CJS_PropValue& vp, 124 CJS_PropValue& vp,
127 CFX_WideString& sError) { 125 CFX_WideString& sError) {
128 if (!vp.IsGetting()) 126 if (!vp.IsGetting())
129 return FALSE; 127 return false;
130 128
131 CJS_Context* pContext = (CJS_Context*)cc; 129 CJS_Context* pContext = (CJS_Context*)cc;
132 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 130 CJS_EventHandler* pEvent = pContext->GetEventHandler();
133 131
134 if (pEvent->Modifier()) 132 if (pEvent->Modifier())
135 vp << TRUE; 133 vp << true;
136 else 134 else
137 vp << FALSE; 135 vp << false;
138 return TRUE; 136 return true;
139 } 137 }
140 138
141 FX_BOOL event::name(IJS_Context* cc, 139 bool event::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
142 CJS_PropValue& vp,
143 CFX_WideString& sError) {
144 if (!vp.IsGetting()) 140 if (!vp.IsGetting())
145 return FALSE; 141 return false;
146 142
147 CJS_Context* pContext = (CJS_Context*)cc; 143 CJS_Context* pContext = (CJS_Context*)cc;
148 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 144 CJS_EventHandler* pEvent = pContext->GetEventHandler();
149 145
150 vp << pEvent->Name(); 146 vp << pEvent->Name();
151 return TRUE; 147 return true;
152 } 148 }
153 149
154 FX_BOOL event::rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { 150 bool event::rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
155 CJS_Context* pContext = (CJS_Context*)cc; 151 CJS_Context* pContext = (CJS_Context*)cc;
156 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 152 CJS_EventHandler* pEvent = pContext->GetEventHandler();
157 153
158 FX_BOOL& bRc = pEvent->Rc(); 154 bool& bRc = pEvent->Rc();
159 if (vp.IsSetting()) { 155 if (vp.IsSetting()) {
160 vp >> bRc; 156 vp >> bRc;
161 } else { 157 } else {
162 vp << bRc; 158 vp << bRc;
163 } 159 }
164 return TRUE; 160 return true;
165 } 161 }
166 162
167 FX_BOOL event::richChange(IJS_Context* cc, 163 bool event::richChange(IJS_Context* cc,
168 CJS_PropValue& vp, 164 CJS_PropValue& vp,
169 CFX_WideString& sError) { 165 CFX_WideString& sError) {
170 return TRUE; 166 return true;
171 } 167 }
172 168
173 FX_BOOL event::richChangeEx(IJS_Context* cc, 169 bool event::richChangeEx(IJS_Context* cc,
174 CJS_PropValue& vp, 170 CJS_PropValue& vp,
175 CFX_WideString& sError) { 171 CFX_WideString& sError) {
176 return TRUE; 172 return true;
177 } 173 }
178 174
179 FX_BOOL event::richValue(IJS_Context* cc, 175 bool event::richValue(IJS_Context* cc,
180 CJS_PropValue& vp, 176 CJS_PropValue& vp,
181 CFX_WideString& sError) { 177 CFX_WideString& sError) {
182 return TRUE; 178 return true;
183 } 179 }
184 180
185 FX_BOOL event::selEnd(IJS_Context* cc, 181 bool event::selEnd(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
186 CJS_PropValue& vp,
187 CFX_WideString& sError) {
188 CJS_Context* pContext = (CJS_Context*)cc; 182 CJS_Context* pContext = (CJS_Context*)cc;
189 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 183 CJS_EventHandler* pEvent = pContext->GetEventHandler();
190 184
191 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { 185 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
192 return TRUE; 186 return true;
193 } 187 }
194 188
195 int& iSelEnd = pEvent->SelEnd(); 189 int& iSelEnd = pEvent->SelEnd();
196 if (vp.IsSetting()) { 190 if (vp.IsSetting()) {
197 vp >> iSelEnd; 191 vp >> iSelEnd;
198 } else { 192 } else {
199 vp << iSelEnd; 193 vp << iSelEnd;
200 } 194 }
201 return TRUE; 195 return true;
202 } 196 }
203 197
204 FX_BOOL event::selStart(IJS_Context* cc, 198 bool event::selStart(IJS_Context* cc,
205 CJS_PropValue& vp, 199 CJS_PropValue& vp,
206 CFX_WideString& sError) { 200 CFX_WideString& sError) {
207 CJS_Context* pContext = (CJS_Context*)cc; 201 CJS_Context* pContext = (CJS_Context*)cc;
208 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 202 CJS_EventHandler* pEvent = pContext->GetEventHandler();
209 203
210 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) { 204 if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
211 return TRUE; 205 return true;
212 } 206 }
213 int& iSelStart = pEvent->SelStart(); 207 int& iSelStart = pEvent->SelStart();
214 if (vp.IsSetting()) { 208 if (vp.IsSetting()) {
215 vp >> iSelStart; 209 vp >> iSelStart;
216 } else { 210 } else {
217 vp << iSelStart; 211 vp << iSelStart;
218 } 212 }
219 return TRUE; 213 return true;
220 } 214 }
221 215
222 FX_BOOL event::shift(IJS_Context* cc, 216 bool event::shift(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
223 CJS_PropValue& vp,
224 CFX_WideString& sError) {
225 if (!vp.IsGetting()) 217 if (!vp.IsGetting())
226 return FALSE; 218 return false;
227 219
228 CJS_Context* pContext = (CJS_Context*)cc; 220 CJS_Context* pContext = (CJS_Context*)cc;
229 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 221 CJS_EventHandler* pEvent = pContext->GetEventHandler();
230 222
231 if (pEvent->Shift()) 223 if (pEvent->Shift())
232 vp << TRUE; 224 vp << true;
233 else 225 else
234 vp << FALSE; 226 vp << false;
235 return TRUE; 227 return true;
236 } 228 }
237 229
238 FX_BOOL event::source(IJS_Context* cc, 230 bool event::source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
239 CJS_PropValue& vp,
240 CFX_WideString& sError) {
241 if (!vp.IsGetting()) 231 if (!vp.IsGetting())
242 return FALSE; 232 return false;
243 233
244 CJS_Context* pContext = (CJS_Context*)cc; 234 CJS_Context* pContext = (CJS_Context*)cc;
245 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 235 CJS_EventHandler* pEvent = pContext->GetEventHandler();
246 236
247 vp << pEvent->Source()->GetJSObject(); 237 vp << pEvent->Source()->GetJSObject();
248 return TRUE; 238 return true;
249 } 239 }
250 240
251 FX_BOOL event::target(IJS_Context* cc, 241 bool event::target(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
252 CJS_PropValue& vp,
253 CFX_WideString& sError) {
254 if (!vp.IsGetting()) 242 if (!vp.IsGetting())
255 return FALSE; 243 return false;
256 244
257 CJS_Context* pContext = (CJS_Context*)cc; 245 CJS_Context* pContext = (CJS_Context*)cc;
258 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 246 CJS_EventHandler* pEvent = pContext->GetEventHandler();
259 247
260 vp << pEvent->Target_Field()->GetJSObject(); 248 vp << pEvent->Target_Field()->GetJSObject();
261 return TRUE; 249 return true;
262 } 250 }
263 251
264 FX_BOOL event::targetName(IJS_Context* cc, 252 bool event::targetName(IJS_Context* cc,
265 CJS_PropValue& vp, 253 CJS_PropValue& vp,
266 CFX_WideString& sError) { 254 CFX_WideString& sError) {
267 if (!vp.IsGetting()) 255 if (!vp.IsGetting())
268 return FALSE; 256 return false;
269 257
270 CJS_Context* pContext = (CJS_Context*)cc; 258 CJS_Context* pContext = (CJS_Context*)cc;
271 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 259 CJS_EventHandler* pEvent = pContext->GetEventHandler();
272 260
273 vp << pEvent->TargetName(); 261 vp << pEvent->TargetName();
274 return TRUE; 262 return true;
275 } 263 }
276 264
277 FX_BOOL event::type(IJS_Context* cc, 265 bool event::type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
278 CJS_PropValue& vp,
279 CFX_WideString& sError) {
280 if (!vp.IsGetting()) 266 if (!vp.IsGetting())
281 return FALSE; 267 return false;
282 268
283 CJS_Context* pContext = (CJS_Context*)cc; 269 CJS_Context* pContext = (CJS_Context*)cc;
284 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 270 CJS_EventHandler* pEvent = pContext->GetEventHandler();
285 271
286 vp << pEvent->Type(); 272 vp << pEvent->Type();
287 return TRUE; 273 return true;
288 } 274 }
289 275
290 FX_BOOL event::value(IJS_Context* cc, 276 bool event::value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
291 CJS_PropValue& vp,
292 CFX_WideString& sError) {
293 CJS_Context* pContext = (CJS_Context*)cc; 277 CJS_Context* pContext = (CJS_Context*)cc;
294 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 278 CJS_EventHandler* pEvent = pContext->GetEventHandler();
295 279
296 if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) 280 if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
297 return FALSE; 281 return false;
298 if (!pEvent->m_pValue) 282 if (!pEvent->m_pValue)
299 return FALSE; 283 return false;
300 CFX_WideString& val = pEvent->Value(); 284 CFX_WideString& val = pEvent->Value();
301 if (vp.IsSetting()) { 285 if (vp.IsSetting()) {
302 vp >> val; 286 vp >> val;
303 } else { 287 } else {
304 vp << val; 288 vp << val;
305 } 289 }
306 return TRUE; 290 return true;
307 } 291 }
308 292
309 FX_BOOL event::willCommit(IJS_Context* cc, 293 bool event::willCommit(IJS_Context* cc,
310 CJS_PropValue& vp, 294 CJS_PropValue& vp,
311 CFX_WideString& sError) { 295 CFX_WideString& sError) {
312 if (!vp.IsGetting()) 296 if (!vp.IsGetting())
313 return FALSE; 297 return false;
314 298
315 CJS_Context* pContext = (CJS_Context*)cc; 299 CJS_Context* pContext = (CJS_Context*)cc;
316 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 300 CJS_EventHandler* pEvent = pContext->GetEventHandler();
317 301
318 if (pEvent->WillCommit()) 302 if (pEvent->WillCommit())
319 vp << TRUE; 303 vp << true;
320 else 304 else
321 vp << FALSE; 305 vp << false;
322 return TRUE; 306 return true;
323 } 307 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/event.h ('k') | fpdfsdk/javascript/global.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698