diff options
| author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
| commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
| tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebCore/rendering/RenderFlexibleBox.h | |
| parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
| download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz | |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebCore/rendering/RenderFlexibleBox.h')
| -rw-r--r-- | Source/WebCore/rendering/RenderFlexibleBox.h | 84 |
1 files changed, 64 insertions, 20 deletions
diff --git a/Source/WebCore/rendering/RenderFlexibleBox.h b/Source/WebCore/rendering/RenderFlexibleBox.h index 98eafca7c..ad7707585 100644 --- a/Source/WebCore/rendering/RenderFlexibleBox.h +++ b/Source/WebCore/rendering/RenderFlexibleBox.h @@ -32,21 +32,21 @@ #define RenderFlexibleBox_h #include "RenderBlock.h" -#include <wtf/OwnPtr.h> namespace WebCore { class RenderFlexibleBox : public RenderBlock { public: - RenderFlexibleBox(Node*); + RenderFlexibleBox(Element*); virtual ~RenderFlexibleBox(); + static RenderFlexibleBox* createAnonymous(Document*); + virtual const char* renderName() const OVERRIDE; virtual bool isFlexibleBox() const OVERRIDE { return true; } virtual bool avoidsFloats() const OVERRIDE { return true; } virtual bool canCollapseAnonymousBlockChild() const OVERRIDE { return false; } - virtual void computePreferredLogicalWidths() OVERRIDE; virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE; virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE; @@ -57,6 +57,12 @@ public: bool isHorizontalFlow() const; +protected: + virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE; + virtual void computePreferredLogicalWidths() OVERRIDE; + + virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); + private: enum FlexSign { PositiveFlexibility, @@ -71,13 +77,32 @@ private: struct OrderHashTraits; typedef HashSet<int, DefaultHash<int>::Hash, OrderHashTraits> OrderHashSet; - class OrderIterator; - typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize; - typedef WTF::Vector<RenderBox*> OrderedFlexItemList; + class OrderIterator { + WTF_MAKE_NONCOPYABLE(OrderIterator); + public: + OrderIterator(const RenderFlexibleBox*); + void setOrderValues(const OrderHashSet&); + RenderBox* currentChild() const { return m_currentChild; } + RenderBox* first(); + RenderBox* next(); + void reset(); + + private: + const RenderFlexibleBox* m_flexibleBox; + RenderBox* m_currentChild; + Vector<int> m_orderValues; + Vector<int>::const_iterator m_orderValuesIterator; + }; + + typedef HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize; + typedef Vector<RenderBox*> OrderedFlexItemList; struct LineContext; struct Violation; + // Use an inline capacity of 8, since flexbox containers usually have less than 8 children. + typedef Vector<LayoutRect, 8> ChildFrameRects; + bool hasOrthogonalFlow(RenderBox* child) const; bool isColumnFlow() const; bool isLeftToRightFlow() const; @@ -113,42 +138,61 @@ private: EAlignItems alignmentForChild(RenderBox* child) const; LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox* child) const; LayoutUnit mainAxisScrollbarExtentForChild(RenderBox* child) const; - LayoutUnit preferredMainAxisContentExtentForChild(RenderBox* child); + LayoutUnit preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength); - void layoutFlexItems(OrderIterator&, WTF::Vector<LineContext>&); + void layoutFlexItems(bool relayoutChildren, Vector<LineContext>&); LayoutUnit autoMarginOffsetInMainAxis(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace); void updateAutoMarginsInMainAxis(RenderBox* child, LayoutUnit autoMarginOffset); bool hasAutoMarginsInCrossAxis(RenderBox* child) const; bool updateAutoMarginsInCrossAxis(RenderBox* child, LayoutUnit availableAlignmentSpace); - void repositionLogicalHeightDependentFlexItems(OrderIterator&, WTF::Vector<LineContext>&, LayoutUnit& oldClientAfterEdge); - void clearChildOverrideSizes(); + void repositionLogicalHeightDependentFlexItems(Vector<LineContext>&); + LayoutUnit clientLogicalBottomAfterRepositioning(); + void appendChildFrameRects(ChildFrameRects&); + void repaintChildrenDuringLayoutIfMoved(const ChildFrameRects&); LayoutUnit availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, RenderBox*); LayoutUnit marginBoxAscentForChild(RenderBox*); LayoutUnit computeChildMarginValue(Length margin, RenderView*); - void computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet&); + void computeMainAxisPreferredSizes(OrderHashSet&); LayoutUnit adjustChildSizeForMinAndMax(RenderBox*, LayoutUnit childSize); - bool computeNextFlexLine(OrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent); + bool computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent, bool& hasInfiniteLineLength); - bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes); - void freezeViolations(const WTF::Vector<Violation>&, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize&); + bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize&, Vector<LayoutUnit>& childSizes, bool hasInfiniteLineLength); + void freezeViolations(const Vector<Violation>&, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize&, bool hasInfiniteLineLength); + void resetAutoMarginsAndLogicalTopInCrossAxis(RenderBox*); + bool needToStretchChild(RenderBox*); void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize); void prepareChildForPositionedLayout(RenderBox* child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode); size_t numberOfInFlowPositionedChildren(const OrderedFlexItemList&) const; - void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, WTF::Vector<LineContext>&); + void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, bool relayoutChildren, Vector<LineContext>&); void layoutColumnReverse(const OrderedFlexItemList&, LayoutUnit crossAxisOffset, LayoutUnit availableFreeSpace); - void alignFlexLines(OrderIterator&, WTF::Vector<LineContext>&); - void alignChildren(OrderIterator&, const WTF::Vector<LineContext>&); + void alignFlexLines(Vector<LineContext>&); + void alignChildren(const Vector<LineContext>&); void applyStretchAlignmentToChild(RenderBox*, LayoutUnit lineCrossAxisExtent); - void flipForRightToLeftColumn(OrderIterator&); - void flipForWrapReverse(OrderIterator&, const WTF::Vector<LineContext>&, LayoutUnit crossAxisStartEdge); + void flipForRightToLeftColumn(); + void flipForWrapReverse(const Vector<LineContext>&, LayoutUnit crossAxisStartEdge); - OwnPtr<OrderIterator> m_orderIterator; + mutable OrderIterator m_orderIterator; int m_numberOfInFlowChildrenOnFirstLine; }; +inline RenderFlexibleBox* toRenderFlexibleBox(RenderObject* object) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isFlexibleBox()); + return static_cast<RenderFlexibleBox*>(object); +} + +inline const RenderFlexibleBox* toRenderFlexibleBox(const RenderObject* object) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isFlexibleBox()); + return static_cast<const RenderFlexibleBox*>(object); +} + +// This will catch anyone doing an unnecessary cast. +void toRenderFlexibleBox(const RenderFlexibleBox*); + } // namespace WebCore #endif // RenderFlexibleBox_h |
