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; }
47 virtual void layoutBlock(bool relayoutChildren, int pageLogicalHeight = 0, BlockLayoutPass = NormalLayoutPass);
49 bool isHorizontalFlow() const;
52 struct FlexOrderHashTraits;
53 typedef HashSet<int, DefaultHash<int>::Hash, FlexOrderHashTraits> FlexOrderHashSet;
55 class FlexOrderIterator;
56 typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
57 typedef WTF::Vector<RenderBox*> OrderedFlexItemList;
59 bool hasOrthogonalFlow(RenderBox* child) const;
60 bool isColumnFlow() const;
61 bool isLeftToRightFlow() const;
62 Length crossAxisLength() const;
63 Length mainAxisLengthForChild(RenderBox* child) const;
64 void setCrossAxisExtent(LayoutUnit);
65 LayoutUnit crossAxisExtentForChild(RenderBox* child);
66 LayoutUnit mainAxisExtentForChild(RenderBox* child);
67 LayoutUnit crossAxisExtent() const;
68 LayoutUnit mainAxisExtent() const;
69 LayoutUnit crossAxisContentExtent() const;
70 LayoutUnit mainAxisContentExtent() const;
71 WritingMode transformedWritingMode() const;
72 LayoutUnit flowAwareBorderStart() const;
73 LayoutUnit flowAwareBorderBefore() const;
74 LayoutUnit flowAwareBorderEnd() const;
75 LayoutUnit crossAxisBorderAndPaddingExtent() const;
76 LayoutUnit flowAwarePaddingStart() const;
77 LayoutUnit flowAwarePaddingBefore() const;
78 LayoutUnit flowAwarePaddingEnd() const;
79 LayoutUnit flowAwareMarginStartForChild(RenderBox* child) const;
80 LayoutUnit flowAwareMarginEndForChild(RenderBox* child) const;
81 LayoutUnit flowAwareMarginBeforeForChild(RenderBox* child) const;
82 LayoutUnit flowAwareMarginAfterForChild(RenderBox* child) const;
83 LayoutUnit crossAxisMarginExtentForChild(RenderBox* child) const;
84 LayoutUnit crossAxisScrollbarExtent() const;
85 LayoutPoint flowAwareLocationForChild(RenderBox* child) const;
86 // FIXME: Supporting layout deltas.
87 void setFlowAwareLocationForChild(RenderBox* child, const LayoutPoint&);
88 void adjustAlignmentForChild(RenderBox* child, LayoutUnit);
89 LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox* child) const;
90 LayoutUnit mainAxisScrollbarExtentForChild(RenderBox* child) const;
91 LayoutUnit preferredMainAxisContentExtentForChild(RenderBox* child) const;
93 void layoutFlexItems(bool relayoutChildren);
95 float positiveFlexForChild(RenderBox* child) const;
96 float negativeFlexForChild(RenderBox* child) const;
98 LayoutUnit availableAlignmentSpaceForChild(RenderBox*);
99 LayoutUnit marginBoxAscent(RenderBox*);
101 void computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet&);
102 void computeFlexOrder(FlexOrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
103 bool runFreeSpaceAllocationAlgorithm(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
104 void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
105 void prepareChildForPositionedLayout(RenderBox* child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset);
106 void layoutAndPlaceChildren(const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace);
107 void layoutColumnReverse(const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace);
108 void alignChildren(const OrderedFlexItemList&, LayoutUnit maxAscent);
111 } // namespace WebCore
113 #endif // RenderFlexibleBox_h