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

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

Issue 856383002: [New Multicolumn] Add RenderMultiColumnFlowThread::findSetRendering(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 RenderMultiColumnSet* RenderMultiColumnFlowThread::lastMultiColumnSet() const 67 RenderMultiColumnSet* RenderMultiColumnFlowThread::lastMultiColumnSet() const
68 { 68 {
69 for (RenderObject* sibling = multiColumnBlockFlow()->lastChild(); sibling; s ibling = sibling->previousSibling()) { 69 for (RenderObject* sibling = multiColumnBlockFlow()->lastChild(); sibling; s ibling = sibling->previousSibling()) {
70 if (sibling->isRenderMultiColumnSet()) 70 if (sibling->isRenderMultiColumnSet())
71 return toRenderMultiColumnSet(sibling); 71 return toRenderMultiColumnSet(sibling);
72 } 72 }
73 return 0; 73 return 0;
74 } 74 }
75 75
76 static RenderObject* firstRendererInSet(RenderMultiColumnSet* multicolSet)
77 {
78 RenderBox* sibling = multicolSet->previousSiblingMultiColumnBox();
79 if (!sibling)
80 return multicolSet->flowThread()->firstChild();
81 // Adjacent column content sets should not occur. We would have no way of fi guring out what each
82 // of them contains then.
83 ASSERT(sibling->isRenderMultiColumnSpannerPlaceholder());
Julien - ping for review 2015/01/22 10:23:08 Note that this ASSERT is already covered by the to
mstensho (USE GERRIT) 2015/01/22 10:39:57 Yeah, since I want to explain that adjacent sets i
84 return toRenderMultiColumnSpannerPlaceholder(sibling)->rendererInFlowThread( )->nextInPreOrderAfterChildren(multicolSet->flowThread());
85 }
86
87 static RenderObject* lastRendererInSet(RenderMultiColumnSet* multicolSet)
88 {
89 RenderBox* sibling = multicolSet->nextSiblingMultiColumnBox();
90 if (!sibling)
91 return 0;
Julien - ping for review 2015/01/22 10:23:08 Shouldn't this return multicolSet->flowThread()->l
mstensho (USE GERRIT) 2015/01/22 10:39:57 I could use *lastLeafChild()*. The only caller of
Julien - ping for review 2015/01/22 11:45:44 Let's add a comment about this in the code to docu
mstensho (USE GERRIT) 2015/01/22 11:53:39 Done.
92 // Adjacent column content sets should not occur. We would have no way of fi guring out what each
93 // of them contains then.
94 ASSERT(sibling->isRenderMultiColumnSpannerPlaceholder());
95 return toRenderMultiColumnSpannerPlaceholder(sibling)->rendererInFlowThread( )->previousInPreOrder(multicolSet->flowThread());
96 }
97
98 RenderMultiColumnSet* RenderMultiColumnFlowThread::findSetRendering(RenderObject * renderer) const
99 {
100 ASSERT(!containingColumnSpannerPlaceholder(renderer)); // should not be used for spanners or content inside them.
101 ASSERT(renderer != this && renderer->isDescendantOf(this));
Julien - ping for review 2015/01/22 10:23:08 It's better to split && into different ASSERTs. Th
mstensho (USE GERRIT) 2015/01/22 10:39:57 Indeed. Done.
102 RenderMultiColumnSet* multicolSet = firstMultiColumnSet();
103 if (!multicolSet)
104 return 0;
105 if (!multicolSet->nextSiblingMultiColumnSet())
106 return multicolSet;
107
108 // This is potentially SLOW! But luckily very uncommon. You would have to dy namically insert a
109 // spanner into the middle of column contents to need this.
110 for (; multicolSet; multicolSet = multicolSet->nextSiblingMultiColumnSet()) {
111 RenderObject* firstRenderer = firstRendererInSet(multicolSet);
112 RenderObject* lastRenderer = lastRendererInSet(multicolSet);
113 ASSERT(firstRenderer);
114
115 for (RenderObject* walker = firstRenderer; walker; walker = walker->next InPreOrder(this)) {
116 if (walker == renderer)
117 return multicolSet;
118 if (walker == lastRenderer)
119 break;
120 }
121 }
122
123 return 0;
124 }
125
76 RenderMultiColumnSpannerPlaceholder* RenderMultiColumnFlowThread::containingColu mnSpannerPlaceholder(const RenderObject* descendant) const 126 RenderMultiColumnSpannerPlaceholder* RenderMultiColumnFlowThread::containingColu mnSpannerPlaceholder(const RenderObject* descendant) const
77 { 127 {
78 ASSERT(descendant->isDescendantOf(this)); 128 ASSERT(descendant->isDescendantOf(this));
79 129
80 // Before we spend time on searching the ancestry, see if there's a quick wa y to determine 130 // Before we spend time on searching the ancestry, see if there's a quick wa y to determine
81 // whether there might be any spanners at all. 131 // whether there might be any spanners at all.
82 RenderBox* firstBox = firstMultiColumnBox(); 132 RenderBox* firstBox = firstMultiColumnBox();
83 if (!firstBox || (firstBox == lastMultiColumnBox() && firstBox->isRenderMult iColumnSet())) 133 if (!firstBox || (firstBox == lastMultiColumnBox() && firstBox->isRenderMult iColumnSet()))
84 return 0; 134 return 0;
85 135
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 546 }
497 547
498 bool RenderMultiColumnFlowThread::isPageLogicalHeightKnown() const 548 bool RenderMultiColumnFlowThread::isPageLogicalHeightKnown() const
499 { 549 {
500 if (RenderMultiColumnSet* columnSet = lastMultiColumnSet()) 550 if (RenderMultiColumnSet* columnSet = lastMultiColumnSet())
501 return columnSet->pageLogicalHeight(); 551 return columnSet->pageLogicalHeight();
502 return false; 552 return false;
503 } 553 }
504 554
505 } 555 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698