Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(977)

Side by Side Diff: Source/core/rendering/RenderMultiColumnSet.h

Issue 584033002: [New Multicolumn] Add support for column-span:all (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix ref in test. Tables don't do subpixel, and that made a difference on Windows and Mac. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Being a "region", a column set has no children on its own, but is merely used to slice a portion 43 // Being a "region", a column set has no children on its own, but is merely used to slice a portion
44 // of the tall "single-column" flow thread into actual columns visually, to conv ert from flow thread 44 // of the tall "single-column" flow thread into actual columns visually, to conv ert from flow thread
45 // coordinates to visual ones. It is in charge of both positioning columns corre ctly relatively to 45 // coordinates to visual ones. It is in charge of both positioning columns corre ctly relatively to
46 // the parent multicol container, and to calculate the correct translation for e ach column's 46 // the parent multicol container, and to calculate the correct translation for e ach column's
47 // contents, and to paint any rules between them. RenderMultiColumnSet objects a re used for 47 // contents, and to paint any rules between them. RenderMultiColumnSet objects a re used for
48 // painting, hit testing, and any other type of operation that requires mapping from flow thread 48 // painting, hit testing, and any other type of operation that requires mapping from flow thread
49 // coordinates to visual coordinates. 49 // coordinates to visual coordinates.
50 // 50 //
51 // Column spans result in the creation of new column sets, since a spanning rend erer has to be 51 // Column spans result in the creation of new column sets, since a spanning rend erer has to be
52 // placed in between the column sets that come before and after the span. 52 // placed in between the column sets that come before and after the span.
53 class RenderMultiColumnSet final : public RenderRegion { 53 class RenderMultiColumnSet : public RenderRegion {
54 public: 54 public:
55 enum BalancedHeightCalculation { GuessFromFlowThreadPortion, StretchBySpaceS hortage }; 55 enum BalancedHeightCalculation { GuessFromFlowThreadPortion, StretchBySpaceS hortage };
56 56
57 static RenderMultiColumnSet* createAnonymous(RenderFlowThread*, RenderStyle* parentStyle); 57 static RenderMultiColumnSet* createAnonymous(RenderFlowThread*, RenderStyle* parentStyle);
58 58
59 virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectRenderMultiColumnSet || RenderRegion::isOfType(type); } 59 virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectRenderMultiColumnSet || RenderRegion::isOfType(type); }
60 60
61 virtual LayoutUnit pageLogicalWidth() const override final { return flowThre ad()->logicalWidth(); } 61 virtual LayoutUnit pageLogicalWidth() const override final { return flowThre ad()->logicalWidth(); }
62 virtual LayoutUnit pageLogicalHeight() const override final { return m_colum nHeight; } 62 virtual LayoutUnit pageLogicalHeight() const override { return m_columnHeigh t; }
63 63
64 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par ent()); } 64 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par ent()); }
65 RenderMultiColumnFlowThread* multiColumnFlowThread() const 65 RenderMultiColumnFlowThread* multiColumnFlowThread() const
66 { 66 {
67 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender MultiColumnFlowThread()); 67 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender MultiColumnFlowThread());
68 return static_cast<RenderMultiColumnFlowThread*>(flowThread()); 68 return static_cast<RenderMultiColumnFlowThread*>(flowThread());
69 } 69 }
70 70
71 RenderMultiColumnSet* nextSiblingMultiColumnSet() const; 71 RenderMultiColumnSet* nextSiblingMultiColumnSet() const;
72 RenderMultiColumnSet* previousSiblingMultiColumnSet() const; 72 RenderMultiColumnSet* previousSiblingMultiColumnSet() const;
73 73
74 void setLogicalTopInFlowThread(LayoutUnit);
74 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x(); } 75 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x(); }
76 LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); }
77 void setLogicalBottomInFlowThread(LayoutUnit);
75 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } 78 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); }
76 79
77 LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); }
78
79 // The used CSS value of column-count, i.e. how many columns there are room for without overflowing. 80 // The used CSS value of column-count, i.e. how many columns there are room for without overflowing.
80 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou nt(); } 81 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou nt(); }
81 82
83 bool heightIsAuto() const;
84
85 bool requiresBalancing() const { return !isRenderMultiColumnSpannerSet() && heightIsAuto(); }
86
82 // Find the column that contains the given block offset, and return the tran slation needed to 87 // Find the column that contains the given block offset, and return the tran slation needed to
83 // get from flow thread coordinates to visual coordinates. 88 // get from flow thread coordinates to visual coordinates.
84 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; 89 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const;
85 90
86 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; 91 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const;
87 92
88 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); } 93 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
89 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } 94 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
90 95
91 // Add a content run, specified by its end position. A content run is append ed at every 96 // Add a content run, specified by its end position. A content run is append ed at every
92 // forced/explicit break and at the end of the column set. The content runs are used to 97 // forced/explicit break and at the end of the column set. The content runs are used to
93 // determine where implicit/soft breaks will occur, in order to calculate an initial column 98 // determine where implicit/soft breaks will occur, in order to calculate an initial column
94 // height. 99 // height.
95 void addContentRun(LayoutUnit endOffsetFromFirstPage); 100 void addContentRun(LayoutUnit endOffsetFromFirstPage);
96 101
97 // (Re-)calculate the column height if it's auto. 102 // (Re-)calculate the column height if it's auto. This is first and foremost needed by sets that
98 bool recalculateColumnHeight(BalancedHeightCalculation); 103 // are to balance the column height, but even when it isn't to be balanced, this is necessary if
104 // the multicol container's height is constrained.
105 virtual bool recalculateColumnHeight(BalancedHeightCalculation);
99 106
100 // Record space shortage (the amount of space that would have been enough to prevent some 107 // Record space shortage (the amount of space that would have been enough to prevent some
101 // element from being moved to the next column) at a column break. The small est amount of space 108 // element from being moved to the next column) at a column break. The small est amount of space
102 // shortage we find is the amount with which we will stretch the column heig ht, if it turns out 109 // shortage we find is the amount with which we will stretch the column heig ht, if it turns out
103 // after layout that the columns weren't tall enough. 110 // after layout that the columns weren't tall enough.
104 void recordSpaceShortage(LayoutUnit spaceShortage); 111 void recordSpaceShortage(LayoutUnit spaceShortage);
105 112
106 // Reset previously calculated column height. Will mark for layout if needed . 113 // Reset previously calculated column height. Will mark for layout if needed .
107 void resetColumnHeight(); 114 void resetColumnHeight();
108 115
116 // Prepare this set for flow thread layout.
117 void resetFlow();
118 // Layout of flow thread content that's to be rendered inside this column se t begins. This
119 // happens at the beginning of flow thread layout, and when advancing from a previous column set
120 // or spanner to this one.
121 void beginFlow(LayoutUnit offsetInFlowThread);
122 // Layout of flow thread content that was to be rendered inside this column set has
123 // finished. This happens at end of flow thread layout, and when advancing t o the next column
124 // set or spanner.
125 void endFlow(LayoutUnit offsetInFlowThread);
126
109 // Expand this set's flow thread portion rectangle to contain all trailing f low thread 127 // Expand this set's flow thread portion rectangle to contain all trailing f low thread
110 // overflow. Only to be called on the last set. 128 // overflow. Only to be called on the last set.
111 void expandToEncompassFlowThreadContentsIfNeeded(); 129 void expandToEncompassFlowThreadContentsIfNeeded();
112 130
113 void attachRegion(); 131 void attachRegion();
114 void detachRegion(); 132 void detachRegion();
115 133
116 void paintInvalidationForFlowThreadContent(const LayoutRect& paintInvalidati onRect) const; 134 void paintInvalidationForFlowThreadContent(const LayoutRect& paintInvalidati onRect) const;
117 135
118 // The top of the nearest page inside the region. For RenderRegions, this is just the logical top of the 136 // The top of the nearest page inside the region. For RenderRegions, this is just the logical top of the
119 // flow thread portion we contain. For sets, we have to figure out the top o f the nearest column or 137 // flow thread portion we contain. For sets, we have to figure out the top o f the nearest column or
120 // page. 138 // page.
121 LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const; 139 LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const;
122 140
123 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB ox, const LayoutRect& dirtyRect); 141 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB ox, const LayoutRect& dirtyRect);
124 142
125 LayoutUnit columnGap() const; 143 LayoutUnit columnGap() const;
126 144
127 // The "CSS actual" value of column-count. This includes overflowing columns , if any. 145 // The "CSS actual" value of column-count. This includes overflowing columns , if any.
128 unsigned actualColumnCount() const; 146 unsigned actualColumnCount() const;
129 147
130 private: 148 protected:
131 RenderMultiColumnSet(RenderFlowThread*); 149 RenderMultiColumnSet(RenderFlowThread*);
132 150
151 private:
133 virtual void insertedIntoTree() override final; 152 virtual void insertedIntoTree() override final;
134 virtual void willBeRemovedFromTree() override final; 153 virtual void willBeRemovedFromTree() override final;
135 154
136 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic alTop, LogicalExtentComputedValues&) const override; 155 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic alTop, LogicalExtentComputedValues&) const override;
137 156
138 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) overrid e; 157 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) overrid e;
139 158
140 virtual void addOverflowFromChildren() override; 159 virtual void addOverflowFromChildren() override;
141 160
142 virtual const char* renderName() const override; 161 virtual const char* renderName() const override;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // breaks assumed so far. 214 // breaks assumed so far.
196 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); } 215 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); }
197 216
198 private: 217 private:
199 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. 218 LayoutUnit m_breakOffset; // Flow thread offset where this run ends.
200 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far. 219 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far.
201 }; 220 };
202 Vector<ContentRun, 1> m_contentRuns; 221 Vector<ContentRun, 1> m_contentRuns;
203 }; 222 };
204 223
224 inline void RenderMultiColumnSet::resetFlow()
225 {
226 // Start with "infinite" flow thread portion height until height is known.
227 setLogicalBottomInFlowThread(RenderFlowThread::maxLogicalHeight());
228 }
229
230 inline void RenderMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread)
231 {
232 // At this point layout is exactly at the beginning of this set. Store block offset from flow
233 // thread start.
234 setLogicalTopInFlowThread(offsetInFlowThread);
235 }
236
237 inline void RenderMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread)
238 {
239 // At this point layout is exactly at the end of this set. Store block offse t from flow thread
240 // start. This set is now considered "flowed", although we may have to revis it it later (with
241 // beginFlow()), e.g. if a subtree in the flow thread has to be laid out ove r again because the
242 // initial margin collapsing estimates were wrong.
243 setLogicalBottomInFlowThread(offsetInFlowThread);
244 }
245
205 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); 246 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet());
206 247
207 } // namespace blink 248 } // namespace blink
208 249
209 #endif // RenderMultiColumnSet_h 250 #endif // RenderMultiColumnSet_h
210 251
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMultiColumnFlowThread.cpp ('k') | Source/core/rendering/RenderMultiColumnSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698