diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-20 20:28:23 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-20 20:28:23 +0000 |
commit | e74ae8c02f6b5efa37ba11bcad6b714046cfc7b0 (patch) | |
tree | 1c5353b26b58732e5bda616ba5d9fc8f414a7037 /xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | |
parent | 68c77592f25f9173d2166fa01fb34b4155f4cfcb (diff) | |
download | pdfium-e74ae8c02f6b5efa37ba11bcad6b714046cfc7b0.tar.xz |
Convert calc data and layout item to store in CJX_Node
This CL moves the XFA_CalcData and XFA_LayoutItem out of the map'd data
for a CJX_Node and stores directly on the node. This makes the object a
bit bigger but makes the code a lot more understandable.
Change-Id: I8897a52d61d37595181960c23928984aa5d67efc
Reviewed-on: https://pdfium-review.googlesource.com/18590
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_layoutpagemgr.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
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; |