diff options
-rw-r--r-- | fxjs/cjx_node.cpp | 70 | ||||
-rw-r--r-- | fxjs/cjx_node.h | 30 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 18 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.h | 1 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_contentlayoutitem.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_contentlayoutitem.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document.cpp | 12 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_document.h | 1 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 14 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 32 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutprocessor.cpp | 3 |
12 files changed, 82 insertions, 121 deletions
diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index b86c2fa6fb..ba55086261 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -826,7 +826,7 @@ void CJX_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { else pFakeXMLRoot = nullptr; } - MoveBufferMapData(pFakeRoot, GetXFANode(), XFA_CalcData); + MoveBufferMapData(pFakeRoot, GetXFANode()); } else { CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild); while (pChild) { @@ -3218,7 +3218,14 @@ pdfium::Optional<WideString> CJX_Node::TryCData(XFA_Attribute eAttr, bool bUseDefault) { void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); if (eAttr == XFA_Attribute::Value) { - WideString* pStr = (WideString*)GetUserData(pKey, true); + void* pData; + int32_t iBytes = 0; + WideString* pStr = nullptr; + if (GetMapModuleBuffer(pKey, pData, iBytes, true) && + iBytes == sizeof(void*)) { + memcpy(&pData, pData, iBytes); + pStr = reinterpret_cast<WideString*>(pData); + } if (pStr) return {*pStr}; } else { @@ -3278,11 +3285,6 @@ void CJX_Node::ReleaseBindingNodes() { node.Release(); } -void* CJX_Node::GetUserData(void* pKey, bool bProtoAlso) { - void* pData; - return TryUserData(pKey, pData, bProtoAlso) ? pData : nullptr; -} - bool CJX_Node::SetUserData(void* pKey, void* pData, XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { @@ -3291,13 +3293,6 @@ bool CJX_Node::SetUserData(void* pKey, return true; } -bool CJX_Node::TryUserData(void* pKey, void*& pData, bool bProtoAlso) { - int32_t iBytes = 0; - if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) - return false; - return iBytes == sizeof(void*) && memcpy(&pData, pData, iBytes); -} - bool CJX_Node::SetContent(const WideString& wsContent, const WideString& wsXMLValue, bool bNotify, @@ -3381,7 +3376,7 @@ bool CJX_Node::SetContent(const WideString& wsContent, } } for (const auto& pArrayNode : *(pBind->GetBindItems())) { - if (pArrayNode != GetXFANode()) { + if (pArrayNode.Get() != GetXFANode()) { pArrayNode->JSNode()->SetContent(wsContent, wsContent, bNotify, bScriptModify, false); } @@ -3406,7 +3401,7 @@ bool CJX_Node::SetContent(const WideString& wsContent, pBindNode->JSNode()->SetContent(wsContent, wsXMLValue, bNotify, bScriptModify, false); for (const auto& pArrayNode : *(pBindNode->GetBindItems())) { - if (pArrayNode != GetXFANode()) { + if (pArrayNode.Get() != GetXFANode()) { pArrayNode->JSNode()->SetContent(wsContent, wsContent, bNotify, true, false); } @@ -3554,6 +3549,14 @@ void CJX_Node::SetWidgetData(std::unique_ptr<CXFA_WidgetData> data) { widget_data_ = std::move(data); } +void CJX_Node::SetCalcData(std::unique_ptr<CXFA_CalcData> data) { + calc_data_ = std::move(data); +} + +std::unique_ptr<CXFA_CalcData> CJX_Node::ReleaseCalcData() { + return std::move(calc_data_); +} + pdfium::Optional<WideString> CJX_Node::TryNamespace() { if (GetXFANode()->IsModelNode() || GetXFANode()->GetElementType() == XFA_Element::Packet) { @@ -3819,35 +3822,16 @@ void CJX_Node::MergeAllData(CXFA_Node* pDstModule) { } } -void CJX_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { +void CJX_Node::MoveBufferMapData(CXFA_Node* pDstModule) { if (!pDstModule) return; bool bNeedMove = true; - if (!pKey) - bNeedMove = false; if (pDstModule->GetElementType() != GetXFANode()->GetElementType()) bNeedMove = false; - XFA_MAPMODULEDATA* pSrcModuleData = nullptr; - XFA_MAPMODULEDATA* pDstModuleData = nullptr; - if (bNeedMove) { - pSrcModuleData = GetMapModuleData(); - if (!pSrcModuleData) - bNeedMove = false; - - pDstModuleData = pDstModule->JSNode()->CreateMapModuleData(); - } - if (bNeedMove) { - auto it = pSrcModuleData->m_BufferMap.find(pKey); - if (it != pSrcModuleData->m_BufferMap.end()) { - XFA_MAPDATABLOCK* pBufferBlockData = it->second; - if (pBufferBlockData) { - pSrcModuleData->m_BufferMap.erase(pKey); - pDstModuleData->m_BufferMap[pKey] = pBufferBlockData; - } - } - } + if (bNeedMove) + pDstModule->JSNode()->SetCalcData(ReleaseCalcData()); if (!pDstModule->IsNodeV()) return; @@ -3860,21 +3844,19 @@ void CJX_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { pDstModule->JSNode()->SetContent(wsValue, wsFormatValue, true, true, true); } -void CJX_Node::MoveBufferMapData(CXFA_Node* pSrcModule, - CXFA_Node* pDstModule, - void* pKey) { - if (!pSrcModule || !pDstModule || !pKey) +void CJX_Node::MoveBufferMapData(CXFA_Node* pSrcModule, CXFA_Node* pDstModule) { + if (!pSrcModule || !pDstModule) return; CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild); CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild); while (pSrcChild && pDstChild) { - MoveBufferMapData(pSrcChild, pDstChild, pKey); + MoveBufferMapData(pSrcChild, pDstChild); pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling); pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling); } - pSrcModule->JSNode()->MoveBufferMapData(pDstModule, pKey); + pSrcModule->JSNode()->MoveBufferMapData(pDstModule); } int32_t CJX_Node::execSingleEventByName(const WideStringView& wsEventName, diff --git a/fxjs/cjx_node.h b/fxjs/cjx_node.h index 3393a52406..d0f8279e7f 100644 --- a/fxjs/cjx_node.h +++ b/fxjs/cjx_node.h @@ -30,6 +30,8 @@ enum XFA_SOM_MESSAGETYPE { }; class CFXJSE_Arguments; +class CXFA_CalcData; +class CXFA_LayoutItem; class CXFA_Node; class CXFA_WidgetData; @@ -100,11 +102,6 @@ class CJX_Node : public CJX_Object { bool SetMeasure(XFA_Attribute eAttr, CXFA_Measurement mValue, bool bNotify); CXFA_Measurement GetMeasure(XFA_Attribute eAttr) const; - bool SetUserData(void* pKey, - void* pData, - XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo); - void* GetUserData(void* pKey, bool bProtoAlso); - void SetBindingNodes(std::vector<UnownedPtr<CXFA_Node>> nodes) { binding_nodes_ = std::move(nodes); } @@ -127,6 +124,16 @@ class CJX_Node : public CJX_Object { void SetWidgetData(std::unique_ptr<CXFA_WidgetData> data); CXFA_WidgetData* GetWidgetData() const { return widget_data_.get(); } + void SetLayoutItem(CXFA_LayoutItem* item) { layout_item_ = item; } + CXFA_LayoutItem* GetLayoutItem() const { return layout_item_.Get(); } + + void SetCalcData(std::unique_ptr<CXFA_CalcData> data); + CXFA_CalcData* GetCalcData() const { return calc_data_.get(); } + std::unique_ptr<CXFA_CalcData> ReleaseCalcData(); + + void SetCalcRecursionCount(size_t count) { calc_recursion_count_ = count; } + size_t GetCalcRecursionCount() const { return calc_recursion_count_; } + pdfium::Optional<WideString> TryNamespace(); void MergeAllData(CXFA_Node* pDstModule); @@ -414,6 +421,10 @@ class CJX_Node : public CJX_Object { XFA_Attribute eAttribute); private: + bool SetUserData(void* pKey, + void* pData, + XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo); + void ResolveNodeList(CFXJSE_Value* pValue, WideString wsExpression, uint32_t dwFlag, @@ -447,17 +458,18 @@ class CJX_Node : public CJX_Object { bool HasMapModuleKey(void* pKey); void ClearMapModuleBuffer(); void RemoveMapModuleKey(void* pKey); - void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey); - void MoveBufferMapData(CXFA_Node* pSrcModule, - CXFA_Node* pDstModule, - void* pKey); + void MoveBufferMapData(CXFA_Node* pDstModule); + void MoveBufferMapData(CXFA_Node* pSrcModule, CXFA_Node* pDstModule); int32_t execSingleEventByName(const WideStringView& wsEventName, XFA_Element eType); std::unique_ptr<XFA_MAPMODULEDATA> map_module_data_; std::unique_ptr<CXFA_WidgetData> widget_data_; + std::unique_ptr<CXFA_CalcData> calc_data_; + UnownedPtr<CXFA_LayoutItem> layout_item_; std::vector<UnownedPtr<CXFA_Node>> binding_nodes_; + size_t calc_recursion_count_ = 0; }; #endif // FXJS_CJX_NODE_H_ diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 3895d54569..928bc1e0d4 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -33,8 +33,6 @@ #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" -#define XFA_CalcRefCount (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'R') - const XFA_ATTRIBUTEENUM gs_EventActivity[] = { XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change, XFA_ATTRIBUTEENUM_DocClose, XFA_ATTRIBUTEENUM_DocReady, @@ -616,8 +614,7 @@ void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { } void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { - auto* pGlobalData = static_cast<CXFA_CalcData*>( - pNodeChange->JSNode()->GetUserData(XFA_CalcData, false)); + CXFA_CalcData* pGlobalData = pNodeChange->JSNode()->GetCalcData(); if (!pGlobalData) return; @@ -631,13 +628,9 @@ size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) { while (index < m_CalculateAccs.size()) { CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[index]; AddCalculateNodeNotify(pCurAcc->GetNode()); - int32_t iRefCount = - (int32_t)(uintptr_t)pCurAcc->GetNode()->JSNode()->GetUserData( - XFA_CalcRefCount, false); - iRefCount++; - pCurAcc->GetNode()->JSNode()->SetUserData( - XFA_CalcRefCount, (void*)(uintptr_t)iRefCount, nullptr); - if (iRefCount > 11) + size_t recurse = pCurAcc->GetNode()->JSNode()->GetCalcRecursionCount() + 1; + pCurAcc->GetNode()->JSNode()->SetCalcRecursionCount(recurse); + if (recurse > 11) break; if (pCurAcc->ProcessCalculate() == XFA_EVENTERROR_Success) AddValidateWidget(pCurAcc); @@ -654,8 +647,7 @@ int32_t CXFA_FFDocView::RunCalculateWidgets() { RunCalculateRecursive(0); for (CXFA_WidgetAcc* pCurAcc : m_CalculateAccs) - pCurAcc->GetNode()->JSNode()->SetUserData(XFA_CalcRefCount, nullptr, - nullptr); + pCurAcc->GetNode()->JSNode()->SetCalcRecursionCount(0); m_CalculateAccs.clear(); return XFA_EVENTERROR_Success; diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 7bc3d6b682..2c20f1d33b 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -26,7 +26,6 @@ inline float XFA_UnitPx2Pt(float fPx, float fDpi) { } #define XFA_FLOAT_PERCISION 0.001f -#define XFA_CalcData (void*)(uintptr_t) FXBSTR_ID('X', 'F', 'A', 'C') enum XFA_WIDGETITEM { XFA_WIDGETITEM_Parent, diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index b019bf636c..6f852f3321 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -36,14 +36,6 @@ class CXFA_WidgetLayoutData { namespace { -void FFDeleteCalcData(void* pData) { - if (pData) - delete ((CXFA_CalcData*)pData); -} - -static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteCalcData = {FFDeleteCalcData, - nullptr}; - class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { public: CXFA_TextLayoutData() {} @@ -644,12 +636,10 @@ std::pair<int32_t, bool> CXFA_WidgetAcc::ExecuteBoolScript( if (static_cast<CXFA_WidgetAcc*>(pRefNode->GetWidgetData()) == this) continue; - auto* pGlobalData = static_cast<CXFA_CalcData*>( - pRefNode->JSNode()->GetUserData(XFA_CalcData, false)); + CXFA_CalcData* pGlobalData = pRefNode->JSNode()->GetCalcData(); if (!pGlobalData) { - pGlobalData = new CXFA_CalcData; - pRefNode->JSNode()->SetUserData(XFA_CalcData, pGlobalData, - &gs_XFADeleteCalcData); + pRefNode->JSNode()->SetCalcData(pdfium::MakeUnique<CXFA_CalcData>()); + pGlobalData = pRefNode->JSNode()->GetCalcData(); } if (!pdfium::ContainsValue(pGlobalData->m_Globals, this)) pGlobalData->m_Globals.push_back(this); diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp index 28871259ce..0c9cab4e2d 100644 --- a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp @@ -15,6 +15,6 @@ CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode) m_dwStatus(0) {} CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() { - if (m_pFormNode->JSNode()->GetUserData(XFA_LAYOUTITEMKEY, false) == this) - m_pFormNode->JSNode()->SetUserData(XFA_LAYOUTITEMKEY, nullptr, nullptr); + if (m_pFormNode->JSNode()->GetLayoutItem() == this) + m_pFormNode->JSNode()->SetLayoutItem(nullptr); } diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.h b/xfa/fxfa/parser/cxfa_contentlayoutitem.h index 9d1fc2abcf..500d3e4959 100644 --- a/xfa/fxfa/parser/cxfa_contentlayoutitem.h +++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.h @@ -9,8 +9,6 @@ #include "xfa/fxfa/parser/cxfa_layoutitem.h" -#define XFA_LAYOUTITEMKEY (void*)(uintptr_t) FXBSTR_ID('L', 'Y', 'I', 'M') - class CXFA_ContentLayoutItem : public CXFA_LayoutItem { public: explicit CXFA_ContentLayoutItem(CXFA_Node* pNode); diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index edae6c3837..bdb8d9a0e5 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -99,7 +99,10 @@ CXFA_Document::~CXFA_Document() { m_pRootNode->ReleaseBindingNodes(); delete m_pRootNode; - PurgeNodes(); + + for (CXFA_Node* pNode : m_PurgeNodes) + delete pNode; + m_PurgeNodes.clear(); } CXFA_LayoutProcessor* CXFA_Document::GetLayoutProcessor() { @@ -238,13 +241,6 @@ bool CXFA_Document::RemovePurgeNode(CXFA_Node* pNode) { return !!m_PurgeNodes.erase(pNode); } -void CXFA_Document::PurgeNodes() { - for (CXFA_Node* pNode : m_PurgeNodes) - delete pNode; - - m_PurgeNodes.clear(); -} - void CXFA_Document::SetFlag(uint32_t dwFlag, bool bOn) { if (bOn) m_dwDocFlags |= dwFlag; diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 4be4bb0475..45e9236ee8 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -79,7 +79,6 @@ class CXFA_Document { void AddPurgeNode(CXFA_Node* pNode); bool RemovePurgeNode(CXFA_Node* pNode); - void PurgeNodes(); bool HasFlag(uint32_t dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; } void SetFlag(uint32_t dwFlag, bool bOn); diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index bf63a2a56c..ec610293ce 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -612,8 +612,7 @@ void DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) { for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; pNode = sIterator.MoveToNext()) { CXFA_ContentLayoutItem* pCurLayoutItem = - (CXFA_ContentLayoutItem*)pNode->JSNode()->GetUserData(XFA_LAYOUTITEMKEY, - false); + static_cast<CXFA_ContentLayoutItem*>(pNode->JSNode()->GetLayoutItem()); CXFA_ContentLayoutItem* pNextLayoutItem = nullptr; while (pCurLayoutItem) { pNextLayoutItem = pCurLayoutItem->m_pNext; @@ -1156,9 +1155,8 @@ CXFA_ItemLayoutProcessor::CXFA_ItemLayoutProcessor(CXFA_Node* pNode, m_bHasAvailHeight(true) { ASSERT(m_pFormNode && (m_pFormNode->IsContainerNode() || m_pFormNode->GetElementType() == XFA_Element::Form)); - m_pOldLayoutItem = - (CXFA_ContentLayoutItem*)m_pFormNode->JSNode()->GetUserData( - XFA_LAYOUTITEMKEY, false); + m_pOldLayoutItem = static_cast<CXFA_ContentLayoutItem*>( + m_pFormNode->JSNode()->GetLayoutItem()); } CXFA_ItemLayoutProcessor::~CXFA_ItemLayoutProcessor() {} @@ -1178,8 +1176,8 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem( ->GetNotify() ->OnCreateLayoutItem(pFormNode); CXFA_ContentLayoutItem* pPrevLayoutItem = - (CXFA_ContentLayoutItem*)pFormNode->JSNode()->GetUserData( - XFA_LAYOUTITEMKEY, false); + static_cast<CXFA_ContentLayoutItem*>( + pFormNode->JSNode()->GetLayoutItem()); if (pPrevLayoutItem) { while (pPrevLayoutItem->m_pNext) pPrevLayoutItem = pPrevLayoutItem->m_pNext; @@ -1187,7 +1185,7 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem( pPrevLayoutItem->m_pNext = pLayoutItem; pLayoutItem->m_pPrev = pPrevLayoutItem; } else { - pFormNode->JSNode()->SetUserData(XFA_LAYOUTITEMKEY, pLayoutItem, nullptr); + pFormNode->JSNode()->SetLayoutItem(pLayoutItem); } return pLayoutItem; } diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 7a013a9a9b..2752b35718 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -285,8 +285,8 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) { new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot); } m_pPageSetCurRoot = m_pPageSetLayoutItemRoot; - m_pTemplatePageSetRoot->JSNode()->SetUserData( - XFA_LAYOUTITEMKEY, (void*)m_pPageSetLayoutItemRoot, nullptr); + m_pTemplatePageSetRoot->JSNode()->SetLayoutItem(m_pPageSetLayoutItemRoot); + XFA_ATTRIBUTEENUM eRelation = m_pTemplatePageSetRoot->JSNode()->GetEnum(XFA_Attribute::Relation); if (eRelation != XFA_ATTRIBUTEENUM_Unknown) @@ -505,7 +505,7 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( } else { CXFA_ContainerLayoutItem* pParentLayoutItem = static_cast<CXFA_ContainerLayoutItem*>( - pPageSet->JSNode()->GetUserData(XFA_LAYOUTITEMKEY, false)); + pPageSet->JSNode()->GetLayoutItem()); if (!pParentLayoutItem) pParentLayoutItem = m_pPageSetCurRoot; @@ -520,12 +520,11 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( pParentPageSetLayout = static_cast<CXFA_ContainerLayoutItem*>( pPageSet->GetNodeItem(XFA_NODEITEM_Parent) ->JSNode() - ->GetUserData(XFA_LAYOUTITEMKEY, false)); + ->GetLayoutItem()); } CXFA_ContainerLayoutItem* pPageSetLayoutItem = new CXFA_ContainerLayoutItem(pPageSet); - pPageSet->JSNode()->SetUserData(XFA_LAYOUTITEMKEY, - (void*)pPageSetLayoutItem, nullptr); + pPageSet->JSNode()->SetLayoutItem(pPageSetLayoutItem); if (!pParentPageSetLayout) { CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot; while (pPrePageSet->m_pNextSibling) { @@ -548,8 +547,7 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord( } else { CXFA_ContainerLayoutItem* pPageSetLayoutItem = new CXFA_ContainerLayoutItem(pPageSet); - pPageSet->JSNode()->SetUserData(XFA_LAYOUTITEMKEY, - (void*)pPageSetLayoutItem, nullptr); + pPageSet->JSNode()->SetLayoutItem(pPageSetLayoutItem); m_pPageSetLayoutItemRoot->AddChild(pPageSetLayoutItem); pNewRecord->pCurPageSet = pPageSetLayoutItem; } @@ -1730,10 +1728,9 @@ void CXFA_LayoutPageMgr::MergePageSetContents() { pPendingPageSet = pRootPageSetContainerItem->m_pFormNode; } } - if (pRootPageSetContainerItem->m_pFormNode->JSNode()->GetUserData( - XFA_LAYOUTITEMKEY, false) == pRootPageSetContainerItem) { - pRootPageSetContainerItem->m_pFormNode->JSNode()->SetUserData( - XFA_LAYOUTITEMKEY, nullptr, nullptr); + if (pRootPageSetContainerItem->m_pFormNode->JSNode()->GetLayoutItem() == + pRootPageSetContainerItem) { + pRootPageSetContainerItem->m_pFormNode->JSNode()->SetLayoutItem(nullptr); } pRootPageSetContainerItem->m_pFormNode = pPendingPageSet; pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode); @@ -1780,8 +1777,8 @@ void CXFA_LayoutPageMgr::MergePageSetContents() { for (CXFA_Node* pIter = sIterator.GetCurrent(); pIter; pIter = sIterator.MoveToNext()) { if (pIter->GetElementType() != XFA_Element::ContentArea) { - CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( - pIter->JSNode()->GetUserData(XFA_LAYOUTITEMKEY, false)); + CXFA_LayoutItem* pLayoutItem = + pIter->JSNode()->GetLayoutItem(); if (pLayoutItem) { pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); delete pLayoutItem; @@ -1844,16 +1841,15 @@ void CXFA_LayoutPageMgr::MergePageSetContents() { CXFA_ContainerIterator iteChild(pNode); CXFA_Node* pChildNode = iteChild.MoveToNext(); for (; pChildNode; pChildNode = iteChild.MoveToNext()) { - CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( - pChildNode->JSNode()->GetUserData(XFA_LAYOUTITEMKEY, false)); + CXFA_LayoutItem* pLayoutItem = + pChildNode->JSNode()->GetLayoutItem(); if (pLayoutItem) { pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); delete pLayoutItem; } } } else if (eType != XFA_Element::ContentArea) { - CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>( - pNode->JSNode()->GetUserData(XFA_LAYOUTITEMKEY, false)); + CXFA_LayoutItem* pLayoutItem = pNode->JSNode()->GetLayoutItem(); if (pLayoutItem) { pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); delete pLayoutItem; diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp index a2494e24b1..b8afd6ec19 100644 --- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp @@ -122,8 +122,7 @@ CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetPage(int32_t index) const { } CXFA_LayoutItem* CXFA_LayoutProcessor::GetLayoutItem(CXFA_Node* pFormItem) { - return static_cast<CXFA_LayoutItem*>( - pFormItem->JSNode()->GetUserData(XFA_LAYOUTITEMKEY, false)); + return pFormItem->JSNode()->GetLayoutItem(); } void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) { |