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

Side by Side Diff: Source/core/rendering/RenderMultiColumnFlowThread.cpp

Issue 143323014: *** DO NOT LAND *** Attempt to understand Regions complexity Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS IN..0TERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27 #include "core/rendering/RenderMultiColumnFlowThread.h"
28
29 #include "core/rendering/RenderMultiColumnBlock.h"
30 #include "core/rendering/RenderMultiColumnSet.h"
31
32 namespace WebCore {
33
34 RenderMultiColumnFlowThread::RenderMultiColumnFlowThread()
35 {
36 setFlowThreadState(InsideInFlowThread);
37 }
38
39 RenderMultiColumnFlowThread::~RenderMultiColumnFlowThread()
40 {
41 }
42
43 RenderMultiColumnFlowThread* RenderMultiColumnFlowThread::createAnonymous(Docume nt* document)
44 {
45 RenderMultiColumnFlowThread* renderer = new RenderMultiColumnFlowThread();
46 renderer->setDocumentForAnonymous(document);
47 return renderer;
48 }
49
50 const char* RenderMultiColumnFlowThread::renderName() const
51 {
52 return "RenderMultiColumnFlowThread";
53 }
54
55 void RenderMultiColumnFlowThread::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
56 {
57 // We simply remain at our intrinsic height.
58 computedValues.m_extent = logicalHeight;
59 computedValues.m_position = logicalTop;
60 }
61
62 LayoutUnit RenderMultiColumnFlowThread::initialLogicalWidth() const
63 {
64 RenderMultiColumnBlock* parentBlock = toRenderMultiColumnBlock(parent());
65 return parentBlock->columnWidth();
66 }
67
68 void RenderMultiColumnFlowThread::autoGenerateRegionsToBlockOffset(LayoutUnit /* offset*/)
69 {
70 // This function ensures we have the correct column set information at all t imes.
71 // For a simple multi-column layout in continuous media, only one column set child is required.
72 // Once a column is nested inside an enclosing pagination context, the numbe r of column sets
73 // required becomes 2n-1, where n is the total number of nested pagination c ontexts. For example:
74 //
75 // Column layout with no enclosing pagination model = 2 * 1 - 1 = 1 column s et.
76 // Columns inside pages = 2 * 2 - 1 = 3 column sets (bottom of first page, a ll the subsequent pages, then the last page).
77 // Columns inside columns inside pages = 2 * 3 - 1 = 5 column sets.
78 //
79 // In addition, column spans will force a column set to "split" into before/ after sets around the spanning element.
80 //
81 // Finally, we will need to deal with columns inside regions. If regions hav e variable widths, then there will need
82 // to be unique column sets created inside any region whose width is differe nt from its surrounding regions. This is
83 // actually pretty similar to the spanning case, in that we break up the col umn sets whenever the width varies.
84 //
85 // FIXME: For now just make one column set. This matches the old multi-colum n code.
86 // Right now our goal is just feature parity with the old multi-column code so that we can switch over to the
87 // new code as soon as possible.
88 RenderMultiColumnSet* firstSet = toRenderMultiColumnSet(firstRegion());
89 if (firstSet)
90 return;
91
92 invalidateRegions();
93
94 RenderMultiColumnBlock* parentBlock = toRenderMultiColumnBlock(parent());
95 firstSet = RenderMultiColumnSet::createAnonymous(this);
96 firstSet->setStyle(RenderStyle::createAnonymousStyleWithDisplay(parentBlock- >style(), BLOCK));
97 parentBlock->RenderBlock::addChild(firstSet);
98
99 // Even though we aren't placed yet, we can go ahead and set up our size. At this point we're
100 // typically in the middle of laying out the thread, attempting to paginate, and we need to do
101 // some rudimentary "layout" of the set now, so that pagination will work.
102 firstSet->prepareForLayout();
103
104 validateRegions();
105 }
106
107 void RenderMultiColumnFlowThread::setPageBreak(LayoutUnit offset, LayoutUnit spa ceShortage)
108 {
109 if (RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(regionAtBlock Offset(offset)))
110 multicolSet->recordSpaceShortage(spaceShortage);
111 }
112
113 void RenderMultiColumnFlowThread::updateMinimumPageHeight(LayoutUnit offset, Lay outUnit minHeight)
114 {
115 if (RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(regionAtBlock Offset(offset)))
116 multicolSet->updateMinimumColumnHeight(minHeight);
117 }
118
119 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMultiColumnFlowThread.h ('k') | Source/core/rendering/RenderMultiColumnSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698