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

Side by Side Diff: xfa/fxfa/parser/xfa_script_imp.cpp

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. Created 4 years, 8 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
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 "xfa/fxfa/parser/xfa_script_imp.h" 7 #include "xfa/fxfa/parser/xfa_script_imp.h"
8 8
9 #include "core/fxcrt/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fxfa/app/xfa_ffnotify.h" 10 #include "xfa/fxfa/app/xfa_ffnotify.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 (CXFA_ScriptContext*)pDoc->GetScriptContext(); 116 (CXFA_ScriptContext*)pDoc->GetScriptContext();
117 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode); 117 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode);
118 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 118 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
119 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings | 119 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings |
120 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 120 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
121 XFA_RESOLVENODE_Attributes; 121 XFA_RESOLVENODE_Attributes;
122 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 122 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
123 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 123 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
124 pRefNode = ToNode(lpCurNode); 124 pRefNode = ToNode(lpCurNode);
125 } 125 }
126 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsWideStringC(), 126 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), hValue,
127 hValue, dwFlag, TRUE)) { 127 dwFlag, TRUE)) {
128 return; 128 return;
129 } 129 }
130 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 130 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
131 if (FXJSE_Value_IsUndefined(hValue)) { 131 if (FXJSE_Value_IsUndefined(hValue)) {
132 FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue); 132 FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue);
133 return; 133 return;
134 } 134 }
135 } 135 }
136 CXFA_FFNotify* pNotify = pDoc->GetNotify(); 136 CXFA_FFNotify* pNotify = pDoc->GetNotify();
137 if (!pNotify) { 137 if (!pNotify) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return; 189 return;
190 } 190 }
191 } 191 }
192 } 192 }
193 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 193 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
194 XFA_RESOLVENODE_Attributes; 194 XFA_RESOLVENODE_Attributes;
195 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 195 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
196 if (pOrginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 196 if (pOrginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
197 pRefNode = ToNode(lpCurNode); 197 pRefNode = ToNode(lpCurNode);
198 } 198 }
199 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsWideStringC(), 199 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), hValue,
200 hValue, dwFlag, FALSE)) { 200 dwFlag, FALSE)) {
201 return; 201 return;
202 } 202 }
203 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; 203 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
204 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsWideStringC(), 204 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), hValue,
205 hValue, dwFlag, FALSE)) { 205 dwFlag, FALSE)) {
206 return; 206 return;
207 } 207 }
208 CXFA_Object* pScriptObject = 208 CXFA_Object* pScriptObject =
209 lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); 209 lpScriptContext->GetVariablesThis(pOrginalObject, TRUE);
210 if (pScriptObject && 210 if (pScriptObject &&
211 lpScriptContext->QueryVariableHValue(pScriptObject->AsNode(), szPropName, 211 lpScriptContext->QueryVariableHValue(pScriptObject->AsNode(), szPropName,
212 hValue, TRUE)) { 212 hValue, TRUE)) {
213 return; 213 return;
214 } 214 }
215 CXFA_FFNotify* pNotify = pDoc->GetNotify(); 215 CXFA_FFNotify* pNotify = pDoc->GetNotify();
(...skipping 18 matching lines...) Expand all
234 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); 234 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject);
235 if (wsPropName == FX_WSTRC(L"xfa")) { 235 if (wsPropName == FX_WSTRC(L"xfa")) {
236 FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap( 236 FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap(
237 lpScriptContext->GetDocument()->GetRoot()); 237 lpScriptContext->GetDocument()->GetRoot());
238 FXJSE_Value_Set(hValue, pValue); 238 FXJSE_Value_Set(hValue, pValue);
239 return; 239 return;
240 } 240 }
241 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 241 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
242 XFA_RESOLVENODE_Attributes; 242 XFA_RESOLVENODE_Attributes;
243 FX_BOOL bRet = lpScriptContext->QueryNodeByFlag( 243 FX_BOOL bRet = lpScriptContext->QueryNodeByFlag(
244 ToNode(pObject), wsPropName.AsWideStringC(), hValue, dwFlag, FALSE); 244 ToNode(pObject), wsPropName.AsStringC(), hValue, dwFlag, FALSE);
245 if (bRet) { 245 if (bRet) {
246 return; 246 return;
247 } 247 }
248 if (pObject == lpScriptContext->GetThisObject() || 248 if (pObject == lpScriptContext->GetThisObject() ||
249 (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript && 249 (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript &&
250 !lpScriptContext->IsStrictScopeInJavaScript())) { 250 !lpScriptContext->IsStrictScopeInJavaScript())) {
251 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; 251 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
252 bRet = lpScriptContext->QueryNodeByFlag( 252 bRet = lpScriptContext->QueryNodeByFlag(
253 ToNode(pObject), wsPropName.AsWideStringC(), hValue, dwFlag, FALSE); 253 ToNode(pObject), wsPropName.AsStringC(), hValue, dwFlag, FALSE);
254 } 254 }
255 if (bRet) { 255 if (bRet) {
256 return; 256 return;
257 } 257 }
258 CXFA_Object* pScriptObject = 258 CXFA_Object* pScriptObject =
259 lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); 259 lpScriptContext->GetVariablesThis(pOrginalObject, TRUE);
260 if (pScriptObject) { 260 if (pScriptObject) {
261 bRet = lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), 261 bRet = lpScriptContext->QueryVariableHValue(ToNode(pScriptObject),
262 szPropName, hValue, TRUE); 262 szPropName, hValue, TRUE);
263 } 263 }
264 if (!bRet) { 264 if (!bRet) {
265 FXJSE_Value_SetUndefined(hValue); 265 FXJSE_Value_SetUndefined(hValue);
266 } 266 }
267 } 267 }
268 void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject, 268 void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject,
269 const CFX_ByteStringC& szPropName, 269 const CFX_ByteStringC& szPropName,
270 FXJSE_HVALUE hValue) { 270 FXJSE_HVALUE hValue) {
271 CXFA_Object* pOrginalObject = 271 CXFA_Object* pOrginalObject =
272 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); 272 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
273 if (pOrginalObject == NULL) { 273 if (pOrginalObject == NULL) {
274 return; 274 return;
275 } 275 }
276 CXFA_ScriptContext* lpScriptContext = 276 CXFA_ScriptContext* lpScriptContext =
277 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); 277 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext();
278 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); 278 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject);
279 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 279 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
280 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = XFA_GetScriptAttributeByName( 280 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = XFA_GetScriptAttributeByName(
281 pObject->GetClassID(), wsPropName.AsWideStringC()); 281 pObject->GetClassID(), wsPropName.AsStringC());
282 if (lpAttributeInfo) { 282 if (lpAttributeInfo) {
283 (pObject->*(lpAttributeInfo->lpfnCallback))( 283 (pObject->*(lpAttributeInfo->lpfnCallback))(
284 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); 284 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
285 } else { 285 } else {
286 if (pObject->IsNode()) { 286 if (pObject->IsNode()) {
287 if (wsPropName.GetAt(0) == '#') { 287 if (wsPropName.GetAt(0) == '#') {
288 wsPropName = wsPropName.Right(wsPropName.GetLength() - 1); 288 wsPropName = wsPropName.Right(wsPropName.GetLength() - 1);
289 } 289 }
290 CXFA_Node* pNode = ToNode(pObject); 290 CXFA_Node* pNode = ToNode(pObject);
291 CXFA_Node* pPropOrChild = NULL; 291 CXFA_Node* pPropOrChild = NULL;
292 const XFA_ELEMENTINFO* lpElementInfo = 292 const XFA_ELEMENTINFO* lpElementInfo =
293 XFA_GetElementByName(wsPropName.AsWideStringC()); 293 XFA_GetElementByName(wsPropName.AsStringC());
294 if (lpElementInfo) { 294 if (lpElementInfo) {
295 pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName); 295 pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName);
296 } else { 296 } else {
297 pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsWideStringC()); 297 pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsStringC());
298 } 298 }
299 if (pPropOrChild) { 299 if (pPropOrChild) {
300 CFX_WideString wsDefaultName = FX_WSTRC(L"{default}"); 300 CFX_WideString wsDefaultName = FX_WSTRC(L"{default}");
301 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = 301 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
302 XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(), 302 XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(),
303 wsDefaultName.AsWideStringC()); 303 wsDefaultName.AsStringC());
304 if (lpAttributeInfo) { 304 if (lpAttributeInfo) {
305 (pPropOrChild->*(lpAttributeInfo->lpfnCallback))( 305 (pPropOrChild->*(lpAttributeInfo->lpfnCallback))(
306 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); 306 hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
307 return; 307 return;
308 } 308 }
309 } 309 }
310 } 310 }
311 CXFA_Object* pScriptObject = 311 CXFA_Object* pScriptObject =
312 lpScriptContext->GetVariablesThis(pOrginalObject, TRUE); 312 lpScriptContext->GetVariablesThis(pOrginalObject, TRUE);
313 if (pScriptObject) { 313 if (pScriptObject) {
314 lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), szPropName, 314 lpScriptContext->QueryVariableHValue(ToNode(pScriptObject), szPropName,
315 hValue, FALSE); 315 hValue, FALSE);
316 } 316 }
317 } 317 }
318 } 318 }
319 int32_t CXFA_ScriptContext::NormalPropTypeGetter( 319 int32_t CXFA_ScriptContext::NormalPropTypeGetter(
320 FXJSE_HOBJECT hObject, 320 FXJSE_HOBJECT hObject,
321 const CFX_ByteStringC& szPropName, 321 const CFX_ByteStringC& szPropName,
322 FX_BOOL bQueryIn) { 322 FX_BOOL bQueryIn) {
323 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); 323 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
324 if (pObject == NULL) { 324 if (pObject == NULL) {
325 return FXJSE_ClassPropType_None; 325 return FXJSE_ClassPropType_None;
326 } 326 }
327 CXFA_ScriptContext* lpScriptContext = 327 CXFA_ScriptContext* lpScriptContext =
328 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); 328 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
329 pObject = lpScriptContext->GetVariablesThis(pObject); 329 pObject = lpScriptContext->GetVariablesThis(pObject);
330 XFA_ELEMENT objElement = pObject->GetClassID(); 330 XFA_ELEMENT objElement = pObject->GetClassID();
331 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 331 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
332 if (XFA_GetMethodByName(objElement, wsPropName.AsWideStringC())) { 332 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
333 return FXJSE_ClassPropType_Method; 333 return FXJSE_ClassPropType_Method;
334 } 334 }
335 if (bQueryIn && 335 if (bQueryIn &&
336 !XFA_GetScriptAttributeByName(objElement, wsPropName.AsWideStringC())) { 336 !XFA_GetScriptAttributeByName(objElement, wsPropName.AsStringC())) {
337 return FXJSE_ClassPropType_None; 337 return FXJSE_ClassPropType_None;
338 } 338 }
339 return FXJSE_ClassPropType_Property; 339 return FXJSE_ClassPropType_Property;
340 } 340 }
341 int32_t CXFA_ScriptContext::GlobalPropTypeGetter( 341 int32_t CXFA_ScriptContext::GlobalPropTypeGetter(
342 FXJSE_HOBJECT hObject, 342 FXJSE_HOBJECT hObject,
343 const CFX_ByteStringC& szPropName, 343 const CFX_ByteStringC& szPropName,
344 FX_BOOL bQueryIn) { 344 FX_BOOL bQueryIn) {
345 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); 345 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
346 if (pObject == NULL) { 346 if (pObject == NULL) {
347 return FXJSE_ClassPropType_None; 347 return FXJSE_ClassPropType_None;
348 } 348 }
349 CXFA_ScriptContext* lpScriptContext = 349 CXFA_ScriptContext* lpScriptContext =
350 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); 350 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
351 pObject = lpScriptContext->GetVariablesThis(pObject); 351 pObject = lpScriptContext->GetVariablesThis(pObject);
352 XFA_ELEMENT objElement = pObject->GetClassID(); 352 XFA_ELEMENT objElement = pObject->GetClassID();
353 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 353 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
354 if (XFA_GetMethodByName(objElement, wsPropName.AsWideStringC())) { 354 if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
355 return FXJSE_ClassPropType_Method; 355 return FXJSE_ClassPropType_Method;
356 } 356 }
357 return FXJSE_ClassPropType_Property; 357 return FXJSE_ClassPropType_Property;
358 } 358 }
359 void CXFA_ScriptContext::NormalMethodCall(FXJSE_HOBJECT hThis, 359 void CXFA_ScriptContext::NormalMethodCall(FXJSE_HOBJECT hThis,
360 const CFX_ByteStringC& szFuncName, 360 const CFX_ByteStringC& szFuncName,
361 CFXJSE_Arguments& args) { 361 CFXJSE_Arguments& args) {
362 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis, NULL); 362 CXFA_Object* pObject = (CXFA_Object*)FXJSE_Value_ToObject(hThis, NULL);
363 if (pObject == NULL) { 363 if (pObject == NULL) {
364 return; 364 return;
365 } 365 }
366 CXFA_ScriptContext* lpScriptContext = 366 CXFA_ScriptContext* lpScriptContext =
367 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext(); 367 (CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
368 pObject = lpScriptContext->GetVariablesThis(pObject); 368 pObject = lpScriptContext->GetVariablesThis(pObject);
369 CFX_WideString wsFunName = CFX_WideString::FromUTF8(szFuncName); 369 CFX_WideString wsFunName = CFX_WideString::FromUTF8(szFuncName);
370 const XFA_METHODINFO* lpMethodInfo = 370 const XFA_METHODINFO* lpMethodInfo =
371 XFA_GetMethodByName(pObject->GetClassID(), wsFunName.AsWideStringC()); 371 XFA_GetMethodByName(pObject->GetClassID(), wsFunName.AsStringC());
372 if (NULL == lpMethodInfo) { 372 if (NULL == lpMethodInfo) {
373 return; 373 return;
374 } 374 }
375 (pObject->*(lpMethodInfo->lpfnCallback))(&args); 375 (pObject->*(lpMethodInfo->lpfnCallback))(&args);
376 } 376 }
377 FX_BOOL CXFA_ScriptContext::IsStrictScopeInJavaScript() { 377 FX_BOOL CXFA_ScriptContext::IsStrictScopeInJavaScript() {
378 return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping); 378 return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping);
379 } 379 }
380 XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() { 380 XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() {
381 return m_eScriptType; 381 return m_eScriptType;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 } 766 }
767 } 767 }
768 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { 768 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) {
769 if (!m_pScriptNodeArray) { 769 if (!m_pScriptNodeArray) {
770 return; 770 return;
771 } 771 }
772 if (m_pScriptNodeArray->Find(pNode) == -1) { 772 if (m_pScriptNodeArray->Find(pNode) == -1) {
773 m_pScriptNodeArray->Add(pNode); 773 m_pScriptNodeArray->Add(pNode);
774 } 774 }
775 } 775 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp ('k') | xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698