diff options
Diffstat (limited to 'fxjs')
-rw-r--r-- | fxjs/cfxjse_engine.cpp | 8 | ||||
-rw-r--r-- | fxjs/cfxjse_formcalc_context.cpp | 10 | ||||
-rw-r--r-- | fxjs/cfxjse_resolveprocessor.cpp | 6 | ||||
-rw-r--r-- | fxjs/xfa/cjx_layoutpseudomodel.cpp | 2 | ||||
-rw-r--r-- | fxjs/xfa/cjx_model.cpp | 4 | ||||
-rw-r--r-- | fxjs/xfa/cjx_node.cpp | 9 | ||||
-rw-r--r-- | fxjs/xfa/cjx_node.h | 14 | ||||
-rw-r--r-- | fxjs/xfa/cjx_object.cpp | 71 | ||||
-rw-r--r-- | fxjs/xfa/cjx_object.h | 11 |
9 files changed, 67 insertions, 68 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index 9d37f3e409..65aedddf4f 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -352,7 +352,7 @@ void CFXJSE_Engine::NormalPropertySetter(CFXJSE_Value* pOriginalValue, CXFA_Node* pPropOrChild = nullptr; XFA_Element eType = CXFA_Node::NameToElement(wsPropName); if (eType != XFA_Element::Unknown) - pPropOrChild = pNode->JSNode()->GetProperty(0, eType, true); + pPropOrChild = pNode->JSObject()->GetProperty(0, eType, true); else pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsStringView()); @@ -360,8 +360,8 @@ void CFXJSE_Engine::NormalPropertySetter(CFXJSE_Value* pOriginalValue, const XFA_SCRIPTATTRIBUTEINFO* lpAttrInfo = XFA_GetScriptAttributeByName( pPropOrChild->GetElementType(), L"{default}"); if (lpAttrInfo) { - pPropOrChild->JSNode()->Script_Som_DefaultValue(pReturnValue, true, - XFA_Attribute::Unknown); + pPropOrChild->JSObject()->Script_Som_DefaultValue( + pReturnValue, true, XFA_Attribute::Unknown); return; } } @@ -465,7 +465,7 @@ bool CFXJSE_Engine::RunVariablesScript(CXFA_Node* pScriptNode) { return false; pdfium::Optional<WideString> wsScript = - pTextNode->JSNode()->TryCData(XFA_Attribute::Value, true); + pTextNode->JSObject()->TryCData(XFA_Attribute::Value, true); if (!wsScript) return false; diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp index 1777102e06..b02e5a9d41 100644 --- a/fxjs/cfxjse_formcalc_context.cpp +++ b/fxjs/cfxjse_formcalc_context.cpp @@ -5853,8 +5853,8 @@ void CFXJSE_FormCalcContext::GetObjectDefaultValue( pDefaultValue->SetNull(); return; } - pNode->JSNode()->Script_Som_DefaultValue(pDefaultValue, false, - XFA_Attribute::Unknown); + pNode->JSObject()->Script_Som_DefaultValue(pDefaultValue, false, + XFA_Attribute::Unknown); } // static @@ -5864,8 +5864,8 @@ bool CFXJSE_FormCalcContext::SetObjectDefaultValue(CFXJSE_Value* pValue, if (!pNode) return false; - pNode->JSNode()->Script_Som_DefaultValue(hNewValue, true, - XFA_Attribute::Unknown); + pNode->JSObject()->Script_Som_DefaultValue(hNewValue, true, + XFA_Attribute::Unknown); return true; } @@ -5951,7 +5951,7 @@ bool CFXJSE_FormCalcContext::ResolveObjects(CFXJSE_Value* pThis, WideString wsName; if (CXFA_Node* pXFANode = pNode->AsNode()) { pdfium::Optional<WideString> ret = - pXFANode->JSNode()->TryAttribute(XFA_Attribute::Name, false); + pXFANode->JSObject()->TryAttribute(XFA_Attribute::Name, false); if (ret) wsName = *ret; } diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp index 9c0121dc52..f3e4a21312 100644 --- a/fxjs/cfxjse_resolveprocessor.cpp +++ b/fxjs/cfxjse_resolveprocessor.cpp @@ -345,13 +345,13 @@ bool CFXJSE_ResolveProcessor::ResolveNormal(CFXJSE_ResolveNodeData& rnd) { CXFA_Node* pInstanceManager = curNode->AsNode()->GetInstanceMgrOfSubform(); if (pInstanceManager) { - pProp = pInstanceManager->JSNode()->GetProperty(0, XFA_Element::Occur, - true); + pProp = pInstanceManager->JSObject()->GetProperty(0, XFA_Element::Occur, + true); } } else { XFA_Element eType = CXFA_Node::NameToElement(wsName); if (eType != XFA_Element::Unknown) { - pProp = curNode->AsNode()->JSNode()->GetProperty( + pProp = curNode->AsNode()->JSObject()->GetProperty( 0, eType, eType != XFA_Element::PageSet); } } diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp index 4165a36e57..e3e0fea5f9 100644 --- a/fxjs/xfa/cjx_layoutpseudomodel.cpp +++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp @@ -163,7 +163,7 @@ CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CJS_V8* runtime, continue; CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage(); - if (pMasterPage->JSNode()->GetInteger(XFA_Attribute::Numbered)) + if (pMasterPage->JSObject()->GetInteger(XFA_Attribute::Numbered)) iPageCount++; } } else { diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp index 7ab90e29ba..4ac6280c44 100644 --- a/fxjs/xfa/cjx_model.cpp +++ b/fxjs/xfa/cjx_model.cpp @@ -55,8 +55,8 @@ CJS_Return CJX_Model::createNode( if (!pNewNode->HasAttribute(XFA_Attribute::Name)) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - pNewNode->JSNode()->SetAttribute(XFA_Attribute::Name, name.AsStringView(), - true); + pNewNode->JSObject()->SetAttribute(XFA_Attribute::Name, name.AsStringView(), + true); if (pNewNode->GetPacketType() == XFA_PacketType::Datasets) pNewNode->CreateXMLMappingNode(); } diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp index cceaa208fc..b2743f0176 100644 --- a/fxjs/xfa/cjx_node.cpp +++ b/fxjs/xfa/cjx_node.cpp @@ -6,6 +6,9 @@ #include "fxjs/xfa/cjx_node.h" +#include <memory> +#include <vector> + #include "core/fxcrt/cfx_memorystream.h" #include "core/fxcrt/fx_codepage.h" #include "fxjs/cfxjse_engine.h" @@ -186,7 +189,7 @@ CJS_Return CJX_Node::isPropertySpecified( bool bHas = !!GetProperty(iIndex, eType, true); if (!bHas && bParent && GetXFANode()->GetParent()) { // Also check on the parent. - auto* jsnode = GetXFANode()->GetParent()->JSNode(); + auto* jsnode = GetXFANode()->GetParent()->JSObject(); bHas = jsnode->HasAttribute(attr) || !!jsnode->GetProperty(iIndex, eType, true); } @@ -227,8 +230,8 @@ CJS_Return CJX_Node::loadXML(CJS_V8* runtime, CXFA_Node* pFakeRoot = GetXFANode()->Clone(false); WideString wsContentType = GetCData(XFA_Attribute::ContentType); if (!wsContentType.IsEmpty()) { - pFakeRoot->JSNode()->SetCData(XFA_Attribute::ContentType, - WideString(wsContentType), false, false); + pFakeRoot->JSObject()->SetCData(XFA_Attribute::ContentType, + WideString(wsContentType), false, false); } std::unique_ptr<CFX_XMLNode> pFakeXMLRoot(pFakeRoot->GetXMLMappingNode()); diff --git a/fxjs/xfa/cjx_node.h b/fxjs/xfa/cjx_node.h index 9d16d852bf..f54239aa67 100644 --- a/fxjs/xfa/cjx_node.h +++ b/fxjs/xfa/cjx_node.h @@ -7,18 +7,12 @@ #ifndef FXJS_XFA_CJX_NODE_H_ #define FXJS_XFA_CJX_NODE_H_ -#include <memory> -#include <vector> - -#include "core/fxcrt/unowned_ptr.h" #include "fxjs/CJX_Define.h" #include "fxjs/xfa/cjx_object.h" #include "fxjs/xfa/cjx_tree.h" #include "xfa/fxfa/fxfa_basic.h" -class CXFA_LayoutItem; class CXFA_Node; -class CXFA_WidgetData; class CJX_Node : public CJX_Tree { public: @@ -28,12 +22,6 @@ class CJX_Node : public CJX_Tree { CXFA_Node* GetXFANode(); const CXFA_Node* GetXFANode() const; - void SetLayoutItem(CXFA_LayoutItem* item) { layout_item_ = item; } - CXFA_LayoutItem* GetLayoutItem() const { return layout_item_.Get(); } - - void SetCalcRecursionCount(size_t count) { calc_recursion_count_ = count; } - size_t GetCalcRecursionCount() const { return calc_recursion_count_; } - JS_METHOD(applyXSL, CJX_Node); JS_METHOD(assignNode, CJX_Node); JS_METHOD(clone, CJX_Node); @@ -51,8 +39,6 @@ class CJX_Node : public CJX_Tree { XFA_Element eType); private: - UnownedPtr<CXFA_LayoutItem> layout_item_; - size_t calc_recursion_count_ = 0; static const CJX_MethodSpec MethodSpecs[]; }; diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index 04d053ce38..fc708584d7 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -602,10 +602,10 @@ bool CJX_Object::SetContent(const WideString& wsContent, CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); ASSERT(pChildValue); - pChildValue->JSNode()->SetCData(XFA_Attribute::ContentType, L"text/xml", - false, false); - pChildValue->JSNode()->SetContent(wsContent, wsContent, bNotify, - bScriptModify, false); + pChildValue->JSObject()->SetCData(XFA_Attribute::ContentType, + L"text/xml", false, false); + pChildValue->JSObject()->SetContent(wsContent, wsContent, bNotify, + bScriptModify, false); CXFA_Node* pBind = ToNode(GetXFAObject())->GetBindData(); if (bSyncData && pBind) { std::vector<WideString> wsSaveTextArray; @@ -645,8 +645,8 @@ bool CJX_Object::SetContent(const WideString& wsContent, while (iAddNodes-- > 0) { pValueNodes = pBind->CreateSamePacketNode(XFA_Element::DataValue); - pValueNodes->JSNode()->SetCData(XFA_Attribute::Name, L"value", - false, false); + pValueNodes->JSObject()->SetCData(XFA_Attribute::Name, L"value", + false, false); pValueNodes->CreateXMLMappingNode(); pBind->InsertChild(pValueNodes, nullptr); } @@ -663,15 +663,15 @@ bool CJX_Object::SetContent(const WideString& wsContent, pBind->GetNodeItem(XFA_NODEITEM_FirstChild); pValueNode; pValueNode = pValueNode->GetNodeItem( XFA_NODEITEM_NextSibling)) { - pValueNode->JSNode()->SetAttributeValue( + pValueNode->JSObject()->SetAttributeValue( wsSaveTextArray[i], wsSaveTextArray[i], false, false); i++; } } for (const auto& pArrayNode : *(pBind->GetBindItems())) { if (pArrayNode.Get() != ToNode(GetXFAObject())) { - pArrayNode->JSNode()->SetContent(wsContent, wsContent, bNotify, - bScriptModify, false); + pArrayNode->JSObject()->SetContent(wsContent, wsContent, bNotify, + bScriptModify, false); } } } @@ -686,17 +686,17 @@ bool CJX_Object::SetContent(const WideString& wsContent, CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); ASSERT(pChildValue); - pChildValue->JSNode()->SetContent(wsContent, wsContent, bNotify, - bScriptModify, false); + pChildValue->JSObject()->SetContent(wsContent, wsContent, bNotify, + bScriptModify, false); } pBindNode = ToNode(GetXFAObject())->GetBindData(); if (pBindNode && bSyncData) { - pBindNode->JSNode()->SetContent(wsContent, wsXMLValue, bNotify, - bScriptModify, false); + pBindNode->JSObject()->SetContent(wsContent, wsXMLValue, bNotify, + bScriptModify, false); for (const auto& pArrayNode : *(pBindNode->GetBindItems())) { if (pArrayNode.Get() != ToNode(GetXFAObject())) { - pArrayNode->JSNode()->SetContent(wsContent, wsContent, bNotify, - true, false); + pArrayNode->JSObject()->SetContent(wsContent, wsContent, bNotify, + true, false); } } } @@ -727,7 +727,7 @@ bool CJX_Object::SetContent(const WideString& wsContent, : XFA_Element::Sharptext); ToNode(GetXFAObject())->InsertChild(pContentRawDataNode, nullptr); } - return pContentRawDataNode->JSNode()->SetContent( + return pContentRawDataNode->JSObject()->SetContent( wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData); } case XFA_ObjectType::NodeC: @@ -748,8 +748,8 @@ bool CJX_Object::SetContent(const WideString& wsContent, if (pParent && pParent->IsContainerNode()) { pBindNode = pParent->GetBindData(); if (pBindNode) { - pBindNode->JSNode()->SetContent(wsContent, wsXMLValue, bNotify, - bScriptModify, false); + pBindNode->JSObject()->SetContent(wsContent, wsXMLValue, bNotify, + bScriptModify, false); } } } @@ -768,8 +768,8 @@ bool CJX_Object::SetContent(const WideString& wsContent, SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify); if (pBindNode && bSyncData) { for (const auto& pArrayNode : *(pBindNode->GetBindItems())) { - pArrayNode->JSNode()->SetContent(wsContent, wsContent, bNotify, - bScriptModify, false); + pArrayNode->JSObject()->SetContent(wsContent, wsContent, bNotify, + bScriptModify, false); } } return true; @@ -794,11 +794,11 @@ pdfium::Optional<WideString> CJX_Object::TryContent(bool bScriptModify, CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); if (pChildValue && XFA_FieldIsMultiListBox(ToNode(GetXFAObject()))) { - pChildValue->JSNode()->SetAttribute(XFA_Attribute::ContentType, - L"text/xml", false); + pChildValue->JSObject()->SetAttribute(XFA_Attribute::ContentType, + L"text/xml", false); } if (pChildValue) - return pChildValue->JSNode()->TryContent(bScriptModify, bProto); + return pChildValue->JSObject()->TryContent(bScriptModify, bProto); return {}; } break; @@ -821,7 +821,7 @@ pdfium::Optional<WideString> CJX_Object::TryContent(bool bScriptModify, ToNode(GetXFAObject())->CreateSamePacketNode(element); ToNode(GetXFAObject())->InsertChild(pContentRawDataNode, nullptr); } - return pContentRawDataNode->JSNode()->TryContent(bScriptModify, true); + return pContentRawDataNode->JSObject()->TryContent(bScriptModify, true); } case XFA_ObjectType::NodeC: case XFA_ObjectType::NodeV: @@ -913,7 +913,7 @@ void CJX_Object::SetMapModuleValue(void* pKey, void* pValue) { bool CJX_Object::GetMapModuleValue(void* pKey, void*& pValue) { for (CXFA_Node* pNode = ToNode(GetXFAObject()); pNode; pNode = pNode->GetTemplateNode()) { - XFA_MAPMODULEDATA* pModule = pNode->JSNode()->GetMapModuleData(); + XFA_MAPMODULEDATA* pModule = pNode->JSObject()->GetMapModuleData(); if (pModule) { auto it = pModule->m_ValueMap.find(pKey); if (it != pModule->m_ValueMap.end()) { @@ -973,7 +973,7 @@ bool CJX_Object::GetMapModuleBuffer(void* pKey, XFA_MAPDATABLOCK* pBuffer = nullptr; for (const CXFA_Node* pNode = ToNode(GetXFAObject()); pNode; pNode = pNode->GetTemplateNode()) { - XFA_MAPMODULEDATA* pModule = pNode->JSNode()->GetMapModuleData(); + XFA_MAPMODULEDATA* pModule = pNode->JSObject()->GetMapModuleData(); if (pModule) { auto it = pModule->m_BufferMap.find(pKey); if (it != pModule->m_BufferMap.end()) { @@ -1040,7 +1040,7 @@ void CJX_Object::RemoveMapModuleKey(void* pKey) { void CJX_Object::MergeAllData(CXFA_Object* pDstModule) { XFA_MAPMODULEDATA* pDstModuleData = - ToNode(pDstModule)->JSNode()->CreateMapModuleData(); + ToNode(pDstModule)->JSObject()->CreateMapModuleData(); XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData(); if (!pSrcModuleData) return; @@ -1092,18 +1092,18 @@ void CJX_Object::MoveBufferMapData(CXFA_Object* pDstModule) { bNeedMove = false; if (bNeedMove) - ToNode(pDstModule)->JSNode()->SetCalcData(ReleaseCalcData()); + ToNode(pDstModule)->JSObject()->SetCalcData(ReleaseCalcData()); if (!pDstModule->IsNodeV()) return; - WideString wsValue = ToNode(pDstModule)->JSNode()->GetContent(false); + WideString wsValue = ToNode(pDstModule)->JSObject()->GetContent(false); WideString wsFormatValue(wsValue); CXFA_WidgetData* pWidgetData = ToNode(pDstModule)->GetContainerWidgetData(); if (pWidgetData) wsFormatValue = pWidgetData->GetFormatDataValue(wsValue); ToNode(pDstModule) - ->JSNode() + ->JSObject() ->SetContent(wsValue, wsFormatValue, true, true, true); } @@ -1122,7 +1122,7 @@ void CJX_Object::MoveBufferMapData(CXFA_Object* pSrcModule, pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling); pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling); } - ToNode(pSrcModule)->JSNode()->MoveBufferMapData(pDstModule); + ToNode(pSrcModule)->JSObject()->MoveBufferMapData(pDstModule); } void CJX_Object::OnChanging(XFA_Attribute eAttr, bool bNotify) { @@ -1558,7 +1558,7 @@ void CJX_Object::Script_Som_InstanceIndex(CFXJSE_Value* pValue, if (!pManagerNode) return; - pManagerNode->JSNode()->InstanceManager_MoveInstance(iTo, iFrom); + pManagerNode->JSObject()->InstanceManager_MoveInstance(iTo, iFrom); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) return; @@ -1619,7 +1619,7 @@ void CJX_Object::Script_Field_DefaultValue(CFXJSE_Value* pValue, XFA_NODEITEM_FirstChild); if (pNode && pNode->GetElementType() == XFA_Element::Decimal) { if (pUIChild->GetElementType() == XFA_Element::NumericEdit && - (pNode->JSNode()->GetInteger(XFA_Attribute::FracDigits) == -1)) { + (pNode->JSObject()->GetInteger(XFA_Attribute::FracDigits) == -1)) { pValue->SetString(content.UTF8Encode().AsStringView()); } else { CFX_Decimal decimal(content.AsStringView()); @@ -1902,7 +1902,8 @@ void CJX_Object::Script_Subform_InstanceManager(CFXJSE_Value* pValue, ToNode(GetXFAObject())->GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { if (pNode->GetElementType() == XFA_Element::InstanceManager) { - WideString wsInstMgrName = pNode->JSNode()->GetCData(XFA_Attribute::Name); + WideString wsInstMgrName = + pNode->JSObject()->GetCData(XFA_Attribute::Name); if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName[0] == '_' && wsInstMgrName.Right(wsInstMgrName.GetLength() - 1) == wsName) { pInstanceMgr = pNode; @@ -2073,7 +2074,7 @@ pdfium::Optional<WideString> CJX_Object::TryNamespace() { } if (ToNode(GetXFAObject())->GetPacketType() != XFA_PacketType::Datasets) - return ToNode(GetXFAObject())->GetModelNode()->JSNode()->TryNamespace(); + return ToNode(GetXFAObject())->GetModelNode()->JSObject()->TryNamespace(); CFX_XMLNode* pXMLNode = ToNode(GetXFAObject())->GetXMLMappingNode(); if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index cb1fef62da..b704037e4f 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h @@ -23,6 +23,7 @@ class CFXJSE_Value; class CJS_V8; class CXFA_CalcData; class CXFA_Document; +class CXFA_LayoutItem; class CXFA_Object; struct XFA_MAPMODULEDATA; @@ -58,6 +59,12 @@ class CJX_Object { } CXFA_WidgetData* GetWidgetData() const { return widget_data_.get(); } + void SetCalcRecursionCount(size_t count) { calc_recursion_count_ = count; } + size_t GetCalcRecursionCount() const { return calc_recursion_count_; } + + void SetLayoutItem(CXFA_LayoutItem* item) { layout_item_ = item; } + CXFA_LayoutItem* GetLayoutItem() const { return layout_item_.Get(); } + bool HasMethod(const WideString& func) const; CJS_Return RunMethod(const WideString& func, const std::vector<v8::Local<v8::Value>>& params); @@ -353,11 +360,13 @@ class CJX_Object { void RemoveMapModuleKey(void* pKey); void MoveBufferMapData(CXFA_Object* pDstModule); - std::unique_ptr<CXFA_WidgetData> widget_data_; UnownedPtr<CXFA_Object> object_; + UnownedPtr<CXFA_LayoutItem> layout_item_; + std::unique_ptr<CXFA_WidgetData> widget_data_; std::unique_ptr<XFA_MAPMODULEDATA> map_module_data_; std::unique_ptr<CXFA_CalcData> calc_data_; std::map<ByteString, CJX_MethodCall> method_specs_; + size_t calc_recursion_count_ = 0; }; #endif // FXJS_XFA_CJX_OBJECT_H_ |