@@ -77,29 +77,29 @@ static bool isValidColumnSpanner(const RenderMultiColumnFlow& fragmentedFlow, co
77
77
// We assume that we're inside the flow thread. This function is not to be called otherwise.
78
78
ASSERT (descendant.isDescendantOf (&fragmentedFlow));
79
79
// First make sure that the renderer itself has the right properties for becoming a spanner.
80
- if (!is<RenderBox>(descendant))
80
+ auto * descendantBox = dynamicDowncast<RenderBox>(descendant);
81
+ if (!descendantBox)
81
82
return false ;
82
83
83
- auto & descendantBox = downcast<RenderBox>(descendant);
84
- if (descendantBox.isFloatingOrOutOfFlowPositioned ())
84
+ if (descendantBox->isFloatingOrOutOfFlowPositioned ())
85
85
return false ;
86
86
87
- if (descendantBox. style ().columnSpan () != ColumnSpan::All)
87
+ if (descendantBox-> style ().columnSpan () != ColumnSpan::All)
88
88
return false ;
89
89
90
- auto * parent = descendantBox. parent ();
90
+ auto * parent = descendantBox-> parent ();
91
91
if (!is<RenderBlockFlow>(*parent) || parent->childrenInline ()) {
92
92
// Needs to be block-level.
93
93
return false ;
94
94
}
95
95
96
96
// We need to have the flow thread as the containing block. A spanner cannot break out of the flow thread.
97
- auto * enclosingFragmentedFlow = descendantBox. enclosingFragmentedFlow ();
97
+ auto * enclosingFragmentedFlow = descendantBox-> enclosingFragmentedFlow ();
98
98
if (enclosingFragmentedFlow != &fragmentedFlow)
99
99
return false ;
100
100
101
101
// This looks like a spanner, but if we're inside something unbreakable, it's not to be treated as one.
102
- for (auto * ancestor = descendantBox. containingBlock (); ancestor; ancestor = ancestor->containingBlock ()) {
102
+ for (auto * ancestor = descendantBox-> containingBlock (); ancestor; ancestor = ancestor->containingBlock ()) {
103
103
if (is<RenderView>(*ancestor))
104
104
return false ;
105
105
if (ancestor->isLegend ())
@@ -112,13 +112,12 @@ static bool isValidColumnSpanner(const RenderMultiColumnFlow& fragmentedFlow, co
112
112
// implement (not to mention specify behavior).
113
113
return ancestor == &fragmentedFlow;
114
114
}
115
- if (is<RenderBlockFlow>(*ancestor)) {
116
- auto & blockFlowAncestor = downcast<RenderBlockFlow>(*ancestor);
117
- if (blockFlowAncestor.willCreateColumns ()) {
115
+ if (auto * blockFlowAncestor = dynamicDowncast<RenderBlockFlow>(*ancestor)) {
116
+ if (blockFlowAncestor->willCreateColumns ()) {
118
117
// This ancestor (descendent of the fragmentedFlow) will create columns later. The spanner belongs to it.
119
118
return false ;
120
119
}
121
- if (blockFlowAncestor. multiColumnFlow ()) {
120
+ if (blockFlowAncestor-> multiColumnFlow ()) {
122
121
// While this ancestor (descendent of the fragmentedFlow) has a fragmented flow context, this context is being destroyed.
123
122
// However the spanner still belongs to it (will most likely be moved to the parent fragmented context as the next step).
124
123
return false ;
@@ -158,8 +157,8 @@ void RenderTreeBuilder::MultiColumn::createFragmentedFlow(RenderBlockFlow& flow)
158
157
flow.deleteLines ();
159
158
// If this soon-to-be multicolumn flow is already part of a multicolumn context, we need to move back the descendant spanners
160
159
// to their original position before moving subtrees around.
161
- if (auto * enclosingflow = flow.enclosingFragmentedFlow (); is<RenderMultiColumnFlow>(enclosingflow ))
162
- restoreColumnSpannersForContainer (flow, downcast<RenderMultiColumnFlow>( *enclosingflow) );
160
+ if (auto * enclosingflow = dynamicDowncast<RenderMultiColumnFlow>( flow.enclosingFragmentedFlow ()))
161
+ restoreColumnSpannersForContainer (flow, *enclosingflow);
163
162
164
163
auto newFragmentedFlow = WebCore::createRenderer<RenderMultiColumnFlow>(flow.document (), RenderStyle::createAnonymousStyleWithDisplay (flow.style (), DisplayType::Block));
165
164
newFragmentedFlow->initializeStyle ();
@@ -256,7 +255,8 @@ RenderObject* RenderTreeBuilder::MultiColumn::resolveMovedChild(RenderFragmented
256
255
if (!is<RenderBox>(*beforeChild))
257
256
return beforeChild;
258
257
259
- if (!is<RenderMultiColumnFlow>(enclosingFragmentedFlow))
258
+ auto * renderMultiColumnFlow = dynamicDowncast<RenderMultiColumnFlow>(enclosingFragmentedFlow);
259
+ if (!renderMultiColumnFlow)
260
260
return beforeChild;
261
261
262
262
// We only need to resolve for column spanners.
@@ -269,7 +269,7 @@ RenderObject* RenderTreeBuilder::MultiColumn::resolveMovedChild(RenderFragmented
269
269
// create and insert a renderer for the sibling node immediately preceding the spanner, we need
270
270
// to map that spanner renderer to the spanner's placeholder, which is where the new inserted
271
271
// renderer belongs.
272
- if (auto * placeholder = downcast<RenderMultiColumnFlow>(enclosingFragmentedFlow). findColumnSpannerPlaceholder (downcast<RenderBox>(beforeChild)))
272
+ if (auto * placeholder = renderMultiColumnFlow-> findColumnSpannerPlaceholder (downcast<RenderBox>(beforeChild)))
273
273
return placeholder;
274
274
275
275
// This is an invalid spanner, or its placeholder hasn't been created yet. This happens when
@@ -294,14 +294,13 @@ void RenderTreeBuilder::MultiColumn::multiColumnDescendantInserted(RenderMultiCo
294
294
descendant = descendant->nextSibling ();
295
295
continue ;
296
296
}
297
- if (is <RenderMultiColumnSpannerPlaceholder>(*descendant)) {
297
+ if (auto * placeholder = dynamicDowncast <RenderMultiColumnSpannerPlaceholder>(*descendant)) {
298
298
// A spanner's placeholder has been inserted. The actual spanner renderer is moved from
299
299
// where it would otherwise occur (if it weren't a spanner) to becoming a sibling of the
300
300
// column sets.
301
- RenderMultiColumnSpannerPlaceholder& placeholder = downcast<RenderMultiColumnSpannerPlaceholder>(*descendant);
302
- ASSERT (!flow.spannerMap ().get (placeholder.spanner ()));
303
- flow.spannerMap ().add (placeholder.spanner (), downcast<RenderMultiColumnSpannerPlaceholder>(descendant));
304
- ASSERT (!placeholder.firstChild ()); // There should be no children here, but if there are, we ought to skip them.
301
+ ASSERT (!flow.spannerMap ().get (placeholder->spanner ()));
302
+ flow.spannerMap ().add (placeholder->spanner (), placeholder);
303
+ ASSERT (!placeholder->firstChild ()); // There should be no children here, but if there are, we ought to skip them.
305
304
} else
306
305
descendant = processPossibleSpannerDescendant (flow, subtreeRoot, *descendant);
307
306
if (descendant)
@@ -358,14 +357,13 @@ RenderObject* RenderTreeBuilder::MultiColumn::processPossibleSpannerDescendant(R
358
357
nextDescendant = &placeholder;
359
358
} else {
360
359
// This is regular multicol content, i.e. not part of a spanner.
361
- if (is <RenderMultiColumnSpannerPlaceholder>(nextRendererInFragmentedFlow)) {
360
+ if (auto * placeholder = dynamicDowncast <RenderMultiColumnSpannerPlaceholder>(nextRendererInFragmentedFlow)) {
362
361
// Inserted right before a spanner. Is there a set for us there?
363
- RenderMultiColumnSpannerPlaceholder& placeholder = downcast<RenderMultiColumnSpannerPlaceholder>(*nextRendererInFragmentedFlow);
364
- if (RenderObject* previous = placeholder.spanner ()->previousSibling ()) {
362
+ if (RenderObject* previous = placeholder->spanner ()->previousSibling ()) {
365
363
if (is<RenderMultiColumnSet>(*previous))
366
364
return nextDescendant; // There's already a set there. Nothing to do.
367
365
}
368
- insertBeforeMulticolChild = placeholder. spanner ();
366
+ insertBeforeMulticolChild = placeholder-> spanner ();
369
367
} else if (RenderMultiColumnSet* lastSet = flow.lastMultiColumnSet ()) {
370
368
// This child is not an immediate predecessor of a spanner, which means that if this
371
369
// child precedes a spanner at all, there has to be a column set created for us there
@@ -419,12 +417,12 @@ void RenderTreeBuilder::MultiColumn::handleSpannerRemoval(RenderMultiColumnFlow&
419
417
void RenderTreeBuilder::MultiColumn::multiColumnRelativeWillBeRemoved (RenderMultiColumnFlow& flow, RenderObject& relative, RenderTreeBuilder::CanCollapseAnonymousBlock canCollapseAnonymousBlock)
420
418
{
421
419
flow.invalidateFragments ();
422
- if (is <RenderMultiColumnSpannerPlaceholder>(relative)) {
420
+ if (auto * placeholder = dynamicDowncast <RenderMultiColumnSpannerPlaceholder>(relative)) {
423
421
// Remove the map entry for this spanner, but leave the actual spanner renderer alone. Also
424
422
// keep the reference to the spanner, since the placeholder may be about to be re-inserted
425
423
// in the tree.
426
424
ASSERT (relative.isDescendantOf (&flow));
427
- flow.spannerMap ().remove (downcast<RenderMultiColumnSpannerPlaceholder>(relative). spanner ());
425
+ flow.spannerMap ().remove (placeholder-> spanner ());
428
426
return ;
429
427
}
430
428
if (relative.style ().columnSpan () == ColumnSpan::All) {
@@ -440,21 +438,23 @@ void RenderTreeBuilder::MultiColumn::multiColumnRelativeWillBeRemoved(RenderMult
440
438
441
439
RenderObject* RenderTreeBuilder::MultiColumn::adjustBeforeChildForMultiColumnSpannerIfNeeded (RenderObject& beforeChild)
442
440
{
443
- if (!is<RenderBox>(beforeChild))
441
+ auto * beforeChildBox = dynamicDowncast<RenderBox>(beforeChild);
442
+ if (!beforeChildBox)
444
443
return &beforeChild;
445
444
446
- auto * nextSibling = beforeChild. nextSibling ();
445
+ auto * nextSibling = beforeChildBox-> nextSibling ();
447
446
if (!nextSibling)
448
447
return &beforeChild;
449
448
450
- if (!is<RenderMultiColumnSet>(*nextSibling))
449
+ auto * renderMultiColumnSet = dynamicDowncast<RenderMultiColumnSet>(*nextSibling);
450
+ if (!renderMultiColumnSet)
451
451
return &beforeChild;
452
452
453
- auto * multiColumnFlow = downcast<RenderMultiColumnSet>(*nextSibling). multiColumnFlow ();
453
+ auto * multiColumnFlow = renderMultiColumnSet-> multiColumnFlow ();
454
454
if (!multiColumnFlow)
455
455
return &beforeChild;
456
456
457
- return multiColumnFlow->findColumnSpannerPlaceholder (downcast<RenderBox>(&beforeChild) );
457
+ return multiColumnFlow->findColumnSpannerPlaceholder (beforeChildBox );
458
458
}
459
459
460
460
}
0 commit comments