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);
50 class TreeOrderIterator;
51 class FlexOrderIterator;
52 typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
54 bool hasOrthogonalFlow(RenderBox* child) const;
55 bool isColumnFlow() const;
56 bool isReverseFlow() const;
57 bool isHorizontalFlow() const;
58 bool isLeftToRightFlow() const;
59 Length crossAxisLength() const;
60 Length mainAxisLengthForChild(RenderBox* child) const;
61 void setCrossAxisExtent(LayoutUnit);
62 LayoutUnit crossAxisExtentForChild(RenderBox* child);
63 LayoutUnit mainAxisExtentForChild(RenderBox* child);
64 LayoutUnit crossAxisExtent() const;
65 LayoutUnit mainAxisExtent() const;
66 LayoutUnit crossAxisContentExtent() const;
67 LayoutUnit mainAxisContentExtent() const;
68 WritingMode transformedWritingMode() const;
69 LayoutUnit flowAwareBorderStart() const;
70 LayoutUnit flowAwareBorderBefore() const;
71 LayoutUnit crossAxisBorderAndPaddingExtent() const;
72 LayoutUnit flowAwarePaddingStart() const;
73 LayoutUnit flowAwarePaddingBefore() const;
74 LayoutUnit flowAwareMarginStartForChild(RenderBox* child) const;
75 LayoutUnit flowAwareMarginEndForChild(RenderBox* child) const;
76 LayoutUnit flowAwareMarginBeforeForChild(RenderBox* child) const;
77 LayoutUnit flowAwareMarginAfterForChild(RenderBox* child) const;
78 LayoutUnit crossAxisMarginExtentForChild(RenderBox* child) const;
79 LayoutPoint flowAwareLocationForChild(RenderBox* child) const;
80 // FIXME: Supporting layout deltas.
81 void setFlowAwareLocationForChild(RenderBox* child, const LayoutPoint&);
82 void adjustAlignmentForChild(RenderBox* child, LayoutUnit);
83 LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox* child) const;
84 LayoutUnit mainAxisScrollbarExtentForChild(RenderBox* child) const;
85 LayoutUnit preferredMainAxisContentExtentForFlexItem(RenderBox* child) const;
87 void layoutFlexItems(bool relayoutChildren);
89 float positiveFlexForChild(RenderBox* child) const;
90 float negativeFlexForChild(RenderBox* child) const;
92 LayoutUnit availableAlignmentSpaceForChild(RenderBox*);
93 LayoutUnit marginBoxAscent(RenderBox*);
95 void computePreferredMainAxisExtent(bool relayoutChildren, TreeOrderIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
96 bool runFreeSpaceAllocationAlgorithm(FlexOrderIterator&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
97 void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
98 void layoutAndPlaceChildren(FlexOrderIterator&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility);
99 void alignChildren(FlexOrderIterator&, LayoutUnit maxAscent);
102 } // namespace WebCore
104 #endif // RenderFlexibleBox_h