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

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

Issue 179993006: [New multicol] Eliminate the need for RenderMultiColumnBlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/RenderMultiColumnBlock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #include "core/rendering/RenderBlockFlow.h" 32 #include "core/rendering/RenderBlockFlow.h"
33 33
34 #include "core/accessibility/AXObjectCache.h" 34 #include "core/accessibility/AXObjectCache.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/rendering/FastTextAutosizer.h" 36 #include "core/rendering/FastTextAutosizer.h"
37 #include "core/rendering/HitTestLocation.h" 37 #include "core/rendering/HitTestLocation.h"
38 #include "core/rendering/LayoutRectRecorder.h" 38 #include "core/rendering/LayoutRectRecorder.h"
39 #include "core/rendering/LayoutRepainter.h" 39 #include "core/rendering/LayoutRepainter.h"
40 #include "core/rendering/RenderFlowThread.h" 40 #include "core/rendering/RenderFlowThread.h"
41 #include "core/rendering/RenderLayer.h" 41 #include "core/rendering/RenderLayer.h"
42 #include "core/rendering/RenderMultiColumnBlock.h" 42 #include "core/rendering/RenderMultiColumnFlowThread.h"
43 #include "core/rendering/RenderText.h" 43 #include "core/rendering/RenderText.h"
44 #include "core/rendering/RenderView.h" 44 #include "core/rendering/RenderView.h"
45 #include "core/rendering/line/LineWidth.h" 45 #include "core/rendering/line/LineWidth.h"
46 #include "core/rendering/svg/SVGTextRunRenderingContext.h" 46 #include "core/rendering/svg/SVGTextRunRenderingContext.h"
47 #include "platform/text/BidiTextRun.h" 47 #include "platform/text/BidiTextRun.h"
48 48
49 using namespace std; 49 using namespace std;
50 50
51 namespace WebCore { 51 namespace WebCore {
52 52
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 RenderBlockFlow* renderer = new RenderBlockFlow(0); 169 RenderBlockFlow* renderer = new RenderBlockFlow(0);
170 renderer->setDocumentForAnonymous(document); 170 renderer->setDocumentForAnonymous(document);
171 return renderer; 171 return renderer;
172 } 172 }
173 173
174 RenderBlockFlow* RenderBlockFlow::createAnonymousBlockFlow() const 174 RenderBlockFlow* RenderBlockFlow::createAnonymousBlockFlow() const
175 { 175 {
176 return toRenderBlockFlow(createAnonymousWithParentRendererAndDisplay(this, B LOCK)); 176 return toRenderBlockFlow(createAnonymousWithParentRendererAndDisplay(this, B LOCK));
177 } 177 }
178 178
179 RenderObject* RenderBlockFlow::layoutSpecialExcludedChild(bool relayoutChildren, SubtreeLayoutScope& layoutScope)
180 {
181 if (RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {
eseidel 2014/02/25 22:16:05 nit: I probably would have written this as an earl
mstensho (USE GERRIT) 2014/02/25 23:17:53 Done.
182 setLogicalTopForChild(flowThread, borderBefore() + paddingBefore());
183 flowThread->layoutColumns(relayoutChildren, layoutScope);
184 determineLogicalLeftPositionForChild(flowThread);
185 return flowThread;
186 }
187 return 0;
188 }
189
190 bool RenderBlockFlow::updateLogicalWidthAndColumnWidth()
191 {
192 bool relayoutChildren = RenderBlock::updateLogicalWidthAndColumnWidth();
193 if (RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {
194 if (flowThread->computeColumnCountAndWidth())
195 relayoutChildren = true;
eseidel 2014/02/25 22:16:05 This is just return true.
mstensho (USE GERRIT) 2014/02/25 23:17:53 Done.
196 }
197 return relayoutChildren;
198 }
199
179 void RenderBlockFlow::checkForPaginationLogicalHeightChange(LayoutUnit& pageLogi calHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight) 200 void RenderBlockFlow::checkForPaginationLogicalHeightChange(LayoutUnit& pageLogi calHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight)
180 { 201 {
181 ColumnInfo* colInfo = columnInfo(); 202 if (RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {
182 if (hasColumns()) { 203 // We don't actually update any of the variables. We just subclassed to adjust our column height.
204 updateLogicalHeight();
205 flowThread->setColumnHeightAvailable(std::max<LayoutUnit>(contentLogical Height(), 0));
206 setLogicalHeight(0);
207 } else if (hasColumns()) {
eseidel 2014/02/25 22:16:05 So this will go away soon, right?
mstensho (USE GERRIT) 2014/02/25 23:17:53 Yes. :)
208 ColumnInfo* colInfo = columnInfo();
209
183 if (!pageLogicalHeight) { 210 if (!pageLogicalHeight) {
184 LayoutUnit oldLogicalHeight = logicalHeight(); 211 LayoutUnit oldLogicalHeight = logicalHeight();
185 setLogicalHeight(0); 212 setLogicalHeight(0);
186 // We need to go ahead and set our explicit page height if one exist s, so that we can 213 // We need to go ahead and set our explicit page height if one exist s, so that we can
187 // avoid doing two layout passes. 214 // avoid doing two layout passes.
188 updateLogicalHeight(); 215 updateLogicalHeight();
189 LayoutUnit columnHeight = contentLogicalHeight(); 216 LayoutUnit columnHeight = contentLogicalHeight();
190 if (columnHeight > 0) { 217 if (columnHeight > 0) {
191 pageLogicalHeight = columnHeight; 218 pageLogicalHeight = columnHeight;
192 hasSpecifiedPageLogicalHeight = true; 219 hasSpecifiedPageLogicalHeight = true;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 362
336 if (frameView()->partialLayout().isStopping()) { 363 if (frameView()->partialLayout().isStopping()) {
337 statePusher.pop(); 364 statePusher.pop();
338 return true; 365 return true;
339 } 366 }
340 367
341 // Expand our intrinsic height to encompass floats. 368 // Expand our intrinsic height to encompass floats.
342 if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsBlo ckFormattingContext()) 369 if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsBlo ckFormattingContext())
343 setLogicalHeight(lowestFloatLogicalBottom() + afterEdge); 370 setLogicalHeight(lowestFloatLogicalBottom() + afterEdge);
344 371
345 if (isRenderMultiColumnBlock()) { 372 if (RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {
346 if (toRenderMultiColumnBlock(this)->shouldRelayoutMultiColumnBlock()) { 373 if (flowThread->recalculateColumnHeights()) {
347 setChildNeedsLayout(MarkOnlyThis); 374 setChildNeedsLayout(MarkOnlyThis);
348 statePusher.pop(); 375 statePusher.pop();
349 return false; 376 return false;
350 } 377 }
351 } else if (hasColumns()) { 378 } else if (hasColumns()) {
352 OwnPtr<RenderOverflow> savedOverflow = m_overflow.release(); 379 OwnPtr<RenderOverflow> savedOverflow = m_overflow.release();
353 if (childrenInline()) 380 if (childrenInline())
354 addOverflowFromInlineChildren(); 381 addOverflowFromInlineChildren();
355 else 382 else
356 addOverflowFromBlockChildren(); 383 addOverflowFromBlockChildren();
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 break; 1829 break;
1803 } 1830 }
1804 } 1831 }
1805 } 1832 }
1806 } 1833 }
1807 } 1834 }
1808 1835
1809 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); 1836 parentBlockFlow->markAllDescendantsWithFloatsForLayout();
1810 parentBlockFlow->markSiblingsWithFloatsForLayout(); 1837 parentBlockFlow->markSiblingsWithFloatsForLayout();
1811 } 1838 }
1839
1840 createMultiColumnFlowThreadIfNeeded();
1812 } 1841 }
1813 1842
1814 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop) 1843 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop)
1815 { 1844 {
1816 if (child->style()->isOriginalDisplayInlineType()) 1845 if (child->style()->isOriginalDisplayInlineType())
1817 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false)); 1846 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false));
1818 else 1847 else
1819 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent ()); 1848 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent ());
1820 } 1849 }
1821 1850
1822 void RenderBlockFlow::setStaticInlinePositionForChild(RenderBox* child, LayoutUn it blockOffset, LayoutUnit inlinePosition) 1851 void RenderBlockFlow::setStaticInlinePositionForChild(RenderBox* child, LayoutUn it blockOffset, LayoutUnit inlinePosition)
1823 { 1852 {
1824 child->layer()->setStaticInlinePosition(inlinePosition); 1853 child->layer()->setStaticInlinePosition(inlinePosition);
1825 } 1854 }
1826 1855
1856 void RenderBlockFlow::addChild(RenderObject* newChild, RenderObject* beforeChild )
1857 {
1858 if (RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread())
1859 return flowThread->addChild(newChild, beforeChild);
1860 RenderBlock::addChild(newChild, beforeChild);
1861 }
1862
1827 void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, boo l fullRemoveInsert) 1863 void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, boo l fullRemoveInsert)
1828 { 1864 {
1829 RenderBlockFlow* toBlockFlow = toRenderBlockFlow(toBlock); 1865 RenderBlockFlow* toBlockFlow = toRenderBlockFlow(toBlock);
1830 moveAllChildrenTo(toBlockFlow, fullRemoveInsert); 1866 moveAllChildrenTo(toBlockFlow, fullRemoveInsert);
1831 1867
1832 // When a portion of the render tree is being detached, anonymous blocks 1868 // When a portion of the render tree is being detached, anonymous blocks
1833 // will be combined as their children are deleted. In this process, the 1869 // will be combined as their children are deleted. In this process, the
1834 // anonymous block later in the tree is merged into the one preceeding it. 1870 // anonymous block later in the tree is merged into the one preceeding it.
1835 // It can happen that the later block (this) contains floats that the 1871 // It can happen that the later block (this) contains floats that the
1836 // previous block (toBlockFlow) did not contain, and thus are not in the 1872 // previous block (toBlockFlow) did not contain, and thus are not in the
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 return constructTextRun(context, font, string, style, 2761 return constructTextRun(context, font, string, style,
2726 determineDirectionality(string, hasStrongDirectionality), 2762 determineDirectionality(string, hasStrongDirectionality),
2727 expansion, flags); 2763 expansion, flags);
2728 } 2764 }
2729 2765
2730 RootInlineBox* RenderBlockFlow::createRootInlineBox() 2766 RootInlineBox* RenderBlockFlow::createRootInlineBox()
2731 { 2767 {
2732 return new RootInlineBox(this); 2768 return new RootInlineBox(this);
2733 } 2769 }
2734 2770
2771 void RenderBlockFlow::createMultiColumnFlowThreadIfNeeded()
2772 {
2773 if ((style()->hasAutoColumnCount() && style()->hasAutoColumnWidth()) || !doc ument().regionBasedColumnsEnabled())
2774 return;
2775
2776 if (multiColumnFlowThread())
2777 return;
2778
2779 setChildrenInline(false);
2780 RenderMultiColumnFlowThread* flowThread = RenderMultiColumnFlowThread::creat eAnonymous(document(), style());
2781 RenderBlock::addChild(flowThread);
2782 RenderBlockFlowRareData& rareData = ensureRareData();
2783 rareData.m_multiColumnFlowThread = flowThread;
eseidel 2014/02/25 22:16:05 Do we need to ASSERT that it doesnt' arleady have
mstensho (USE GERRIT) 2014/02/25 23:17:53 Done. You're right about multiColumnFlowThread(),
2784 }
2785
2735 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() 2786 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
2736 { 2787 {
2737 if (m_rareData) 2788 if (m_rareData)
2738 return *m_rareData; 2789 return *m_rareData;
2739 2790
2740 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 2791 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
2741 return *m_rareData; 2792 return *m_rareData;
2742 } 2793 }
2743 2794
2744 } // namespace WebCore 2795 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/RenderMultiColumnBlock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698