OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 13 matching lines...) Expand all Loading... |
24 */ | 24 */ |
25 | 25 |
26 | 26 |
27 #ifndef RenderMultiColumnFlowThread_h | 27 #ifndef RenderMultiColumnFlowThread_h |
28 #define RenderMultiColumnFlowThread_h | 28 #define RenderMultiColumnFlowThread_h |
29 | 29 |
30 #include "core/rendering/RenderFlowThread.h" | 30 #include "core/rendering/RenderFlowThread.h" |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
| 34 class RenderMultiColumnSet; |
| 35 |
| 36 // Flow thread implementation for CSS multicol. This will be inserted as an anon
ymous child block of |
| 37 // the actual multicol container (i.e. the RenderBlockFlow whose style computes
to non-auto |
| 38 // column-count and/or column-width). RenderMultiColumnFlowThread is the heart o
f the multicol |
| 39 // implementation, and there is only one instance per multicol container. Child
content of the |
| 40 // multicol container is parented into the flow thread at the time of renderer i
nsertion. |
| 41 // |
| 42 // Apart from this flow thread child, the multicol container will also have Rend
erMultiColumnSet |
| 43 // "region" children, which are used to position the columns visually. The flow
thread is in charge |
| 44 // of layout, and, after having calculated the column width, it lays out content
as if everything |
| 45 // were in one tall single column, except that there will typically be some amou
nt of blank space |
| 46 // (also known as pagination struts) at the offsets where the actual column boun
daries are. This |
| 47 // way, content that needs to be preceded by a break will appear at the top of t
he next |
| 48 // column. Content needs to be preceded by a break when there's a forced break o
r when the content |
| 49 // is unbreakable and cannot fully fit in the same column as the preceding piece
of |
| 50 // content. Although a RenderMultiColumnFlowThread is laid out, it does not take
up any space in its |
| 51 // container. It's the RenderMultiColumnSet objects that take up the necessary a
mount of space, and |
| 52 // make sure that the columns are painted and hit-tested correctly. |
34 class RenderMultiColumnFlowThread FINAL : public RenderFlowThread { | 53 class RenderMultiColumnFlowThread FINAL : public RenderFlowThread { |
35 public: | 54 public: |
36 virtual ~RenderMultiColumnFlowThread(); | 55 virtual ~RenderMultiColumnFlowThread(); |
37 | 56 |
38 static RenderMultiColumnFlowThread* createAnonymous(Document&, RenderStyle*
parentStyle); | 57 static RenderMultiColumnFlowThread* createAnonymous(Document&, RenderStyle*
parentStyle); |
39 | 58 |
40 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par
ent()); } | 59 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par
ent()); } |
41 | 60 |
| 61 RenderMultiColumnSet* firstMultiColumnSet() const; |
| 62 RenderMultiColumnSet* lastMultiColumnSet() const; |
| 63 |
| 64 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0)
OVERRIDE; |
| 65 |
42 // Populate the flow thread with what's currently its siblings. Called when
a regular block | 66 // Populate the flow thread with what's currently its siblings. Called when
a regular block |
43 // becomes a multicol container. | 67 // becomes a multicol container. |
44 void populate(); | 68 void populate(); |
45 | 69 |
46 // Empty the flow thread by moving everything to the parent. Remove all mult
icol specific | 70 // Empty the flow thread by moving everything to the parent. Remove all mult
icol specific |
47 // renderers. Then destroy the flow thread. Called when a multicol container
becomes a regular | 71 // renderers. Then destroy the flow thread. Called when a multicol container
becomes a regular |
48 // block. | 72 // block. |
49 void evacuateAndDestroy(); | 73 void evacuateAndDestroy(); |
50 | 74 |
51 unsigned columnCount() const { return m_columnCount; } | 75 unsigned columnCount() const { return m_columnCount; } |
52 LayoutUnit columnWidth() const { return m_columnWidth; } | 76 LayoutUnit columnWidth() const { return m_columnWidth; } |
53 LayoutUnit columnHeightAvailable() const { return m_columnHeightAvailable; } | 77 LayoutUnit columnHeightAvailable() const { return m_columnHeightAvailable; } |
54 void setColumnHeightAvailable(LayoutUnit available) { m_columnHeightAvailabl
e = available; } | 78 void setColumnHeightAvailable(LayoutUnit available) { m_columnHeightAvailabl
e = available; } |
55 bool requiresBalancing() const { return !columnHeightAvailable() || multiCol
umnBlockFlow()->style()->columnFill() == ColumnFillBalance; } | 79 bool requiresBalancing() const { return !columnHeightAvailable() || multiCol
umnBlockFlow()->style()->columnFill() == ColumnFillBalance; } |
56 | 80 |
57 void layoutColumns(bool relayoutChildren, SubtreeLayoutScope&); | 81 void layoutColumns(bool relayoutChildren, SubtreeLayoutScope&); |
58 bool computeColumnCountAndWidth(); | 82 bool computeColumnCountAndWidth(); |
59 bool recalculateColumnHeights(); | 83 bool recalculateColumnHeights(); |
60 | 84 |
61 private: | 85 private: |
62 RenderMultiColumnFlowThread(); | 86 RenderMultiColumnFlowThread(); |
63 | 87 |
64 virtual const char* renderName() const OVERRIDE; | 88 virtual const char* renderName() const OVERRIDE; |
| 89 virtual void addRegionToThread(RenderRegion*) OVERRIDE; |
| 90 virtual void willBeRemovedFromTree() OVERRIDE; |
65 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; | 91 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; |
66 virtual void autoGenerateRegionsToBlockOffset(LayoutUnit) OVERRIDE; | |
67 virtual LayoutUnit initialLogicalWidth() const OVERRIDE; | 92 virtual LayoutUnit initialLogicalWidth() const OVERRIDE; |
68 virtual void setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) OVERR
IDE; | 93 virtual void setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) OVERR
IDE; |
69 virtual void updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeight
) OVERRIDE; | 94 virtual void updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeight
) OVERRIDE; |
| 95 virtual RenderRegion* regionAtBlockOffset(LayoutUnit) const OVERRIDE; |
70 virtual bool addForcedRegionBreak(LayoutUnit, RenderObject* breakChild, bool
isBefore, LayoutUnit* offsetBreakAdjustment = 0) OVERRIDE; | 96 virtual bool addForcedRegionBreak(LayoutUnit, RenderObject* breakChild, bool
isBefore, LayoutUnit* offsetBreakAdjustment = 0) OVERRIDE; |
71 virtual bool isPageLogicalHeightKnown() const OVERRIDE; | 97 virtual bool isPageLogicalHeightKnown() const OVERRIDE; |
72 | 98 |
73 unsigned m_columnCount; // The used value of column-count | 99 unsigned m_columnCount; // The used value of column-count |
74 LayoutUnit m_columnWidth; // The used value of column-width | 100 LayoutUnit m_columnWidth; // The used value of column-width |
75 LayoutUnit m_columnHeightAvailable; // Total height available to columns, or
0 if auto. | 101 LayoutUnit m_columnHeightAvailable; // Total height available to columns, or
0 if auto. |
76 bool m_inBalancingPass; // Set when relayouting for column balancing. | 102 bool m_inBalancingPass; // Set when relayouting for column balancing. |
77 bool m_needsRebalancing; | 103 bool m_needsRebalancing; |
78 }; | 104 }; |
79 | 105 |
80 } // namespace WebCore | 106 } // namespace WebCore |
81 | 107 |
82 #endif // RenderMultiColumnFlowThread_h | 108 #endif // RenderMultiColumnFlowThread_h |
83 | 109 |
OLD | NEW |