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

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

Issue 1830323006: Remove FX_DWORD from XFA. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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/fm2js/xfa_fm2jsapi.h" 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const CFX_ByteStringC& szPropName, 109 const CFX_ByteStringC& szPropName,
110 FXJSE_HVALUE hValue) { 110 FXJSE_HVALUE hValue) {
111 CXFA_Object* lpOrginalNode = 111 CXFA_Object* lpOrginalNode =
112 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL); 112 (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
113 CXFA_Document* pDoc = lpOrginalNode->GetDocument(); 113 CXFA_Document* pDoc = lpOrginalNode->GetDocument();
114 CXFA_ScriptContext* lpScriptContext = 114 CXFA_ScriptContext* lpScriptContext =
115 (CXFA_ScriptContext*)pDoc->GetScriptContext(); 115 (CXFA_ScriptContext*)pDoc->GetScriptContext();
116 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode); 116 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode);
117 CFX_WideString wsPropName = CFX_WideString::FromUTF8( 117 CFX_WideString wsPropName = CFX_WideString::FromUTF8(
118 (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); 118 (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength());
119 FX_DWORD 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, hValue, dwFlag, 126 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag,
127 TRUE)) { 127 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 IXFA_Notify* pNotify = pDoc->GetNotify(); 136 IXFA_Notify* pNotify = pDoc->GetNotify();
137 if (!pNotify) { 137 if (!pNotify) {
138 return; 138 return;
139 } 139 }
140 pNotify->GetDocProvider()->SetGlobalProperty(pNotify->GetHDOC(), szPropName, 140 pNotify->GetDocProvider()->SetGlobalProperty(pNotify->GetHDOC(), szPropName,
141 hValue); 141 hValue);
142 } 142 }
143 FX_BOOL CXFA_ScriptContext::QueryNodeByFlag(CXFA_Node* refNode, 143 FX_BOOL CXFA_ScriptContext::QueryNodeByFlag(CXFA_Node* refNode,
144 const CFX_WideStringC& propname, 144 const CFX_WideStringC& propname,
145 FXJSE_HVALUE hValue, 145 FXJSE_HVALUE hValue,
146 FX_DWORD dwFlag, 146 uint32_t dwFlag,
147 FX_BOOL bSetting) { 147 FX_BOOL bSetting) {
148 if (!refNode) 148 if (!refNode)
149 return false; 149 return false;
150 XFA_RESOLVENODE_RS resolveRs; 150 XFA_RESOLVENODE_RS resolveRs;
151 if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0) 151 if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0)
152 return false; 152 return false;
153 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 153 if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
154 FXJSE_HVALUE pValue = GetJSValueFromMap(resolveRs.nodes[0]); 154 FXJSE_HVALUE pValue = GetJSValueFromMap(resolveRs.nodes[0]);
155 FXJSE_Value_Set(hValue, pValue); 155 FXJSE_Value_Set(hValue, pValue);
156 return true; 156 return true;
(...skipping 27 matching lines...) Expand all
184 FX_HashCode_String_GetW(wsPropName, wsPropName.GetLength()); 184 FX_HashCode_String_GetW(wsPropName, wsPropName.GetLength());
185 if (uHashCode != XFA_HASHCODE_Layout) { 185 if (uHashCode != XFA_HASHCODE_Layout) {
186 CXFA_Object* pObject = 186 CXFA_Object* pObject =
187 lpScriptContext->GetDocument()->GetXFAObject(uHashCode); 187 lpScriptContext->GetDocument()->GetXFAObject(uHashCode);
188 if (pObject) { 188 if (pObject) {
189 FXJSE_Value_Set(hValue, lpScriptContext->GetJSValueFromMap(pObject)); 189 FXJSE_Value_Set(hValue, lpScriptContext->GetJSValueFromMap(pObject));
190 return; 190 return;
191 } 191 }
192 } 192 }
193 } 193 }
194 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 194 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
195 XFA_RESOLVENODE_Attributes; 195 XFA_RESOLVENODE_Attributes;
196 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 196 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
197 if (pOrginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 197 if (pOrginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
198 pRefNode = ToNode(lpCurNode); 198 pRefNode = ToNode(lpCurNode);
199 } 199 }
200 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag, 200 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName, hValue, dwFlag,
201 FALSE)) { 201 FALSE)) {
202 return; 202 return;
203 } 203 }
204 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; 204 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
(...skipping 28 matching lines...) Expand all
233 (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength()); 233 (const FX_CHAR*)szPropName.GetPtr(), szPropName.GetLength());
234 CXFA_ScriptContext* lpScriptContext = 234 CXFA_ScriptContext* lpScriptContext =
235 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext(); 235 (CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext();
236 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject); 236 CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject);
237 if (wsPropName == FX_WSTRC(L"xfa")) { 237 if (wsPropName == FX_WSTRC(L"xfa")) {
238 FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap( 238 FXJSE_HVALUE pValue = lpScriptContext->GetJSValueFromMap(
239 lpScriptContext->GetDocument()->GetRoot()); 239 lpScriptContext->GetDocument()->GetRoot());
240 FXJSE_Value_Set(hValue, pValue); 240 FXJSE_Value_Set(hValue, pValue);
241 return; 241 return;
242 } 242 }
243 FX_DWORD dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 243 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
244 XFA_RESOLVENODE_Attributes; 244 XFA_RESOLVENODE_Attributes;
245 FX_BOOL bRet = lpScriptContext->QueryNodeByFlag(ToNode(pObject), wsPropName, 245 FX_BOOL bRet = lpScriptContext->QueryNodeByFlag(ToNode(pObject), wsPropName,
246 hValue, dwFlag, FALSE); 246 hValue, dwFlag, FALSE);
247 if (bRet) { 247 if (bRet) {
248 return; 248 return;
249 } 249 }
250 if (pObject == lpScriptContext->GetThisObject() || 250 if (pObject == lpScriptContext->GetThisObject() ||
251 (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript && 251 (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Javascript &&
252 !lpScriptContext->IsStrictScopeInJavaScript())) { 252 !lpScriptContext->IsStrictScopeInJavaScript())) {
253 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; 253 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 556 }
557 FXJSE_Value_Release(hProp); 557 FXJSE_Value_Release(hProp);
558 FXJSE_Value_Release(hObject); 558 FXJSE_Value_Release(hObject);
559 } 559 }
560 FXJSE_HCLASS CXFA_ScriptContext::GetJseNormalClass() { 560 FXJSE_HCLASS CXFA_ScriptContext::GetJseNormalClass() {
561 return m_hJsClass; 561 return m_hJsClass;
562 } 562 }
563 int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode, 563 int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
564 const CFX_WideStringC& wsExpression, 564 const CFX_WideStringC& wsExpression,
565 XFA_RESOLVENODE_RS& resolveNodeRS, 565 XFA_RESOLVENODE_RS& resolveNodeRS,
566 FX_DWORD dwStyles, 566 uint32_t dwStyles,
567 CXFA_Node* bindNode) { 567 CXFA_Node* bindNode) {
568 if (wsExpression.IsEmpty()) { 568 if (wsExpression.IsEmpty()) {
569 return 0; 569 return 0;
570 } 570 }
571 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc || 571 if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc ||
572 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { 572 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) {
573 m_upObjectArray.RemoveAll(); 573 m_upObjectArray.RemoveAll();
574 } 574 }
575 if (refNode && refNode->IsNode() && 575 if (refNode && refNode->IsNode() &&
576 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) { 576 (dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 if (!m_pScriptNodeArray) { 773 if (!m_pScriptNodeArray) {
774 return; 774 return;
775 } 775 }
776 if (m_pScriptNodeArray->Find(pNode) == -1) { 776 if (m_pScriptNodeArray->Find(pNode) == -1) {
777 m_pScriptNodeArray->Add(pNode); 777 m_pScriptNodeArray->Add(pNode);
778 } 778 }
779 } 779 }
780 IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument) { 780 IXFA_ScriptContext* XFA_ScriptContext_Create(CXFA_Document* pDocument) {
781 return new CXFA_ScriptContext(pDocument); 781 return new CXFA_ScriptContext(pDocument);
782 } 782 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp ('k') | xfa/fxfa/parser/xfa_script_nodehelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698