| OLD | NEW |
| 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_layout_itemlayout.h" | 7 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 208 } |
| 209 static FX_BOOL XFA_ExistContainerKeep(CXFA_Node* pCurNode, FX_BOOL bPreFind) { | 209 static FX_BOOL XFA_ExistContainerKeep(CXFA_Node* pCurNode, FX_BOOL bPreFind) { |
| 210 if (pCurNode == NULL || !XFA_ItemLayoutProcessor_IsTakingSpace(pCurNode)) { | 210 if (pCurNode == NULL || !XFA_ItemLayoutProcessor_IsTakingSpace(pCurNode)) { |
| 211 return FALSE; | 211 return FALSE; |
| 212 } | 212 } |
| 213 XFA_NODEITEM eItemType = XFA_NODEITEM_PrevSibling; | 213 XFA_NODEITEM eItemType = XFA_NODEITEM_PrevSibling; |
| 214 if (!bPreFind) { | 214 if (!bPreFind) { |
| 215 eItemType = XFA_NODEITEM_NextSibling; | 215 eItemType = XFA_NODEITEM_NextSibling; |
| 216 } | 216 } |
| 217 CXFA_Node* pPreContainer = | 217 CXFA_Node* pPreContainer = |
| 218 pCurNode->GetNodeItem(eItemType, XFA_OBJECTTYPE_ContainerNode); | 218 pCurNode->GetNodeItem(eItemType, XFA_ObjectType::ContainerNode); |
| 219 if (pPreContainer == NULL) { | 219 if (pPreContainer == NULL) { |
| 220 return FALSE; | 220 return FALSE; |
| 221 } | 221 } |
| 222 CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Keep); | 222 CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Keep); |
| 223 if (pKeep) { | 223 if (pKeep) { |
| 224 XFA_ATTRIBUTEENUM ePrevious; | 224 XFA_ATTRIBUTEENUM ePrevious; |
| 225 XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Previous; | 225 XFA_ATTRIBUTE eKeepType = XFA_ATTRIBUTE_Previous; |
| 226 if (!bPreFind) { | 226 if (!bPreFind) { |
| 227 eKeepType = XFA_ATTRIBUTE_Next; | 227 eKeepType = XFA_ATTRIBUTE_Next; |
| 228 } | 228 } |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 return; | 760 return; |
| 761 } | 761 } |
| 762 } | 762 } |
| 763 goto CheckNextChildContainer; | 763 goto CheckNextChildContainer; |
| 764 } | 764 } |
| 765 } | 765 } |
| 766 CheckNextChildContainer : { | 766 CheckNextChildContainer : { |
| 767 CXFA_Node* pNextChildContainer = | 767 CXFA_Node* pNextChildContainer = |
| 768 pChildContainer == XFA_LAYOUT_INVALIDNODE | 768 pChildContainer == XFA_LAYOUT_INVALIDNODE |
| 769 ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild, | 769 ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild, |
| 770 XFA_OBJECTTYPE_ContainerNode) | 770 XFA_ObjectType::ContainerNode) |
| 771 : pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, | 771 : pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, |
| 772 XFA_OBJECTTYPE_ContainerNode); | 772 XFA_ObjectType::ContainerNode); |
| 773 while (pNextChildContainer && | 773 while (pNextChildContainer && |
| 774 pNextChildContainer->HasFlag(XFA_NODEFLAG_LayoutGeneratedNode)) { | 774 pNextChildContainer->IsLayoutGeneratedNode()) { |
| 775 CXFA_Node* pSaveNode = pNextChildContainer; | 775 CXFA_Node* pSaveNode = pNextChildContainer; |
| 776 pNextChildContainer = pNextChildContainer->GetNodeItem( | 776 pNextChildContainer = pNextChildContainer->GetNodeItem( |
| 777 XFA_NODEITEM_NextSibling, XFA_OBJECTTYPE_ContainerNode); | 777 XFA_NODEITEM_NextSibling, XFA_ObjectType::ContainerNode); |
| 778 if (pSaveNode->HasFlag(XFA_NODEFLAG_UnusedNode)) { | 778 if (pSaveNode->IsUnusedNode()) |
| 779 XFA_DeleteLayoutGeneratedNode(pSaveNode); | 779 XFA_DeleteLayoutGeneratedNode(pSaveNode); |
| 780 } | |
| 781 } | 780 } |
| 782 if (!pNextChildContainer) { | 781 if (!pNextChildContainer) { |
| 783 goto NoMoreChildContainer; | 782 goto NoMoreChildContainer; |
| 784 } | 783 } |
| 785 FX_BOOL bLastKeep = FALSE; | 784 FX_BOOL bLastKeep = FALSE; |
| 786 if (ProcessKeepNodesForCheckNext(pCurActionNode, nCurStage, | 785 if (ProcessKeepNodesForCheckNext(pCurActionNode, nCurStage, |
| 787 pNextChildContainer, bLastKeep)) { | 786 pNextChildContainer, bLastKeep)) { |
| 788 return; | 787 return; |
| 789 } | 788 } |
| 790 if (!m_bKeepBreakFinish && !bLastKeep && | 789 if (!m_bKeepBreakFinish && !bLastKeep && |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 pFormNode); | 1888 pFormNode); |
| 1890 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; | 1889 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; |
| 1891 pNode = sIterator.MoveToNext()) { | 1890 pNode = sIterator.MoveToNext()) { |
| 1892 if (pNode->IsContainerNode()) { | 1891 if (pNode->IsContainerNode()) { |
| 1893 CXFA_Node* pBindNode = pNode->GetBindData(); | 1892 CXFA_Node* pBindNode = pNode->GetBindData(); |
| 1894 if (pBindNode) { | 1893 if (pBindNode) { |
| 1895 pBindNode->RemoveBindItem(pNode); | 1894 pBindNode->RemoveBindItem(pNode); |
| 1896 pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 1895 pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); |
| 1897 } | 1896 } |
| 1898 } | 1897 } |
| 1899 pNode->SetFlag(XFA_NODEFLAG_UnusedNode, true); | 1898 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); |
| 1900 } | 1899 } |
| 1901 } | 1900 } |
| 1902 void CXFA_ItemLayoutProcessor::ProcessUnUseOverFlow( | 1901 void CXFA_ItemLayoutProcessor::ProcessUnUseOverFlow( |
| 1903 CXFA_Node* pLeaderNode, | 1902 CXFA_Node* pLeaderNode, |
| 1904 CXFA_Node* pTrailerNode, | 1903 CXFA_Node* pTrailerNode, |
| 1905 CXFA_ContentLayoutItem* pTrailerItem, | 1904 CXFA_ContentLayoutItem* pTrailerItem, |
| 1906 CXFA_Node* pFormNode) { | 1905 CXFA_Node* pFormNode) { |
| 1907 ProcessUnUseBinds(pLeaderNode); | 1906 ProcessUnUseBinds(pLeaderNode); |
| 1908 ProcessUnUseBinds(pTrailerNode); | 1907 ProcessUnUseBinds(pTrailerNode); |
| 1909 if (pFormNode == NULL) { | 1908 if (pFormNode == NULL) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 pProcessor, fSplitPos, pTrailerLayoutItem, bUseInherited); | 2159 pProcessor, fSplitPos, pTrailerLayoutItem, bUseInherited); |
| 2161 } else { | 2160 } else { |
| 2162 pProcessor->SplitLayoutItem(fSplitPos); | 2161 pProcessor->SplitLayoutItem(fSplitPos); |
| 2163 } | 2162 } |
| 2164 if (bUseInherited) { | 2163 if (bUseInherited) { |
| 2165 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | 2164 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, |
| 2166 pOverflowTrailerNode, | 2165 pOverflowTrailerNode, |
| 2167 pTrailerLayoutItem, pFormNode); | 2166 pTrailerLayoutItem, pFormNode); |
| 2168 pThis->m_bUseInheriated = TRUE; | 2167 pThis->m_bUseInheriated = TRUE; |
| 2169 } else { | 2168 } else { |
| 2170 if (pProcessor->m_pLayoutItem->m_pFirstChild && | 2169 CXFA_LayoutItem* firstChild = |
| 2171 pProcessor->m_pLayoutItem->m_pFirstChild->m_pNextSibling == | 2170 pProcessor->m_pLayoutItem->m_pFirstChild; |
| 2172 NULL && | 2171 if (firstChild && !firstChild->m_pNextSibling && |
| 2173 pProcessor->m_pLayoutItem->m_pFirstChild->m_pFormNode->HasFlag( | 2172 firstChild->m_pFormNode->IsLayoutGeneratedNode()) { |
| 2174 XFA_NODEFLAG_LayoutGeneratedNode)) { | |
| 2175 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, | 2173 pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, |
| 2176 pOverflowTrailerNode, | 2174 pOverflowTrailerNode, |
| 2177 pTrailerLayoutItem, pFormNode); | 2175 pTrailerLayoutItem, pFormNode); |
| 2178 } else { | 2176 } else { |
| 2179 if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { | 2177 if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode)) { |
| 2180 XFA_ItemLayoutProcessor_AddPendingNode( | 2178 XFA_ItemLayoutProcessor_AddPendingNode( |
| 2181 pProcessor, pOverflowLeaderNode, FALSE); | 2179 pProcessor, pOverflowLeaderNode, FALSE); |
| 2182 } | 2180 } |
| 2183 } | 2181 } |
| 2184 } | 2182 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2297 if (!bContainerHeightAutoSize) { | 2295 if (!bContainerHeightAutoSize) { |
| 2298 fContainerHeight -= m_fUsedSize; | 2296 fContainerHeight -= m_fUsedSize; |
| 2299 } | 2297 } |
| 2300 if (!bContainerHeightAutoSize) { | 2298 if (!bContainerHeightAutoSize) { |
| 2301 CXFA_Node* pParentNode = m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent); | 2299 CXFA_Node* pParentNode = m_pFormNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 2302 FX_BOOL bFocrTb = FALSE; | 2300 FX_BOOL bFocrTb = FALSE; |
| 2303 if (pParentNode && | 2301 if (pParentNode && |
| 2304 XFA_ItemLayoutProcessor_GetLayout(pParentNode, bFocrTb) == | 2302 XFA_ItemLayoutProcessor_GetLayout(pParentNode, bFocrTb) == |
| 2305 XFA_ATTRIBUTEENUM_Row) { | 2303 XFA_ATTRIBUTEENUM_Row) { |
| 2306 CXFA_Node* pChildContainer = m_pFormNode->GetNodeItem( | 2304 CXFA_Node* pChildContainer = m_pFormNode->GetNodeItem( |
| 2307 XFA_NODEITEM_FirstChild, XFA_OBJECTTYPE_ContainerNode); | 2305 XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode); |
| 2308 if (pChildContainer && | 2306 if (pChildContainer && |
| 2309 pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, | 2307 pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling, |
| 2310 XFA_OBJECTTYPE_ContainerNode)) { | 2308 XFA_ObjectType::ContainerNode)) { |
| 2311 fContainerHeight = 0; | 2309 fContainerHeight = 0; |
| 2312 bContainerHeightAutoSize = TRUE; | 2310 bContainerHeightAutoSize = TRUE; |
| 2313 } | 2311 } |
| 2314 } | 2312 } |
| 2315 } | 2313 } |
| 2316 CXFA_Node* pMarginNode = | 2314 CXFA_Node* pMarginNode = |
| 2317 m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); | 2315 m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Margin); |
| 2318 FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; | 2316 FX_FLOAT fLeftInset = 0, fTopInset = 0, fRightInset = 0, fBottomInset = 0; |
| 2319 if (pMarginNode) { | 2317 if (pMarginNode) { |
| 2320 fLeftInset = | 2318 fLeftInset = |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 if (iMax < 0) | 2985 if (iMax < 0) |
| 2988 return TRUE; | 2986 return TRUE; |
| 2989 | 2987 |
| 2990 int32_t iCount = m_PendingNodesCount[pTemplate]; | 2988 int32_t iCount = m_PendingNodesCount[pTemplate]; |
| 2991 if (iCount >= iMax) | 2989 if (iCount >= iMax) |
| 2992 return FALSE; | 2990 return FALSE; |
| 2993 | 2991 |
| 2994 m_PendingNodesCount[pTemplate] = iCount + 1; | 2992 m_PendingNodesCount[pTemplate] = iCount + 1; |
| 2995 return TRUE; | 2993 return TRUE; |
| 2996 } | 2994 } |
| OLD | NEW |