1 // Copyright 2014 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef FXJS_XFA_CFXJSE_RESOLVEPROCESSOR_H_ 8 #define FXJS_XFA_CFXJSE_RESOLVEPROCESSOR_H_ 9 10 #include <memory> 11 12 #include "core/fxcrt/unowned_ptr.h" 13 #include "core/fxcrt/widestring.h" 14 #include "fxjs/xfa/cfxjse_engine.h" 15 #include "v8/include/cppgc/macros.h" 16 #include "xfa/fxfa/fxfa_basic.h" 17 #include "xfa/fxfa/parser/xfa_basic_data.h" 18 19 class CFXJSE_NodeHelper; 20 21 class CFXJSE_ResolveProcessor { 22 public: 23 class NodeData { 24 CPPGC_STACK_ALLOCATED(); // Allows Raw/Unowned pointers. 25 26 public: 27 NodeData(); 28 ~NodeData(); 29 30 UnownedPtr<CXFA_Object> m_CurObject; // Ok, stack-only. 31 WideString m_wsName; 32 WideString m_wsCondition; 33 XFA_HashCode m_uHashName = XFA_HASHCODE_None; 34 int32_t m_nLevel = 0; 35 Mask<XFA_ResolveFlag> m_dwStyles = XFA_ResolveFlag::kChildren; 36 CFXJSE_Engine::ResolveResult m_Result; 37 }; 38 39 CFXJSE_ResolveProcessor(CFXJSE_Engine* pEngine, CFXJSE_NodeHelper* pHelper); 40 ~CFXJSE_ResolveProcessor(); 41 42 bool Resolve(v8::Isolate* pIsolate, NodeData& rnd); 43 int32_t GetFilter(WideStringView wsExpression, int32_t nStart, NodeData& rnd); 44 int32_t IndexForDataBind(const WideString& wsNextCondition, int32_t iCount); SetCurStart(int32_t start)45 void SetCurStart(int32_t start) { m_iCurStart = start; } 46 47 private: 48 bool ResolveForAttributeRs(CXFA_Object* curNode, 49 CFXJSE_Engine::ResolveResult* rnd, 50 WideStringView strAttr); 51 bool ResolveAnyChild(v8::Isolate* pIsolate, NodeData& rnd); 52 bool ResolveDollar(v8::Isolate* pIsolate, NodeData& rnd); 53 bool ResolveExcalmatory(v8::Isolate* pIsolate, NodeData& rnd); 54 bool ResolveNumberSign(v8::Isolate* pIsolate, NodeData& rnd); 55 bool ResolveAsterisk(NodeData& rnd); 56 bool ResolveNormal(v8::Isolate* pIsolate, NodeData& rnd); 57 void SetStylesForChild(Mask<XFA_ResolveFlag> dwParentStyles, NodeData& rnd); 58 59 void ConditionArray(size_t iCurIndex, 60 WideString wsCondition, 61 size_t iFoundCount, 62 NodeData* pRnd); 63 void FilterCondition(v8::Isolate* pIsolate, 64 WideString wsCondition, 65 NodeData* pRnd); 66 void DoPredicateFilter(v8::Isolate* pIsolate, 67 WideString wsCondition, 68 size_t iFoundCount, 69 NodeData* pRnd); 70 71 int32_t m_iCurStart = 0; 72 UnownedPtr<CFXJSE_Engine> const m_pEngine; 73 UnownedPtr<CFXJSE_NodeHelper> const m_pNodeHelper; 74 }; 75 76 #endif // FXJS_XFA_CFXJSE_RESOLVEPROCESSOR_H_ 77