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

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

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: 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 | « xfa/fxfa/parser/cxfa_scriptcontext.h ('k') | xfa/fxfa/parser/cxfa_simple_parser.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 "xfa/fxfa/parser/cxfa_scriptcontext.h" 7 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 #include "fxjs/cfxjse_arguments.h" 10 #include "fxjs/cfxjse_arguments.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 m_upObjectArray.RemoveAll(); 136 m_upObjectArray.RemoveAll();
137 } 137 }
138 138
139 void CXFA_ScriptContext::Initialize(v8::Isolate* pIsolate) { 139 void CXFA_ScriptContext::Initialize(v8::Isolate* pIsolate) {
140 m_pIsolate = pIsolate; 140 m_pIsolate = pIsolate;
141 DefineJsContext(); 141 DefineJsContext();
142 DefineJsClass(); 142 DefineJsClass();
143 m_ResolveProcessor.reset(new CXFA_ResolveProcessor); 143 m_ResolveProcessor.reset(new CXFA_ResolveProcessor);
144 } 144 }
145 FX_BOOL CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, 145 bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
146 const CFX_WideStringC& wsScript, 146 const CFX_WideStringC& wsScript,
147 CFXJSE_Value* hRetValue, 147 CFXJSE_Value* hRetValue,
148 CXFA_Object* pThisObject) { 148 CXFA_Object* pThisObject) {
149 CFX_ByteString btScript; 149 CFX_ByteString btScript;
150 XFA_SCRIPTLANGTYPE eSaveType = m_eScriptType; 150 XFA_SCRIPTLANGTYPE eSaveType = m_eScriptType;
151 m_eScriptType = eScriptType; 151 m_eScriptType = eScriptType;
152 if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) { 152 if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) {
153 if (!m_FM2JSContext) { 153 if (!m_FM2JSContext) {
154 m_FM2JSContext.reset( 154 m_FM2JSContext.reset(
155 new CXFA_FM2JSContext(m_pIsolate, m_JsContext.get(), m_pDocument)); 155 new CXFA_FM2JSContext(m_pIsolate, m_JsContext.get(), m_pDocument));
156 } 156 }
157 CFX_WideTextBuf wsJavaScript; 157 CFX_WideTextBuf wsJavaScript;
158 CFX_WideString wsErrorInfo; 158 CFX_WideString wsErrorInfo;
159 int32_t iFlags = 159 int32_t iFlags =
160 CXFA_FM2JSContext::Translate(wsScript, wsJavaScript, wsErrorInfo); 160 CXFA_FM2JSContext::Translate(wsScript, wsJavaScript, wsErrorInfo);
161 if (iFlags) { 161 if (iFlags) {
162 hRetValue->SetUndefined(); 162 hRetValue->SetUndefined();
163 return FALSE; 163 return false;
164 } 164 }
165 btScript = 165 btScript =
166 FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength()); 166 FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength());
167 } else { 167 } else {
168 btScript = FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); 168 btScript = FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength());
169 } 169 }
170 CXFA_Object* pOriginalObject = m_pThisObject; 170 CXFA_Object* pOriginalObject = m_pThisObject;
171 m_pThisObject = pThisObject; 171 m_pThisObject = pThisObject;
172 CFXJSE_Value* pValue = pThisObject ? GetJSValueFromMap(pThisObject) : nullptr; 172 CFXJSE_Value* pValue = pThisObject ? GetJSValueFromMap(pThisObject) : nullptr;
173 FX_BOOL bRet = 173 bool bRet = m_JsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue);
174 m_JsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue);
175 m_pThisObject = pOriginalObject; 174 m_pThisObject = pOriginalObject;
176 m_eScriptType = eSaveType; 175 m_eScriptType = eSaveType;
177 return bRet; 176 return bRet;
178 } 177 }
179 void CXFA_ScriptContext::GlobalPropertySetter(CFXJSE_Value* pObject, 178 void CXFA_ScriptContext::GlobalPropertySetter(CFXJSE_Value* pObject,
180 const CFX_ByteStringC& szPropName, 179 const CFX_ByteStringC& szPropName,
181 CFXJSE_Value* pValue) { 180 CFXJSE_Value* pValue) {
182 CXFA_Object* lpOrginalNode = ToObject(pObject, nullptr); 181 CXFA_Object* lpOrginalNode = ToObject(pObject, nullptr);
183 CXFA_Document* pDoc = lpOrginalNode->GetDocument(); 182 CXFA_Document* pDoc = lpOrginalNode->GetDocument();
184 CXFA_ScriptContext* lpScriptContext = pDoc->GetScriptContext(); 183 CXFA_ScriptContext* lpScriptContext = pDoc->GetScriptContext();
185 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode); 184 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode);
186 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 185 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
187 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings | 186 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings |
188 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 187 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
189 XFA_RESOLVENODE_Attributes; 188 XFA_RESOLVENODE_Attributes;
190 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 189 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
191 if (lpOrginalNode->IsVariablesThis()) 190 if (lpOrginalNode->IsVariablesThis())
192 pRefNode = ToNode(lpCurNode); 191 pRefNode = ToNode(lpCurNode);
193 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue, 192 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue,
194 dwFlag, TRUE)) { 193 dwFlag, true)) {
195 return; 194 return;
196 } 195 }
197 if (lpOrginalNode->IsVariablesThis()) { 196 if (lpOrginalNode->IsVariablesThis()) {
198 if (pValue && pValue->IsUndefined()) { 197 if (pValue && pValue->IsUndefined()) {
199 pObject->SetObjectOwnProperty(szPropName, pValue); 198 pObject->SetObjectOwnProperty(szPropName, pValue);
200 return; 199 return;
201 } 200 }
202 } 201 }
203 CXFA_FFNotify* pNotify = pDoc->GetNotify(); 202 CXFA_FFNotify* pNotify = pDoc->GetNotify();
204 if (!pNotify) { 203 if (!pNotify) {
205 return; 204 return;
206 } 205 }
207 pNotify->GetDocEnvironment()->SetGlobalProperty(pNotify->GetHDOC(), 206 pNotify->GetDocEnvironment()->SetGlobalProperty(pNotify->GetHDOC(),
208 szPropName, pValue); 207 szPropName, pValue);
209 } 208 }
210 FX_BOOL CXFA_ScriptContext::QueryNodeByFlag(CXFA_Node* refNode, 209 bool CXFA_ScriptContext::QueryNodeByFlag(CXFA_Node* refNode,
211 const CFX_WideStringC& propname, 210 const CFX_WideStringC& propname,
212 CFXJSE_Value* pValue, 211 CFXJSE_Value* pValue,
213 uint32_t dwFlag, 212 uint32_t dwFlag,
214 FX_BOOL bSetting) { 213 bool bSetting) {
215 if (!refNode) 214 if (!refNode)
216 return false; 215 return false;
217 XFA_RESOLVENODE_RS resolveRs; 216 XFA_RESOLVENODE_RS resolveRs;
218 if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0) 217 if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0)
219 return false; 218 return false;
220 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 219 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
221 pValue->Assign(GetJSValueFromMap(resolveRs.nodes[0])); 220 pValue->Assign(GetJSValueFromMap(resolveRs.nodes[0]));
222 return true; 221 return true;
223 } 222 }
224 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Attribute) { 223 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Attribute) {
(...skipping 29 matching lines...) Expand all
254 } 253 }
255 } 254 }
256 } 255 }
257 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 256 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
258 XFA_RESOLVENODE_Attributes; 257 XFA_RESOLVENODE_Attributes;
259 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 258 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
260 if (pOriginalObject->IsVariablesThis()) { 259 if (pOriginalObject->IsVariablesThis()) {
261 pRefNode = ToNode(lpCurNode); 260 pRefNode = ToNode(lpCurNode);
262 } 261 }
263 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue, 262 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue,
264 dwFlag, FALSE)) { 263 dwFlag, false)) {
265 return; 264 return;
266 } 265 }
267 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; 266 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
268 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue, 267 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue,
269 dwFlag, FALSE)) { 268 dwFlag, false)) {
270 return; 269 return;
271 } 270 }
272 CXFA_Object* pScriptObject = 271 CXFA_Object* pScriptObject =
273 lpScriptContext->GetVariablesThis(pOriginalObject, TRUE); 272 lpScriptContext->GetVariablesThis(pOriginalObject, true);
274 if (pScriptObject && 273 if (pScriptObject &&
275 lpScriptContext->QueryVariableValue(pScriptObject->AsNode(), szPropName, 274 lpScriptContext->QueryVariableValue(pScriptObject->AsNode(), szPropName,
276 pValue, TRUE)) { 275 pValue, true)) {
277 return; 276 return;
278 } 277 }
279 CXFA_FFNotify* pNotify = pDoc->GetNotify(); 278 CXFA_FFNotify* pNotify = pDoc->GetNotify();
280 if (!pNotify) { 279 if (!pNotify) {
281 return; 280 return;
282 } 281 }
283 pNotify->GetDocEnvironment()->GetGlobalProperty(pNotify->GetHDOC(), 282 pNotify->GetDocEnvironment()->GetGlobalProperty(pNotify->GetHDOC(),
284 szPropName, pValue); 283 szPropName, pValue);
285 } 284 }
286 void CXFA_ScriptContext::NormalPropertyGetter(CFXJSE_Value* pOriginalValue, 285 void CXFA_ScriptContext::NormalPropertyGetter(CFXJSE_Value* pOriginalValue,
287 const CFX_ByteStringC& szPropName, 286 const CFX_ByteStringC& szPropName,
288 CFXJSE_Value* pReturnValue) { 287 CFXJSE_Value* pReturnValue) {
289 CXFA_Object* pOriginalObject = ToObject(pOriginalValue, nullptr); 288 CXFA_Object* pOriginalObject = ToObject(pOriginalValue, nullptr);
290 if (!pOriginalObject) { 289 if (!pOriginalObject) {
291 pReturnValue->SetUndefined(); 290 pReturnValue->SetUndefined();
292 return; 291 return;
293 } 292 }
294 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 293 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
295 CXFA_ScriptContext* lpScriptContext = 294 CXFA_ScriptContext* lpScriptContext =
296 pOriginalObject->GetDocument()->GetScriptContext(); 295 pOriginalObject->GetDocument()->GetScriptContext();
297 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOriginalObject); 296 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOriginalObject);
298 if (wsPropName == FX_WSTRC(L"xfa")) { 297 if (wsPropName == FX_WSTRC(L"xfa")) {
299 CFXJSE_Value* pValue = lpScriptContext->GetJSValueFromMap( 298 CFXJSE_Value* pValue = lpScriptContext->GetJSValueFromMap(
300 lpScriptContext->GetDocument()->GetRoot()); 299 lpScriptContext->GetDocument()->GetRoot());
301 pReturnValue->Assign(pValue); 300 pReturnValue->Assign(pValue);
302 return; 301 return;
303 } 302 }
304 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 303 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
305 XFA_RESOLVENODE_Attributes; 304 XFA_RESOLVENODE_Attributes;
306 FX_BOOL bRet = lpScriptContext->QueryNodeByFlag( 305 bool bRet = lpScriptContext->QueryNodeByFlag(
307 ToNode(pObject), wsPropName.AsStringC(), pReturnValue, dwFlag, FALSE); 306 ToNode(pObject), wsPropName.AsStringC(), pReturnValue, dwFlag, false);
308 if (bRet) { 307 if (bRet) {
309 return; 308 return;
310 } 309 }
311 if (pObject == lpScriptContext->GetThisObject() || 310 if (pObject == lpScriptContext->GetThisObject() ||
312 (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript && 311 (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript &&
313 !lpScriptContext->IsStrictScopeInJavaScript())) { 312 !lpScriptContext->IsStrictScopeInJavaScript())) {
314 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; 313 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
315 bRet = lpScriptContext->QueryNodeByFlag( 314 bRet = lpScriptContext->QueryNodeByFlag(
316 ToNode(pObject), wsPropName.AsStringC(), pReturnValue, dwFlag, FALSE); 315 ToNode(pObject), wsPropName.AsStringC(), pReturnValue, dwFlag, false);
317 } 316 }
318 if (bRet) { 317 if (bRet) {
319 return; 318 return;
320 } 319 }
321 CXFA_Object* pScriptObject = 320 CXFA_Object* pScriptObject =
322 lpScriptContext->GetVariablesThis(pOriginalObject, TRUE); 321 lpScriptContext->GetVariablesThis(pOriginalObject, true);
323 if (pScriptObject) { 322 if (pScriptObject) {
324 bRet = lpScriptContext->QueryVariableValue(ToNode(pScriptObject), 323 bRet = lpScriptContext->QueryVariableValue(ToNode(pScriptObject),
325 szPropName, pReturnValue, TRUE); 324 szPropName, pReturnValue, true);
326 } 325 }
327 if (!bRet) { 326 if (!bRet) {
328 pReturnValue->SetUndefined(); 327 pReturnValue->SetUndefined();
329 } 328 }
330 } 329 }
331 void CXFA_ScriptContext::NormalPropertySetter(CFXJSE_Value* pOriginalValue, 330 void CXFA_ScriptContext::NormalPropertySetter(CFXJSE_Value* pOriginalValue,
332 const CFX_ByteStringC& szPropName, 331 const CFX_ByteStringC& szPropName,
333 CFXJSE_Value* pReturnValue) { 332 CFXJSE_Value* pReturnValue) {
334 CXFA_Object* pOriginalObject = ToObject(pOriginalValue, nullptr); 333 CXFA_Object* pOriginalObject = ToObject(pOriginalValue, nullptr);
335 if (!pOriginalObject) 334 if (!pOriginalObject)
336 return; 335 return;
337 336
338 CXFA_ScriptContext* lpScriptContext = 337 CXFA_ScriptContext* lpScriptContext =
339 pOriginalObject->GetDocument()->GetScriptContext(); 338 pOriginalObject->GetDocument()->GetScriptContext();
340 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOriginalObject); 339 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOriginalObject);
341 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 340 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
342 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = XFA_GetScriptAttributeByName( 341 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = XFA_GetScriptAttributeByName(
343 pObject->GetElementType(), wsPropName.AsStringC()); 342 pObject->GetElementType(), wsPropName.AsStringC());
344 if (lpAttributeInfo) { 343 if (lpAttributeInfo) {
345 (pObject->*(lpAttributeInfo->lpfnCallback))( 344 (pObject->*(lpAttributeInfo->lpfnCallback))(
346 pReturnValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); 345 pReturnValue, true, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
347 } else { 346 } else {
348 if (pObject->IsNode()) { 347 if (pObject->IsNode()) {
349 if (wsPropName.GetAt(0) == '#') { 348 if (wsPropName.GetAt(0) == '#') {
350 wsPropName = wsPropName.Right(wsPropName.GetLength() - 1); 349 wsPropName = wsPropName.Right(wsPropName.GetLength() - 1);
351 } 350 }
352 CXFA_Node* pNode = ToNode(pObject); 351 CXFA_Node* pNode = ToNode(pObject);
353 CXFA_Node* pPropOrChild = nullptr; 352 CXFA_Node* pPropOrChild = nullptr;
354 XFA_Element eType = XFA_GetElementTypeForName(wsPropName.AsStringC()); 353 XFA_Element eType = XFA_GetElementTypeForName(wsPropName.AsStringC());
355 if (eType != XFA_Element::Unknown) 354 if (eType != XFA_Element::Unknown)
356 pPropOrChild = pNode->GetProperty(0, eType); 355 pPropOrChild = pNode->GetProperty(0, eType);
357 else 356 else
358 pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsStringC()); 357 pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsStringC());
359 358
360 if (pPropOrChild) { 359 if (pPropOrChild) {
361 CFX_WideString wsDefaultName(L"{default}"); 360 CFX_WideString wsDefaultName(L"{default}");
362 const XFA_SCRIPTATTRIBUTEINFO* lpAttrInfo = 361 const XFA_SCRIPTATTRIBUTEINFO* lpAttrInfo =
363 XFA_GetScriptAttributeByName(pPropOrChild->GetElementType(), 362 XFA_GetScriptAttributeByName(pPropOrChild->GetElementType(),
364 wsDefaultName.AsStringC()); 363 wsDefaultName.AsStringC());
365 if (lpAttrInfo) { 364 if (lpAttrInfo) {
366 (pPropOrChild->*(lpAttrInfo->lpfnCallback))( 365 (pPropOrChild->*(lpAttrInfo->lpfnCallback))(
367 pReturnValue, TRUE, (XFA_ATTRIBUTE)lpAttrInfo->eAttribute); 366 pReturnValue, true, (XFA_ATTRIBUTE)lpAttrInfo->eAttribute);
368 return; 367 return;
369 } 368 }
370 } 369 }
371 } 370 }
372 CXFA_Object* pScriptObject = 371 CXFA_Object* pScriptObject =
373 lpScriptContext->GetVariablesThis(pOriginalObject, TRUE); 372 lpScriptContext->GetVariablesThis(pOriginalObject, true);
374 if (pScriptObject) { 373 if (pScriptObject) {
375 lpScriptContext->QueryVariableValue(ToNode(pScriptObject), szPropName, 374 lpScriptContext->QueryVariableValue(ToNode(pScriptObject), szPropName,
376 pReturnValue, FALSE); 375 pReturnValue, false);
377 } 376 }
378 } 377 }
379 } 378 }
380 int32_t CXFA_ScriptContext::NormalPropTypeGetter( 379 int32_t CXFA_ScriptContext::NormalPropTypeGetter(
381 CFXJSE_Value* pOriginalValue, 380 CFXJSE_Value* pOriginalValue,
382 const CFX_ByteStringC& szPropName, 381 const CFX_ByteStringC& szPropName,
383 FX_BOOL bQueryIn) { 382 bool bQueryIn) {
384 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr); 383 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr);
385 if (!pObject) 384 if (!pObject)
386 return FXJSE_ClassPropType_None; 385 return FXJSE_ClassPropType_None;
387 386
388 CXFA_ScriptContext* lpScriptContext = 387 CXFA_ScriptContext* lpScriptContext =
389 pObject->GetDocument()->GetScriptContext(); 388 pObject->GetDocument()->GetScriptContext();
390 pObject = lpScriptContext->GetVariablesThis(pObject); 389 pObject = lpScriptContext->GetVariablesThis(pObject);
391 XFA_Element eType = pObject->GetElementType(); 390 XFA_Element eType = pObject->GetElementType();
392 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 391 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
393 if (GetMethodByName(eType, wsPropName.AsStringC())) { 392 if (GetMethodByName(eType, wsPropName.AsStringC())) {
394 return FXJSE_ClassPropType_Method; 393 return FXJSE_ClassPropType_Method;
395 } 394 }
396 if (bQueryIn && 395 if (bQueryIn &&
397 !XFA_GetScriptAttributeByName(eType, wsPropName.AsStringC())) { 396 !XFA_GetScriptAttributeByName(eType, wsPropName.AsStringC())) {
398 return FXJSE_ClassPropType_None; 397 return FXJSE_ClassPropType_None;
399 } 398 }
400 return FXJSE_ClassPropType_Property; 399 return FXJSE_ClassPropType_Property;
401 } 400 }
402 int32_t CXFA_ScriptContext::GlobalPropTypeGetter( 401 int32_t CXFA_ScriptContext::GlobalPropTypeGetter(
403 CFXJSE_Value* pOriginalValue, 402 CFXJSE_Value* pOriginalValue,
404 const CFX_ByteStringC& szPropName, 403 const CFX_ByteStringC& szPropName,
405 FX_BOOL bQueryIn) { 404 bool bQueryIn) {
406 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr); 405 CXFA_Object* pObject = ToObject(pOriginalValue, nullptr);
407 if (!pObject) 406 if (!pObject)
408 return FXJSE_ClassPropType_None; 407 return FXJSE_ClassPropType_None;
409 408
410 CXFA_ScriptContext* lpScriptContext = 409 CXFA_ScriptContext* lpScriptContext =
411 pObject->GetDocument()->GetScriptContext(); 410 pObject->GetDocument()->GetScriptContext();
412 pObject = lpScriptContext->GetVariablesThis(pObject); 411 pObject = lpScriptContext->GetVariablesThis(pObject);
413 XFA_Element eType = pObject->GetElementType(); 412 XFA_Element eType = pObject->GetElementType();
414 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 413 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
415 if (GetMethodByName(eType, wsPropName.AsStringC())) { 414 if (GetMethodByName(eType, wsPropName.AsStringC())) {
(...skipping 12 matching lines...) Expand all
428 pObject->GetDocument()->GetScriptContext(); 427 pObject->GetDocument()->GetScriptContext();
429 pObject = lpScriptContext->GetVariablesThis(pObject); 428 pObject = lpScriptContext->GetVariablesThis(pObject);
430 CFX_WideString wsFunName = CFX_WideString::FromUTF8(szFuncName); 429 CFX_WideString wsFunName = CFX_WideString::FromUTF8(szFuncName);
431 const XFA_METHODINFO* lpMethodInfo = 430 const XFA_METHODINFO* lpMethodInfo =
432 GetMethodByName(pObject->GetElementType(), wsFunName.AsStringC()); 431 GetMethodByName(pObject->GetElementType(), wsFunName.AsStringC());
433 if (!lpMethodInfo) 432 if (!lpMethodInfo)
434 return; 433 return;
435 434
436 (pObject->*(lpMethodInfo->lpfnCallback))(&args); 435 (pObject->*(lpMethodInfo->lpfnCallback))(&args);
437 } 436 }
438 FX_BOOL CXFA_ScriptContext::IsStrictScopeInJavaScript() { 437 bool CXFA_ScriptContext::IsStrictScopeInJavaScript() {
439 return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping); 438 return m_pDocument->HasFlag(XFA_DOCFLAG_StrictScoping);
440 } 439 }
441 XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() { 440 XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() {
442 return m_eScriptType; 441 return m_eScriptType;
443 } 442 }
444 void CXFA_ScriptContext::DefineJsContext() { 443 void CXFA_ScriptContext::DefineJsContext() {
445 m_JsContext.reset(CFXJSE_Context::Create(m_pIsolate, &GlobalClassDescriptor, 444 m_JsContext.reset(CFXJSE_Context::Create(m_pIsolate, &GlobalClassDescriptor,
446 m_pDocument->GetRoot())); 445 m_pDocument->GetRoot()));
447 RemoveBuiltInObjs(m_JsContext.get()); 446 RemoveBuiltInObjs(m_JsContext.get());
448 m_JsContext->EnableCompatibleMode(); 447 m_JsContext->EnableCompatibleMode();
449 } 448 }
450 CFXJSE_Context* CXFA_ScriptContext::CreateVariablesContext( 449 CFXJSE_Context* CXFA_ScriptContext::CreateVariablesContext(
451 CXFA_Node* pScriptNode, 450 CXFA_Node* pScriptNode,
452 CXFA_Node* pSubform) { 451 CXFA_Node* pSubform) {
453 if (!pScriptNode || !pSubform) 452 if (!pScriptNode || !pSubform)
454 return nullptr; 453 return nullptr;
455 454
456 CFXJSE_Context* pVariablesContext = 455 CFXJSE_Context* pVariablesContext =
457 CFXJSE_Context::Create(m_pIsolate, &VariablesClassDescriptor, 456 CFXJSE_Context::Create(m_pIsolate, &VariablesClassDescriptor,
458 new CXFA_ThisProxy(pSubform, pScriptNode)); 457 new CXFA_ThisProxy(pSubform, pScriptNode));
459 RemoveBuiltInObjs(pVariablesContext); 458 RemoveBuiltInObjs(pVariablesContext);
460 pVariablesContext->EnableCompatibleMode(); 459 pVariablesContext->EnableCompatibleMode();
461 m_mapVariableToContext.SetAt(pScriptNode, pVariablesContext); 460 m_mapVariableToContext.SetAt(pScriptNode, pVariablesContext);
462 return pVariablesContext; 461 return pVariablesContext;
463 } 462 }
464 CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject, 463 CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject,
465 FX_BOOL bScriptNode) { 464 bool bScriptNode) {
466 if (!pObject->IsVariablesThis()) 465 if (!pObject->IsVariablesThis())
467 return pObject; 466 return pObject;
468 467
469 CXFA_ThisProxy* pProxy = static_cast<CXFA_ThisProxy*>(pObject); 468 CXFA_ThisProxy* pProxy = static_cast<CXFA_ThisProxy*>(pObject);
470 return bScriptNode ? pProxy->GetScriptNode() : pProxy->GetThisNode(); 469 return bScriptNode ? pProxy->GetScriptNode() : pProxy->GetThisNode();
471 } 470 }
472 471
473 FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { 472 bool CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) {
474 if (!pScriptNode) 473 if (!pScriptNode)
475 return FALSE; 474 return false;
476 475
477 if (pScriptNode->GetElementType() != XFA_Element::Script) 476 if (pScriptNode->GetElementType() != XFA_Element::Script)
478 return TRUE; 477 return true;
479 478
480 CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); 479 CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
481 if (!pParent || pParent->GetElementType() != XFA_Element::Variables) 480 if (!pParent || pParent->GetElementType() != XFA_Element::Variables)
482 return FALSE; 481 return false;
483 482
484 if (m_mapVariableToContext.GetValueAt(pScriptNode)) 483 if (m_mapVariableToContext.GetValueAt(pScriptNode))
485 return TRUE; 484 return true;
486 485
487 CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild); 486 CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild);
488 if (!pTextNode) 487 if (!pTextNode)
489 return FALSE; 488 return false;
490 489
491 CFX_WideStringC wsScript; 490 CFX_WideStringC wsScript;
492 if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript)) 491 if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript))
493 return FALSE; 492 return false;
494 493
495 CFX_ByteString btScript = 494 CFX_ByteString btScript =
496 FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); 495 FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength());
497 std::unique_ptr<CFXJSE_Value> hRetValue(new CFXJSE_Value(m_pIsolate)); 496 std::unique_ptr<CFXJSE_Value> hRetValue(new CFXJSE_Value(m_pIsolate));
498 CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent); 497 CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent);
499 CFXJSE_Context* pVariablesContext = 498 CFXJSE_Context* pVariablesContext =
500 CreateVariablesContext(pScriptNode, pThisObject); 499 CreateVariablesContext(pScriptNode, pThisObject);
501 CXFA_Object* pOriginalObject = m_pThisObject; 500 CXFA_Object* pOriginalObject = m_pThisObject;
502 m_pThisObject = pThisObject; 501 m_pThisObject = pThisObject;
503 FX_BOOL bRet = 502 bool bRet =
504 pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get()); 503 pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get());
505 m_pThisObject = pOriginalObject; 504 m_pThisObject = pOriginalObject;
506 return bRet; 505 return bRet;
507 } 506 }
508 507
509 FX_BOOL CXFA_ScriptContext::QueryVariableValue( 508 bool CXFA_ScriptContext::QueryVariableValue(CXFA_Node* pScriptNode,
510 CXFA_Node* pScriptNode, 509 const CFX_ByteStringC& szPropName,
511 const CFX_ByteStringC& szPropName, 510 CFXJSE_Value* pValue,
512 CFXJSE_Value* pValue, 511 bool bGetter) {
513 FX_BOOL bGetter) {
514 if (!pScriptNode || pScriptNode->GetElementType() != XFA_Element::Script) 512 if (!pScriptNode || pScriptNode->GetElementType() != XFA_Element::Script)
515 return FALSE; 513 return false;
516 514
517 CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent); 515 CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
518 if (!variablesNode || 516 if (!variablesNode ||
519 variablesNode->GetElementType() != XFA_Element::Variables) 517 variablesNode->GetElementType() != XFA_Element::Variables)
520 return FALSE; 518 return false;
521 519
522 void* lpVariables = m_mapVariableToContext.GetValueAt(pScriptNode); 520 void* lpVariables = m_mapVariableToContext.GetValueAt(pScriptNode);
523 if (!lpVariables) 521 if (!lpVariables)
524 return FALSE; 522 return false;
525 523
526 FX_BOOL bRes = FALSE; 524 bool bRes = false;
527 CFXJSE_Context* pVariableContext = static_cast<CFXJSE_Context*>(lpVariables); 525 CFXJSE_Context* pVariableContext = static_cast<CFXJSE_Context*>(lpVariables);
528 std::unique_ptr<CFXJSE_Value> pObject = pVariableContext->GetGlobalObject(); 526 std::unique_ptr<CFXJSE_Value> pObject = pVariableContext->GetGlobalObject();
529 std::unique_ptr<CFXJSE_Value> hVariableValue(new CFXJSE_Value(m_pIsolate)); 527 std::unique_ptr<CFXJSE_Value> hVariableValue(new CFXJSE_Value(m_pIsolate));
530 if (!bGetter) { 528 if (!bGetter) {
531 pObject->SetObjectOwnProperty(szPropName, pValue); 529 pObject->SetObjectOwnProperty(szPropName, pValue);
532 bRes = TRUE; 530 bRes = true;
533 } else if (pObject->HasObjectOwnProperty(szPropName, FALSE)) { 531 } else if (pObject->HasObjectOwnProperty(szPropName, false)) {
534 pObject->GetObjectProperty(szPropName, hVariableValue.get()); 532 pObject->GetObjectProperty(szPropName, hVariableValue.get());
535 if (hVariableValue->IsFunction()) 533 if (hVariableValue->IsFunction())
536 pValue->SetFunctionBind(hVariableValue.get(), pObject.get()); 534 pValue->SetFunctionBind(hVariableValue.get(), pObject.get());
537 else if (bGetter) 535 else if (bGetter)
538 pValue->Assign(hVariableValue.get()); 536 pValue->Assign(hVariableValue.get());
539 else 537 else
540 hVariableValue.get()->Assign(pValue); 538 hVariableValue.get()->Assign(pValue);
541 bRes = TRUE; 539 bRes = true;
542 } 540 }
543 return bRes; 541 return bRes;
544 } 542 }
545 543
546 void CXFA_ScriptContext::DefineJsClass() { 544 void CXFA_ScriptContext::DefineJsClass() {
547 m_pJsClass = CFXJSE_Class::Create(m_JsContext.get(), &NormalClassDescriptor); 545 m_pJsClass = CFXJSE_Class::Create(m_JsContext.get(), &NormalClassDescriptor);
548 } 546 }
549 547
550 void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const { 548 void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const {
551 static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; 549 static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"};
(...skipping 16 matching lines...) Expand all
568 return 0; 566 return 0;
569 } 567 }
570 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || 568 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc ||
571 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { 569 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) {
572 m_upObjectArray.RemoveAll(); 570 m_upObjectArray.RemoveAll();
573 } 571 }
574 if (refNode && refNode->IsNode() && 572 if (refNode && refNode->IsNode() &&
575 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { 573 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) {
576 m_upObjectArray.Add(refNode->AsNode()); 574 m_upObjectArray.Add(refNode->AsNode());
577 } 575 }
578 FX_BOOL bNextCreate = FALSE; 576 bool bNextCreate = false;
579 if (dwStyles & XFA_RESOLVENODE_CreateNode) { 577 if (dwStyles & XFA_RESOLVENODE_CreateNode) {
580 m_ResolveProcessor->GetNodeHelper()->SetCreateNodeType(bindNode); 578 m_ResolveProcessor->GetNodeHelper()->SetCreateNodeType(bindNode);
581 } 579 }
582 m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = nullptr; 580 m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = nullptr;
583 m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1; 581 m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1;
584 CXFA_ResolveNodesData rndFind; 582 CXFA_ResolveNodesData rndFind;
585 int32_t nStart = 0; 583 int32_t nStart = 0;
586 int32_t nLevel = 0; 584 int32_t nLevel = 0;
587 int32_t nRet = -1; 585 int32_t nRet = -1;
588 rndFind.m_pSC = this; 586 rndFind.m_pSC = this;
589 CXFA_ObjArray findNodes; 587 CXFA_ObjArray findNodes;
590 findNodes.Add(refNode ? refNode : m_pDocument->GetRoot()); 588 findNodes.Add(refNode ? refNode : m_pDocument->GetRoot());
591 int32_t nNodes = 0; 589 int32_t nNodes = 0;
592 while (TRUE) { 590 while (true) {
593 nNodes = findNodes.GetSize(); 591 nNodes = findNodes.GetSize();
594 int32_t i = 0; 592 int32_t i = 0;
595 rndFind.m_dwStyles = dwStyles; 593 rndFind.m_dwStyles = dwStyles;
596 m_ResolveProcessor->SetCurStart(nStart); 594 m_ResolveProcessor->SetCurStart(nStart);
597 nStart = m_ResolveProcessor->GetFilter(wsExpression, nStart, rndFind); 595 nStart = m_ResolveProcessor->GetFilter(wsExpression, nStart, rndFind);
598 if (nStart < 1) { 596 if (nStart < 1) {
599 if ((dwStyles & XFA_RESOLVENODE_CreateNode) && !bNextCreate) { 597 if ((dwStyles & XFA_RESOLVENODE_CreateNode) && !bNextCreate) {
600 CXFA_Node* pDataNode = nullptr; 598 CXFA_Node* pDataNode = nullptr;
601 nStart = m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart; 599 nStart = m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart;
602 if (nStart != -1) { 600 if (nStart != -1) {
(...skipping 11 matching lines...) Expand all
614 } 612 }
615 dwStyles |= XFA_RESOLVENODE_Bind; 613 dwStyles |= XFA_RESOLVENODE_Bind;
616 findNodes.RemoveAll(); 614 findNodes.RemoveAll();
617 findNodes.Add(m_ResolveProcessor->GetNodeHelper()->m_pAllStartParent); 615 findNodes.Add(m_ResolveProcessor->GetNodeHelper()->m_pAllStartParent);
618 continue; 616 continue;
619 } else { 617 } else {
620 break; 618 break;
621 } 619 }
622 } 620 }
623 if (bNextCreate) { 621 if (bNextCreate) {
624 FX_BOOL bCreate = 622 bool bCreate =
625 m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode( 623 m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode(
626 rndFind.m_wsName, rndFind.m_wsCondition, 624 rndFind.m_wsName, rndFind.m_wsCondition,
627 nStart == wsExpression.GetLength(), this); 625 nStart == wsExpression.GetLength(), this);
628 if (bCreate) { 626 if (bCreate) {
629 continue; 627 continue;
630 } else { 628 } else {
631 break; 629 break;
632 } 630 }
633 } 631 }
634 CXFA_ObjArray retNodes; 632 CXFA_ObjArray retNodes;
635 while (i < nNodes) { 633 while (i < nNodes) {
636 FX_BOOL bDataBind = FALSE; 634 bool bDataBind = false;
637 if (((dwStyles & XFA_RESOLVENODE_Bind) || 635 if (((dwStyles & XFA_RESOLVENODE_Bind) ||
638 (dwStyles & XFA_RESOLVENODE_CreateNode)) && 636 (dwStyles & XFA_RESOLVENODE_CreateNode)) &&
639 nNodes > 1) { 637 nNodes > 1) {
640 CXFA_ResolveNodesData rndBind; 638 CXFA_ResolveNodesData rndBind;
641 m_ResolveProcessor->GetFilter(wsExpression, nStart, rndBind); 639 m_ResolveProcessor->GetFilter(wsExpression, nStart, rndBind);
642 m_ResolveProcessor->SetIndexDataBind(rndBind.m_wsCondition, i, nNodes); 640 m_ResolveProcessor->SetIndexDataBind(rndBind.m_wsCondition, i, nNodes);
643 bDataBind = TRUE; 641 bDataBind = true;
644 } 642 }
645 rndFind.m_CurNode = findNodes[i++]; 643 rndFind.m_CurNode = findNodes[i++];
646 rndFind.m_nLevel = nLevel; 644 rndFind.m_nLevel = nLevel;
647 rndFind.m_dwFlag = XFA_RESOVENODE_RSTYPE_Nodes; 645 rndFind.m_dwFlag = XFA_RESOVENODE_RSTYPE_Nodes;
648 nRet = m_ResolveProcessor->Resolve(rndFind); 646 nRet = m_ResolveProcessor->Resolve(rndFind);
649 if (nRet < 1) { 647 if (nRet < 1) {
650 continue; 648 continue;
651 } 649 }
652 if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute && 650 if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute &&
653 rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) { 651 rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) {
654 std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(m_pIsolate)); 652 std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(m_pIsolate));
655 (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))( 653 (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))(
656 pValue.get(), FALSE, 654 pValue.get(), false,
657 (XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute); 655 (XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute);
658 rndFind.m_Nodes.SetAt(0, ToObject(pValue.get(), nullptr)); 656 rndFind.m_Nodes.SetAt(0, ToObject(pValue.get(), nullptr));
659 } 657 }
660 int32_t iSize = m_upObjectArray.GetSize(); 658 int32_t iSize = m_upObjectArray.GetSize();
661 if (iSize) { 659 if (iSize) {
662 m_upObjectArray.RemoveAt(iSize - 1); 660 m_upObjectArray.RemoveAt(iSize - 1);
663 } 661 }
664 retNodes.Append(rndFind.m_Nodes); 662 retNodes.Append(rndFind.m_Nodes);
665 rndFind.m_Nodes.RemoveAll(); 663 rndFind.m_Nodes.RemoveAll();
666 if (bDataBind) { 664 if (bDataBind) {
667 break; 665 break;
668 } 666 }
669 } 667 }
670 findNodes.RemoveAll(); 668 findNodes.RemoveAll();
671 nNodes = retNodes.GetSize(); 669 nNodes = retNodes.GetSize();
672 if (nNodes < 1) { 670 if (nNodes < 1) {
673 if (dwStyles & XFA_RESOLVENODE_CreateNode) { 671 if (dwStyles & XFA_RESOLVENODE_CreateNode) {
674 bNextCreate = TRUE; 672 bNextCreate = true;
675 if (!m_ResolveProcessor->GetNodeHelper()->m_pCreateParent) { 673 if (!m_ResolveProcessor->GetNodeHelper()->m_pCreateParent) {
676 m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = 674 m_ResolveProcessor->GetNodeHelper()->m_pCreateParent =
677 ToNode(rndFind.m_CurNode); 675 ToNode(rndFind.m_CurNode);
678 m_ResolveProcessor->GetNodeHelper()->m_iCreateCount = 1; 676 m_ResolveProcessor->GetNodeHelper()->m_iCreateCount = 1;
679 } 677 }
680 FX_BOOL bCreate = 678 bool bCreate =
681 m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode( 679 m_ResolveProcessor->GetNodeHelper()->ResolveNodes_CreateNode(
682 rndFind.m_wsName, rndFind.m_wsCondition, 680 rndFind.m_wsName, rndFind.m_wsCondition,
683 nStart == wsExpression.GetLength(), this); 681 nStart == wsExpression.GetLength(), this);
684 if (bCreate) { 682 if (bCreate) {
685 continue; 683 continue;
686 } else { 684 } else {
687 break; 685 break;
688 } 686 }
689 } else { 687 } else {
690 break; 688 break;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 733
736 std::unique_ptr<CFXJSE_Value> jsValue(new CFXJSE_Value(m_pIsolate)); 734 std::unique_ptr<CFXJSE_Value> jsValue(new CFXJSE_Value(m_pIsolate));
737 jsValue->SetObject(pObject, m_pJsClass); 735 jsValue->SetObject(pObject, m_pJsClass);
738 CFXJSE_Value* pValue = jsValue.get(); 736 CFXJSE_Value* pValue = jsValue.get();
739 m_mapObjectToValue.insert(std::make_pair(pObject, std::move(jsValue))); 737 m_mapObjectToValue.insert(std::make_pair(pObject, std::move(jsValue)));
740 return pValue; 738 return pValue;
741 } 739 }
742 int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) { 740 int32_t CXFA_ScriptContext::GetIndexByName(CXFA_Node* refNode) {
743 CXFA_NodeHelper* lpNodeHelper = m_ResolveProcessor->GetNodeHelper(); 741 CXFA_NodeHelper* lpNodeHelper = m_ResolveProcessor->GetNodeHelper();
744 return lpNodeHelper->GetIndex(refNode, XFA_LOGIC_Transparent, 742 return lpNodeHelper->GetIndex(refNode, XFA_LOGIC_Transparent,
745 lpNodeHelper->NodeIsProperty(refNode), FALSE); 743 lpNodeHelper->NodeIsProperty(refNode), false);
746 } 744 }
747 int32_t CXFA_ScriptContext::GetIndexByClassName(CXFA_Node* refNode) { 745 int32_t CXFA_ScriptContext::GetIndexByClassName(CXFA_Node* refNode) {
748 CXFA_NodeHelper* lpNodeHelper = m_ResolveProcessor->GetNodeHelper(); 746 CXFA_NodeHelper* lpNodeHelper = m_ResolveProcessor->GetNodeHelper();
749 return lpNodeHelper->GetIndex(refNode, XFA_LOGIC_Transparent, 747 return lpNodeHelper->GetIndex(refNode, XFA_LOGIC_Transparent,
750 lpNodeHelper->NodeIsProperty(refNode), TRUE); 748 lpNodeHelper->NodeIsProperty(refNode), true);
751 } 749 }
752 void CXFA_ScriptContext::GetSomExpression(CXFA_Node* refNode, 750 void CXFA_ScriptContext::GetSomExpression(CXFA_Node* refNode,
753 CFX_WideString& wsExpression) { 751 CFX_WideString& wsExpression) {
754 CXFA_NodeHelper* lpNodeHelper = m_ResolveProcessor->GetNodeHelper(); 752 CXFA_NodeHelper* lpNodeHelper = m_ResolveProcessor->GetNodeHelper();
755 lpNodeHelper->GetNameExpression(refNode, wsExpression, TRUE, 753 lpNodeHelper->GetNameExpression(refNode, wsExpression, true,
756 XFA_LOGIC_Transparent); 754 XFA_LOGIC_Transparent);
757 } 755 }
758 void CXFA_ScriptContext::SetNodesOfRunScript(CXFA_NodeArray* pArray) { 756 void CXFA_ScriptContext::SetNodesOfRunScript(CXFA_NodeArray* pArray) {
759 m_pScriptNodeArray = pArray; 757 m_pScriptNodeArray = pArray;
760 } 758 }
761 void CXFA_ScriptContext::AddNodesOfRunScript(const CXFA_NodeArray& nodes) { 759 void CXFA_ScriptContext::AddNodesOfRunScript(const CXFA_NodeArray& nodes) {
762 if (!m_pScriptNodeArray) 760 if (!m_pScriptNodeArray)
763 return; 761 return;
764 if (nodes.GetSize() > 0) 762 if (nodes.GetSize() > 0)
765 m_pScriptNodeArray->Copy(nodes); 763 m_pScriptNodeArray->Copy(nodes);
766 } 764 }
767 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { 765 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) {
768 if (!m_pScriptNodeArray) 766 if (!m_pScriptNodeArray)
769 return; 767 return;
770 if (m_pScriptNodeArray->Find(pNode) == -1) 768 if (m_pScriptNodeArray->Find(pNode) == -1)
771 m_pScriptNodeArray->Add(pNode); 769 m_pScriptNodeArray->Add(pNode);
772 } 770 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_scriptcontext.h ('k') | xfa/fxfa/parser/cxfa_simple_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698