2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef RenderFlexibleBox_h
32 #define RenderFlexibleBox_h
34 #include "RenderBlock.h"
38 class RenderFlexibleBox : public RenderBlock {
40 RenderFlexibleBox(Node*);
41 virtual ~RenderFlexibleBox();
43 virtual const char* renderName() const;
45 virtual bool isFlexibleBox() const { return true; }
46 virtual void computePreferredLogicalWidths();
47 virtual void layoutBlock(bool relayoutChildren, int pageLogicalHeight = 0, BlockLayoutPass = NormalLayoutPass);
49 bool isHorizontalFlow() const;
57 struct FlexOrderHashTraits;
58 typedef HashSet<int, DefaultHash<int>::Hash, FlexOrderHashTraits> FlexOrderHashSet;
60 class FlexOrderIterator;
61 typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
62 typedef WTF::Vector<RenderBox*> OrderedFlexItemList;
66 bool hasOrthogonalFlow(RenderBox* child) const;
67 bool isColumnFlow() const;
68 bool isLeftToRightFlow() const;
69 bool isMultiline() const;
70 Length crossAxisLength() const;
71 Length mainAxisLengthForChild(RenderBox* child) const;
72 void setCrossAxisExtent(LayoutUnit);
73 LayoutUnit crossAxisExtentForChild(RenderBox* child);
74 LayoutUnit mainAxisExtentForChild(RenderBox* child);
75 LayoutUnit crossAxisExtent() const;
76 LayoutUnit mainAxisExtent() const;
77 LayoutUnit crossAxisContentExtent() const;
78 LayoutUnit mainAxisContentExtent() const;
79 WritingMode transformedWritingMode() const;
80 LayoutUnit flowAwareBorderStart() const;
81 LayoutUnit flowAwareBorderEnd() const;
82 LayoutUnit flowAwareBorderBefore() const;
83 LayoutUnit flowAwareBorderAfter() const;
84 LayoutUnit flowAwarePaddingStart() const;
85 LayoutUnit flowAwarePaddingEnd() const;
86 LayoutUnit flowAwarePaddingBefore() const;
87 LayoutUnit flowAwarePaddingAfter() const;
88 LayoutUnit flowAwareMarginStartForChild(RenderBox* child) const;
89 LayoutUnit flowAwareMarginEndForChild(RenderBox* child) const;
90 LayoutUnit flowAwareMarginBeforeForChild(RenderBox* child) const;
91 LayoutUnit flowAwareMarginAfterForChild(RenderBox* child) const;
92 LayoutUnit crossAxisMarginExtentForChild(RenderBox* child) const;
93 LayoutUnit crossAxisScrollbarExtent() const;
94 LayoutPoint flowAwareLocationForChild(RenderBox* child) const;
95 // FIXME: Supporting layout deltas.
96 void setFlowAwareLocationForChild(RenderBox* child, const LayoutPoint&);
97 void adjustAlignmentForChild(RenderBox* child, LayoutUnit);
98 LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox* child) const;
99 LayoutUnit mainAxisScrollbarExtentForChild(RenderBox* child) const;
100 LayoutUnit preferredMainAxisContentExtentForChild(RenderBox* child) const;
102 void layoutFlexItems(bool relayoutChildren);
104 float positiveFlexForChild(RenderBox* child) const;
105 float negativeFlexForChild(RenderBox* child) const;
107 LayoutUnit availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, RenderBox*);
108 LayoutUnit marginBoxAscentForChild(RenderBox*);
110 void computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet&);
111 LayoutUnit lineBreakLength();
112 bool computeNextFlexLine(FlexOrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility, LayoutUnit& minMaxAppliedMainAxisExtent);
113 LayoutUnit computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent);
114 bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
115 void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
116 void prepareChildForPositionedLayout(RenderBox* child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset);
117 void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, WTF::Vector<LineContext>& lineContexts);
118 void layoutColumnReverse(const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit crossAxisOffset, LayoutUnit availableFreeSpace);
119 void alignChildren(FlexOrderIterator&, const WTF::Vector<LineContext>&);
120 void applyStretchAlignmentToChild(RenderBox*, LayoutUnit lineCrossAxisExtent);
121 void flipForRightToLeftColumn(FlexOrderIterator&);
122 void flipForWrapReverse(FlexOrderIterator&, const WTF::Vector<LineContext>&);
125 } // namespace WebCore
127 #endif // RenderFlexibleBox_h