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

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

Issue 2083453003: Split the XFA_OBJECTTYPE enum into two parts. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix == nullptr Created 4 years, 6 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
« no previous file with comments | « xfa/fxfa/parser/xfa_parser_imp.cpp ('k') | no next file » | 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/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 "fxjse/include/cfxjse_arguments.h" 10 #include "fxjse/include/cfxjse_arguments.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 CFXJSE_Value* pValue) { 149 CFXJSE_Value* pValue) {
150 CXFA_Object* lpOrginalNode = ToObject(pObject, nullptr); 150 CXFA_Object* lpOrginalNode = ToObject(pObject, nullptr);
151 CXFA_Document* pDoc = lpOrginalNode->GetDocument(); 151 CXFA_Document* pDoc = lpOrginalNode->GetDocument();
152 CXFA_ScriptContext* lpScriptContext = pDoc->GetScriptContext(); 152 CXFA_ScriptContext* lpScriptContext = pDoc->GetScriptContext();
153 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode); 153 CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode);
154 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName); 154 CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
155 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings | 155 uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings |
156 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 156 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
157 XFA_RESOLVENODE_Attributes; 157 XFA_RESOLVENODE_Attributes;
158 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 158 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
159 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 159 if (lpOrginalNode->IsVariablesThis())
160 pRefNode = ToNode(lpCurNode); 160 pRefNode = ToNode(lpCurNode);
161 }
162 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue, 161 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue,
163 dwFlag, TRUE)) { 162 dwFlag, TRUE)) {
164 return; 163 return;
165 } 164 }
166 if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 165 if (lpOrginalNode->IsVariablesThis()) {
167 if (pValue && pValue->IsUndefined()) { 166 if (pValue && pValue->IsUndefined()) {
168 pObject->SetObjectOwnProperty(szPropName, pValue); 167 pObject->SetObjectOwnProperty(szPropName, pValue);
169 return; 168 return;
170 } 169 }
171 } 170 }
172 CXFA_FFNotify* pNotify = pDoc->GetNotify(); 171 CXFA_FFNotify* pNotify = pDoc->GetNotify();
173 if (!pNotify) { 172 if (!pNotify) {
174 return; 173 return;
175 } 174 }
176 pNotify->GetDocProvider()->SetGlobalProperty(pNotify->GetHDOC(), szPropName, 175 pNotify->GetDocProvider()->SetGlobalProperty(pNotify->GetHDOC(), szPropName,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 lpScriptContext->GetDocument()->GetXFAObject(uHashCode); 218 lpScriptContext->GetDocument()->GetXFAObject(uHashCode);
220 if (pObj) { 219 if (pObj) {
221 pValue->Assign(lpScriptContext->GetJSValueFromMap(pObj)); 220 pValue->Assign(lpScriptContext->GetJSValueFromMap(pObj));
222 return; 221 return;
223 } 222 }
224 } 223 }
225 } 224 }
226 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 225 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
227 XFA_RESOLVENODE_Attributes; 226 XFA_RESOLVENODE_Attributes;
228 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); 227 CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject());
229 if (pOriginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) { 228 if (pOriginalObject->IsVariablesThis()) {
230 pRefNode = ToNode(lpCurNode); 229 pRefNode = ToNode(lpCurNode);
231 } 230 }
232 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue, 231 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue,
233 dwFlag, FALSE)) { 232 dwFlag, FALSE)) {
234 return; 233 return;
235 } 234 }
236 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; 235 dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
237 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue, 236 if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), pValue,
238 dwFlag, FALSE)) { 237 dwFlag, FALSE)) {
239 return; 238 return;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 CFXJSE_Context* pVariablesContext = 425 CFXJSE_Context* pVariablesContext =
427 CFXJSE_Context::Create(m_pIsolate, &VariablesClassDescriptor, 426 CFXJSE_Context::Create(m_pIsolate, &VariablesClassDescriptor,
428 new CXFA_ThisProxy(pSubform, pScriptNode)); 427 new CXFA_ThisProxy(pSubform, pScriptNode));
429 RemoveBuiltInObjs(pVariablesContext); 428 RemoveBuiltInObjs(pVariablesContext);
430 pVariablesContext->EnableCompatibleMode(); 429 pVariablesContext->EnableCompatibleMode();
431 m_mapVariableToContext.SetAt(pScriptNode, pVariablesContext); 430 m_mapVariableToContext.SetAt(pScriptNode, pVariablesContext);
432 return pVariablesContext; 431 return pVariablesContext;
433 } 432 }
434 CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject, 433 CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject,
435 FX_BOOL bScriptNode) { 434 FX_BOOL bScriptNode) {
436 if (pObject->GetObjectType() != XFA_OBJECTTYPE_VariablesThis) 435 if (!pObject->IsVariablesThis())
437 return pObject; 436 return pObject;
438 437
439 CXFA_ThisProxy* pProxy = static_cast<CXFA_ThisProxy*>(pObject); 438 CXFA_ThisProxy* pProxy = static_cast<CXFA_ThisProxy*>(pObject);
440 return bScriptNode ? pProxy->GetScriptNode() : pProxy->GetThisNode(); 439 return bScriptNode ? pProxy->GetScriptNode() : pProxy->GetThisNode();
441 } 440 }
442 441
443 FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { 442 FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) {
444 if (!pScriptNode) 443 if (!pScriptNode)
445 return FALSE; 444 return FALSE;
446 445
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 return; 736 return;
738 if (nodes.GetSize() > 0) 737 if (nodes.GetSize() > 0)
739 m_pScriptNodeArray->Copy(nodes); 738 m_pScriptNodeArray->Copy(nodes);
740 } 739 }
741 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { 740 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) {
742 if (!m_pScriptNodeArray) 741 if (!m_pScriptNodeArray)
743 return; 742 return;
744 if (m_pScriptNodeArray->Find(pNode) == -1) 743 if (m_pScriptNodeArray->Find(pNode) == -1)
745 m_pScriptNodeArray->Add(pNode); 744 m_pScriptNodeArray->Add(pNode);
746 } 745 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_parser_imp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698