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"
36 #if ENABLE(CSS3_FLEXBOX)
40 class RenderFlexibleBox : public RenderBlock {
42 RenderFlexibleBox(Node*);
43 virtual ~RenderFlexibleBox();
45 virtual const char* renderName() const;
47 virtual bool isFlexibleBox() const { return true; }
49 virtual void layoutBlock(bool relayoutChildren, int pageLogicalHeight = 0, BlockLayoutPass = NormalLayoutPass);
52 class TreeOrderIterator;
53 class FlexOrderIterator;
54 typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
56 bool hasOrthogonalFlow(RenderBox* child) const;
57 bool isColumnFlow() const;
58 bool isHorizontalFlow() const;
59 bool isLeftToRightFlow() const;
60 bool isFlowAwareLogicalHeightAuto() const;
61 Length flowAwareLogicalWidthLengthForChild(RenderBox* child) const;
62 void setFlowAwareLogicalHeight(LayoutUnit);
63 LayoutUnit flowAwareLogicalHeightForChild(RenderBox* child);
64 LayoutUnit flowAwareLogicalWidthForChild(RenderBox* child);
65 LayoutUnit flowAwareLogicalHeight() const;
66 LayoutUnit flowAwareLogicalWidth() const;
67 LayoutUnit flowAwareContentLogicalHeight() const;
68 LayoutUnit flowAwareContentLogicalWidth() const;
69 WritingMode transformedWritingMode() const;
70 LayoutUnit flowAwareBorderStart() const;
71 LayoutUnit flowAwareBorderBefore() const;
72 LayoutUnit flowAwareBorderAfter() const;
73 LayoutUnit flowAwareBorderAndPaddingLogicalHeight() const;
74 LayoutUnit flowAwarePaddingStart() const;
75 LayoutUnit flowAwarePaddingBefore() const;
76 LayoutUnit flowAwarePaddingAfter() const;
77 LayoutUnit flowAwareMarginStartForChild(RenderBox* child) const;
78 LayoutUnit flowAwareMarginEndForChild(RenderBox* child) const;
79 LayoutUnit flowAwareMarginBeforeForChild(RenderBox* child) const;
80 LayoutUnit flowAwareMarginAfterForChild(RenderBox* child) const;
81 LayoutUnit flowAwareMarginLogicalHeightForChild(RenderBox* child) const;
82 LayoutPoint flowAwareLogicalLocationForChild(RenderBox* child) const;
83 void setFlowAwareMarginStartForChild(RenderBox* child, LayoutUnit);
84 void setFlowAwareMarginEndForChild(RenderBox* child, LayoutUnit);
85 // FIXME: Supporting layout deltas.
86 void setFlowAwareLogicalLocationForChild(RenderBox* child, const LayoutPoint&);
87 void adjustLocationLogicalTopForChild(RenderBox* child, LayoutUnit);
88 LayoutUnit logicalBorderAndPaddingWidthForChild(RenderBox* child) const;
89 LayoutUnit logicalScrollbarHeightForChild(RenderBox* child) const;
90 Length marginStartStyleForChild(RenderBox* child) const;
91 Length marginEndStyleForChild(RenderBox* child) const;
92 LayoutUnit preferredLogicalContentWidthForFlexItem(RenderBox* child) const;
94 void layoutInlineDirection(bool relayoutChildren);
96 float logicalPositiveFlexForChild(RenderBox* child) const;
97 float logicalNegativeFlexForChild(RenderBox* child) const;
99 LayoutUnit availableLogicalHeightForChild(RenderBox*);
100 LayoutUnit marginBoxAscent(RenderBox*);
102 void computePreferredLogicalWidth(bool relayoutChildren, TreeOrderIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
103 bool runFreeSpaceAllocationAlgorithmInlineDirection(FlexOrderIterator&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
104 void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
105 void layoutAndPlaceChildrenInlineDirection(FlexOrderIterator&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility);
106 void alignChildrenBlockDirection(FlexOrderIterator&, LayoutUnit maxAscent);
109 } // namespace WebCore
111 #endif // ENABLE(CSS3_FLEXBOX)
113 #endif // RenderFlexibleBox_h