OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 enum FlexSign { | 69 enum FlexSign { |
70 PositiveFlexibility, | 70 PositiveFlexibility, |
71 NegativeFlexibility, | 71 NegativeFlexibility, |
72 }; | 72 }; |
73 | 73 |
74 enum PositionedLayoutMode { | 74 enum PositionedLayoutMode { |
75 FlipForRowReverse, | 75 FlipForRowReverse, |
76 NoFlipForRowReverse, | 76 NoFlipForRowReverse, |
77 }; | 77 }; |
78 | 78 |
79 typedef HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize; | 79 typedef HashMap<const LayoutBox*, LayoutUnit> InflexibleFlexItemSize; |
80 typedef Vector<RenderBox*> OrderedFlexItemList; | 80 typedef Vector<LayoutBox*> OrderedFlexItemList; |
81 | 81 |
82 struct LineContext; | 82 struct LineContext; |
83 struct Violation; | 83 struct Violation; |
84 | 84 |
85 // Use an inline capacity of 8, since flexbox containers usually have less t
han 8 children. | 85 // Use an inline capacity of 8, since flexbox containers usually have less t
han 8 children. |
86 typedef Vector<LayoutRect, 8> ChildFrameRects; | 86 typedef Vector<LayoutRect, 8> ChildFrameRects; |
87 | 87 |
88 bool hasOrthogonalFlow(RenderBox& child) const; | 88 bool hasOrthogonalFlow(LayoutBox& child) const; |
89 bool isColumnFlow() const; | 89 bool isColumnFlow() const; |
90 bool isLeftToRightFlow() const; | 90 bool isLeftToRightFlow() const; |
91 bool isMultiline() const; | 91 bool isMultiline() const; |
92 Length flexBasisForChild(RenderBox& child) const; | 92 Length flexBasisForChild(LayoutBox& child) const; |
93 LayoutUnit crossAxisExtentForChild(RenderBox& child) const; | 93 LayoutUnit crossAxisExtentForChild(LayoutBox& child) const; |
94 LayoutUnit crossAxisIntrinsicExtentForChild(RenderBox& child) const; | 94 LayoutUnit crossAxisIntrinsicExtentForChild(LayoutBox& child) const; |
95 LayoutUnit childIntrinsicHeight(RenderBox& child) const; | 95 LayoutUnit childIntrinsicHeight(LayoutBox& child) const; |
96 LayoutUnit childIntrinsicWidth(RenderBox& child) const; | 96 LayoutUnit childIntrinsicWidth(LayoutBox& child) const; |
97 LayoutUnit mainAxisExtentForChild(RenderBox& child) const; | 97 LayoutUnit mainAxisExtentForChild(LayoutBox& child) const; |
98 LayoutUnit crossAxisExtent() const; | 98 LayoutUnit crossAxisExtent() const; |
99 LayoutUnit mainAxisExtent() const; | 99 LayoutUnit mainAxisExtent() const; |
100 LayoutUnit crossAxisContentExtent() const; | 100 LayoutUnit crossAxisContentExtent() const; |
101 LayoutUnit mainAxisContentExtent(LayoutUnit contentLogicalHeight); | 101 LayoutUnit mainAxisContentExtent(LayoutUnit contentLogicalHeight); |
102 LayoutUnit computeMainAxisExtentForChild(RenderBox& child, SizeType, const L
ength& size); | 102 LayoutUnit computeMainAxisExtentForChild(LayoutBox& child, SizeType, const L
ength& size); |
103 WritingMode transformedWritingMode() const; | 103 WritingMode transformedWritingMode() const; |
104 LayoutUnit flowAwareBorderStart() const; | 104 LayoutUnit flowAwareBorderStart() const; |
105 LayoutUnit flowAwareBorderEnd() const; | 105 LayoutUnit flowAwareBorderEnd() const; |
106 LayoutUnit flowAwareBorderBefore() const; | 106 LayoutUnit flowAwareBorderBefore() const; |
107 LayoutUnit flowAwareBorderAfter() const; | 107 LayoutUnit flowAwareBorderAfter() const; |
108 LayoutUnit flowAwarePaddingStart() const; | 108 LayoutUnit flowAwarePaddingStart() const; |
109 LayoutUnit flowAwarePaddingEnd() const; | 109 LayoutUnit flowAwarePaddingEnd() const; |
110 LayoutUnit flowAwarePaddingBefore() const; | 110 LayoutUnit flowAwarePaddingBefore() const; |
111 LayoutUnit flowAwarePaddingAfter() const; | 111 LayoutUnit flowAwarePaddingAfter() const; |
112 LayoutUnit flowAwareMarginStartForChild(RenderBox& child) const; | 112 LayoutUnit flowAwareMarginStartForChild(LayoutBox& child) const; |
113 LayoutUnit flowAwareMarginEndForChild(RenderBox& child) const; | 113 LayoutUnit flowAwareMarginEndForChild(LayoutBox& child) const; |
114 LayoutUnit flowAwareMarginBeforeForChild(RenderBox& child) const; | 114 LayoutUnit flowAwareMarginBeforeForChild(LayoutBox& child) const; |
115 LayoutUnit crossAxisMarginExtentForChild(RenderBox& child) const; | 115 LayoutUnit crossAxisMarginExtentForChild(LayoutBox& child) const; |
116 LayoutUnit crossAxisScrollbarExtent() const; | 116 LayoutUnit crossAxisScrollbarExtent() const; |
117 LayoutUnit crossAxisScrollbarExtentForChild(RenderBox& child) const; | 117 LayoutUnit crossAxisScrollbarExtentForChild(LayoutBox& child) const; |
118 LayoutPoint flowAwareLocationForChild(RenderBox& child) const; | 118 LayoutPoint flowAwareLocationForChild(LayoutBox& child) const; |
119 // FIXME: Supporting layout deltas. | 119 // FIXME: Supporting layout deltas. |
120 void setFlowAwareLocationForChild(RenderBox& child, const LayoutPoint&); | 120 void setFlowAwareLocationForChild(LayoutBox& child, const LayoutPoint&); |
121 void adjustAlignmentForChild(RenderBox& child, LayoutUnit); | 121 void adjustAlignmentForChild(LayoutBox& child, LayoutUnit); |
122 ItemPosition alignmentForChild(RenderBox& child) const; | 122 ItemPosition alignmentForChild(LayoutBox& child) const; |
123 LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox& child) const; | 123 LayoutUnit mainAxisBorderAndPaddingExtentForChild(LayoutBox& child) const; |
124 LayoutUnit preferredMainAxisContentExtentForChild(RenderBox& child, bool has
InfiniteLineLength, bool relayoutChildren = false); | 124 LayoutUnit preferredMainAxisContentExtentForChild(LayoutBox& child, bool has
InfiniteLineLength, bool relayoutChildren = false); |
125 bool childPreferredMainAxisContentExtentRequiresLayout(RenderBox& child, boo
l hasInfiniteLineLength) const; | 125 bool childPreferredMainAxisContentExtentRequiresLayout(LayoutBox& child, boo
l hasInfiniteLineLength) const; |
126 bool needToStretchChildLogicalHeight(RenderBox& child) const; | 126 bool needToStretchChildLogicalHeight(LayoutBox& child) const; |
127 | 127 |
128 void layoutFlexItems(bool relayoutChildren); | 128 void layoutFlexItems(bool relayoutChildren); |
129 LayoutUnit autoMarginOffsetInMainAxis(const OrderedFlexItemList&, LayoutUnit
& availableFreeSpace); | 129 LayoutUnit autoMarginOffsetInMainAxis(const OrderedFlexItemList&, LayoutUnit
& availableFreeSpace); |
130 void updateAutoMarginsInMainAxis(RenderBox& child, LayoutUnit autoMarginOffs
et); | 130 void updateAutoMarginsInMainAxis(LayoutBox& child, LayoutUnit autoMarginOffs
et); |
131 bool hasAutoMarginsInCrossAxis(RenderBox& child) const; | 131 bool hasAutoMarginsInCrossAxis(LayoutBox& child) const; |
132 bool updateAutoMarginsInCrossAxis(RenderBox& child, LayoutUnit availableAlig
nmentSpace); | 132 bool updateAutoMarginsInCrossAxis(LayoutBox& child, LayoutUnit availableAlig
nmentSpace); |
133 void repositionLogicalHeightDependentFlexItems(Vector<LineContext>&); | 133 void repositionLogicalHeightDependentFlexItems(Vector<LineContext>&); |
134 LayoutUnit clientLogicalBottomAfterRepositioning(); | 134 LayoutUnit clientLogicalBottomAfterRepositioning(); |
135 void appendChildFrameRects(ChildFrameRects&); | 135 void appendChildFrameRects(ChildFrameRects&); |
136 | 136 |
137 LayoutUnit availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, R
enderBox& child); | 137 LayoutUnit availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, L
ayoutBox& child); |
138 LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit lineCr
ossAxisExtent, RenderBox& child); | 138 LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit lineCr
ossAxisExtent, LayoutBox& child); |
139 LayoutUnit marginBoxAscentForChild(RenderBox& child); | 139 LayoutUnit marginBoxAscentForChild(LayoutBox& child); |
140 | 140 |
141 LayoutUnit computeChildMarginValue(Length margin); | 141 LayoutUnit computeChildMarginValue(Length margin); |
142 void prepareOrderIteratorAndMargins(); | 142 void prepareOrderIteratorAndMargins(); |
143 LayoutUnit adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSiz
e); | 143 LayoutUnit adjustChildSizeForMinAndMax(LayoutBox& child, LayoutUnit childSiz
e); |
144 // The hypothetical main size of an item is the flex base size clamped accor
ding to its min and max main size properties | 144 // The hypothetical main size of an item is the flex base size clamped accor
ding to its min and max main size properties |
145 bool computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& s
umFlexBaseSize, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUn
it& sumHypotheticalMainSize, bool& hasInfiniteLineLength, bool relayoutChildren)
; | 145 bool computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& s
umFlexBaseSize, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUn
it& sumHypotheticalMainSize, bool& hasInfiniteLineLength, bool relayoutChildren)
; |
146 | 146 |
147 bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit
& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, In
flexibleFlexItemSize&, Vector<LayoutUnit, 16>& childSizes, bool hasInfiniteLineL
ength); | 147 bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit
& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, In
flexibleFlexItemSize&, Vector<LayoutUnit, 16>& childSizes, bool hasInfiniteLineL
ength); |
148 void freezeViolations(const Vector<Violation>&, LayoutUnit& availableFreeSpa
ce, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSi
ze&, bool hasInfiniteLineLength); | 148 void freezeViolations(const Vector<Violation>&, LayoutUnit& availableFreeSpa
ce, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSi
ze&, bool hasInfiniteLineLength); |
149 | 149 |
150 void resetAutoMarginsAndLogicalTopInCrossAxis(RenderBox& child); | 150 void resetAutoMarginsAndLogicalTopInCrossAxis(LayoutBox& child); |
151 void setOverrideMainAxisSizeForChild(RenderBox& child, LayoutUnit childPrefe
rredSize); | 151 void setOverrideMainAxisSizeForChild(LayoutBox& child, LayoutUnit childPrefe
rredSize); |
152 void prepareChildForPositionedLayout(RenderBox& child, LayoutUnit mainAxisOf
fset, LayoutUnit crossAxisOffset, PositionedLayoutMode); | 152 void prepareChildForPositionedLayout(LayoutBox& child, LayoutUnit mainAxisOf
fset, LayoutUnit crossAxisOffset, PositionedLayoutMode); |
153 size_t numberOfInFlowPositionedChildren(const OrderedFlexItemList&) const; | 153 size_t numberOfInFlowPositionedChildren(const OrderedFlexItemList&) const; |
154 void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexIt
emList&, const Vector<LayoutUnit, 16>& childSizes, LayoutUnit availableFreeSpace
, bool relayoutChildren, Vector<LineContext>&, bool hasInfiniteLineLength); | 154 void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexIt
emList&, const Vector<LayoutUnit, 16>& childSizes, LayoutUnit availableFreeSpace
, bool relayoutChildren, Vector<LineContext>&, bool hasInfiniteLineLength); |
155 void layoutColumnReverse(const OrderedFlexItemList&, LayoutUnit crossAxisOff
set, LayoutUnit availableFreeSpace); | 155 void layoutColumnReverse(const OrderedFlexItemList&, LayoutUnit crossAxisOff
set, LayoutUnit availableFreeSpace); |
156 void alignFlexLines(Vector<LineContext>&); | 156 void alignFlexLines(Vector<LineContext>&); |
157 void alignChildren(const Vector<LineContext>&); | 157 void alignChildren(const Vector<LineContext>&); |
158 void applyStretchAlignmentToChild(RenderBox& child, LayoutUnit lineCrossAxis
Extent); | 158 void applyStretchAlignmentToChild(LayoutBox& child, LayoutUnit lineCrossAxis
Extent); |
159 void flipForRightToLeftColumn(); | 159 void flipForRightToLeftColumn(); |
160 void flipForWrapReverse(const Vector<LineContext>&, LayoutUnit crossAxisStar
tEdge); | 160 void flipForWrapReverse(const Vector<LineContext>&, LayoutUnit crossAxisStar
tEdge); |
161 | 161 |
162 // This is used to cache the preferred size for orthogonal flow children so
we don't have to relayout to get it | 162 // This is used to cache the preferred size for orthogonal flow children so
we don't have to relayout to get it |
163 HashMap<const LayoutObject*, LayoutUnit> m_intrinsicSizeAlongMainAxis; | 163 HashMap<const LayoutObject*, LayoutUnit> m_intrinsicSizeAlongMainAxis; |
164 | 164 |
165 mutable OrderIterator m_orderIterator; | 165 mutable OrderIterator m_orderIterator; |
166 int m_numberOfInFlowChildrenOnFirstLine; | 166 int m_numberOfInFlowChildrenOnFirstLine; |
167 }; | 167 }; |
168 | 168 |
169 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderFlexibleBox, isFlexibleBox()); | 169 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderFlexibleBox, isFlexibleBox()); |
170 | 170 |
171 } // namespace blink | 171 } // namespace blink |
172 | 172 |
173 #endif // RenderFlexibleBox_h | 173 #endif // RenderFlexibleBox_h |
OLD | NEW |