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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 static inline void XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( | 894 static inline void XFA_ItemLayoutProcessor_CalculateContainerSpecfiedSize( |
895 CXFA_Node* pFormNode, | 895 CXFA_Node* pFormNode, |
896 FX_FLOAT& fContainerWidth, | 896 FX_FLOAT& fContainerWidth, |
897 FX_FLOAT& fContainerHeight, | 897 FX_FLOAT& fContainerHeight, |
898 FX_BOOL& bContainerWidthAutoSize, | 898 FX_BOOL& bContainerWidthAutoSize, |
899 FX_BOOL& bContainerHeightAutoSize) { | 899 FX_BOOL& bContainerHeightAutoSize) { |
900 fContainerWidth = 0; | 900 fContainerWidth = 0; |
901 fContainerHeight = 0; | 901 fContainerHeight = 0; |
902 bContainerWidthAutoSize = TRUE; | 902 bContainerWidthAutoSize = TRUE; |
903 bContainerHeightAutoSize = TRUE; | 903 bContainerHeightAutoSize = TRUE; |
904 XFA_Element eClassID = pFormNode->GetElementType(); | 904 XFA_Element eType = pFormNode->GetElementType(); |
905 CXFA_Measurement mTmpValue; | 905 CXFA_Measurement mTmpValue; |
906 if (bContainerWidthAutoSize && (eClassID == XFA_Element::Subform || | 906 if (bContainerWidthAutoSize && |
907 eClassID == XFA_Element::ExclGroup) && | 907 (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) && |
908 pFormNode->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, FALSE) && | 908 pFormNode->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, FALSE) && |
909 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | 909 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { |
910 fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); | 910 fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); |
911 bContainerWidthAutoSize = FALSE; | 911 bContainerWidthAutoSize = FALSE; |
912 } | 912 } |
913 if (bContainerHeightAutoSize && (eClassID == XFA_Element::Subform || | 913 if (bContainerHeightAutoSize && |
914 eClassID == XFA_Element::ExclGroup) && | 914 (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) && |
915 pFormNode->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, FALSE) && | 915 pFormNode->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, FALSE) && |
916 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | 916 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { |
917 fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); | 917 fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); |
918 bContainerHeightAutoSize = FALSE; | 918 bContainerHeightAutoSize = FALSE; |
919 } | 919 } |
920 if (bContainerWidthAutoSize && eClassID == XFA_Element::Subform && | 920 if (bContainerWidthAutoSize && eType == XFA_Element::Subform && |
921 pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, FALSE) && | 921 pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, FALSE) && |
922 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | 922 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { |
923 fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); | 923 fContainerWidth = mTmpValue.ToUnit(XFA_UNIT_Pt); |
924 bContainerWidthAutoSize = FALSE; | 924 bContainerWidthAutoSize = FALSE; |
925 } | 925 } |
926 if (bContainerHeightAutoSize && eClassID == XFA_Element::Subform && | 926 if (bContainerHeightAutoSize && eType == XFA_Element::Subform && |
927 pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, FALSE) && | 927 pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, FALSE) && |
928 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { | 928 mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { |
929 fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); | 929 fContainerHeight = mTmpValue.ToUnit(XFA_UNIT_Pt); |
930 bContainerHeightAutoSize = FALSE; | 930 bContainerHeightAutoSize = FALSE; |
931 } | 931 } |
932 } | 932 } |
933 static inline void | 933 static inline void |
934 XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( | 934 XFA_ItemLayoutProcessor_CalculateContainerComponentSizeFromContentSize( |
935 CXFA_Node* pFormNode, | 935 CXFA_Node* pFormNode, |
936 FX_BOOL bContainerWidthAutoSize, | 936 FX_BOOL bContainerWidthAutoSize, |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, | 1211 fContainerWidth, bContainerHeightAutoSize, fContentCalculatedHeight, |
1212 fContainerHeight); | 1212 fContainerHeight); |
1213 SetCurrentComponentSize(fContainerWidth, fContainerHeight); | 1213 SetCurrentComponentSize(fContainerWidth, fContainerHeight); |
1214 } | 1214 } |
1215 static inline void XFA_ItemLayoutProcessor_UpdateWidgetSize( | 1215 static inline void XFA_ItemLayoutProcessor_UpdateWidgetSize( |
1216 CXFA_ContentLayoutItem* pLayoutItem, | 1216 CXFA_ContentLayoutItem* pLayoutItem, |
1217 FX_FLOAT& fWidth, | 1217 FX_FLOAT& fWidth, |
1218 FX_FLOAT& fHeight) { | 1218 FX_FLOAT& fHeight) { |
1219 CXFA_Node* pNode = pLayoutItem->m_pFormNode; | 1219 CXFA_Node* pNode = pLayoutItem->m_pFormNode; |
1220 ASSERT(pNode); | 1220 ASSERT(pNode); |
1221 XFA_Element eClassID = pNode->GetElementType(); | 1221 switch (pNode->GetElementType()) { |
1222 switch (eClassID) { | |
1223 case XFA_Element::Subform: | 1222 case XFA_Element::Subform: |
1224 case XFA_Element::Area: | 1223 case XFA_Element::Area: |
1225 case XFA_Element::ExclGroup: | 1224 case XFA_Element::ExclGroup: |
1226 case XFA_Element::SubformSet: { | 1225 case XFA_Element::SubformSet: { |
1227 if (fWidth < -XFA_LAYOUT_FLOAT_PERCISION) { | 1226 if (fWidth < -XFA_LAYOUT_FLOAT_PERCISION) { |
1228 fWidth = pLayoutItem->m_sSize.x; | 1227 fWidth = pLayoutItem->m_sSize.x; |
1229 } | 1228 } |
1230 if (fHeight < -XFA_LAYOUT_FLOAT_PERCISION) { | 1229 if (fHeight < -XFA_LAYOUT_FLOAT_PERCISION) { |
1231 fHeight = pLayoutItem->m_sSize.y; | 1230 fHeight = pLayoutItem->m_sSize.y; |
1232 } | 1231 } |
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2904 fWidth = fHeight; | 2903 fWidth = fHeight; |
2905 fHeight = fTmp; | 2904 fHeight = fTmp; |
2906 } | 2905 } |
2907 SetCurrentComponentSize(fWidth, fHeight); | 2906 SetCurrentComponentSize(fWidth, fHeight); |
2908 } | 2907 } |
2909 XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayout( | 2908 XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayout( |
2910 FX_BOOL bUseBreakControl, | 2909 FX_BOOL bUseBreakControl, |
2911 FX_FLOAT fHeightLimit, | 2910 FX_FLOAT fHeightLimit, |
2912 FX_FLOAT fRealHeight, | 2911 FX_FLOAT fRealHeight, |
2913 CXFA_LayoutContext* pContext) { | 2912 CXFA_LayoutContext* pContext) { |
2914 XFA_Element eClassID = m_pFormNode->GetElementType(); | 2913 switch (m_pFormNode->GetElementType()) { |
2915 switch (eClassID) { | |
2916 case XFA_Element::Subform: | 2914 case XFA_Element::Subform: |
2917 case XFA_Element::Area: | 2915 case XFA_Element::Area: |
2918 case XFA_Element::ExclGroup: | 2916 case XFA_Element::ExclGroup: |
2919 case XFA_Element::SubformSet: { | 2917 case XFA_Element::SubformSet: { |
2920 FX_BOOL bRootForceTb = FALSE; | 2918 FX_BOOL bRootForceTb = FALSE; |
2921 CXFA_Node* pLayoutNode = GetSubformSetParent(m_pFormNode); | 2919 CXFA_Node* pLayoutNode = GetSubformSetParent(m_pFormNode); |
2922 XFA_ATTRIBUTEENUM eLayoutStrategy = | 2920 XFA_ATTRIBUTEENUM eLayoutStrategy = |
2923 XFA_ItemLayoutProcessor_GetLayout(pLayoutNode, bRootForceTb); | 2921 XFA_ItemLayoutProcessor_GetLayout(pLayoutNode, bRootForceTb); |
2924 switch (eLayoutStrategy) { | 2922 switch (eLayoutStrategy) { |
2925 case XFA_ATTRIBUTEENUM_Tb: | 2923 case XFA_ATTRIBUTEENUM_Tb: |
(...skipping 61 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 |