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