| Differences between
and this patch
- a/Source/WebCore/ChangeLog +126 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2014-10-07  Christophe Dumez  <cdumez@apple.com>
2
3
        Use is<>() / downcast<>() for RenderBlock objects
4
        https://bugs.webkit.org/show_bug.cgi?id=137512
5
6
        Reviewed by Darin Adler.
7
8
        Use is<>() / downcast<>() for RenderBlock objects and clean up the
9
        surrounding code.
10
11
        No new tests, no behavior change.
12
13
        * accessibility/AccessibilityRenderObject.cpp:
14
        (WebCore::firstChildConsideringContinuation):
15
        (WebCore::lastChildConsideringContinuation):
16
        (WebCore::AccessibilityRenderObject::firstChild):
17
        (WebCore::startOfContinuations):
18
        (WebCore::endOfContinuations):
19
        (WebCore::childBeforeConsideringContinuations):
20
        (WebCore::AccessibilityRenderObject::previousSibling):
21
        (WebCore::AccessibilityRenderObject::nextSibling):
22
        (WebCore::nextContinuation):
23
        (WebCore::AccessibilityRenderObject::renderParentObject):
24
        (WebCore::AccessibilityRenderObject::anchorElement):
25
        (WebCore::AccessibilityRenderObject::setValue):
26
        * bindings/objc/DOMUIKitExtensions.mm:
27
        (-[DOMNode containsOnlyInlineObjects]):
28
        (-[DOMNode isSelectableBlock]):
29
        (-[DOMHTMLElement structuralComplexityContribution]):
30
        * css/CSSComputedStyleDeclaration.cpp:
31
        (WebCore::valueForGridTrackList):
32
        * editing/CompositeEditCommand.cpp:
33
        (WebCore::CompositeEditCommand::addBlockPlaceholderIfNeeded):
34
        * editing/TextIterator.cpp:
35
        (WebCore::TextIterator::shouldRepresentNodeOffsetZero):
36
        * page/ios/FrameIOS.mm:
37
        (WebCore::Frame::preferredHeight):
38
        * rendering/LogicalSelectionOffsetCaches.h:
39
        (WebCore::containingBlockForFixedPosition):
40
        (WebCore::containingBlockForAbsolutePosition):
41
        (WebCore::containingBlockForObjectInFlow):
42
        * rendering/RenderBlock.cpp:
43
        (WebCore::RenderBlock::styleWillChange):
44
        (WebCore::RenderBlock::continuationBefore):
45
        (WebCore::RenderBlock::splitBlocks):
46
        (WebCore::RenderBlock::addChildIgnoringContinuation):
47
        (WebCore::canMergeAnonymousBlock):
48
        (WebCore::canMergeContiguousAnonymousBlocks):
49
        (WebCore::RenderBlock::collapseAnonymousBoxChild):
50
        (WebCore::RenderBlock::removeChild):
51
        (WebCore::RenderBlock::blockElementContinuation):
52
        (WebCore::RenderBlock::blockSelectionGaps):
53
        (WebCore::RenderBlock::blockBeforeWithinSelectionRoot):
54
        (WebCore::isChildHitTestCandidate):
55
        (WebCore::RenderBlock::firstLineBlock):
56
        (WebCore::findFirstLetterBlock):
57
        (WebCore::RenderBlock::childBecameNonInline):
58
        (WebCore::RenderBlock::hasMarginBeforeQuirk):
59
        (WebCore::RenderBlock::hasMarginAfterQuirk):
60
        * rendering/RenderBlock.h:
61
        * rendering/RenderBlockFlow.cpp:
62
        (WebCore::RenderBlockFlow::marginBeforeEstimateForChild):
63
        (WebCore::RenderBlockFlow::estimateLogicalTopPosition):
64
        (WebCore::RenderBlockFlow::adjustBlockChildForPagination):
65
        (WebCore::RenderBlockFlow::positionNewFloats):
66
        (WebCore::RenderBlockFlow::markSiblingsWithFloatsForLayout):
67
        * rendering/RenderBlockLineLayout.cpp:
68
        (WebCore::RenderBlockFlow::positionNewFloatOnLine):
69
        * rendering/RenderBox.cpp:
70
        (WebCore::RenderBox::computeReplacedLogicalHeightUsing):
71
        (WebCore::RenderBox::availableLogicalHeightUsing):
72
        (WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
73
        (WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
74
        (WebCore::computeInlineStaticDistance):
75
        (WebCore::RenderBox::computePositionedLogicalWidth):
76
        (WebCore::RenderBox::computePositionedLogicalHeight):
77
        * rendering/RenderBoxModelObject.cpp:
78
        (WebCore::accumulateInFlowPositionOffsets):
79
        (WebCore::RenderBoxModelObject::moveChildTo):
80
        (WebCore::RenderBoxModelObject::moveChildrenTo):
81
        * rendering/RenderElement.cpp:
82
        (WebCore::RenderElement::propagateStyleToAnonymousChildren):
83
        * rendering/RenderFlowThread.cpp:
84
        (WebCore::RenderFlowThread::adjustedPositionRelativeToOffsetParent):
85
        * rendering/RenderFullScreen.cpp:
86
        (WebCore::RenderFullScreen::unwrapRenderer):
87
        * rendering/RenderInline.cpp:
88
        (WebCore::RenderInline::inlineElementContinuation):
89
        (WebCore::updateStyleOfAnonymousBlockContinuations):
90
        (WebCore::RenderInline::styleDidChange):
91
        (WebCore::nextContinuation):
92
        (WebCore::RenderInline::splitFlow):
93
        (WebCore::RenderInline::positionForPoint):
94
        * rendering/RenderLayer.cpp:
95
        (WebCore::RenderLayer::updateScrollbarsAfterLayout):
96
        (WebCore::RenderLayer::calculateClipRects):
97
        * rendering/RenderListItem.cpp:
98
        (WebCore::getParentOfFirstLineBox):
99
        (WebCore::RenderListItem::insertOrMoveMarkerRendererIfNeeded):
100
        (WebCore::RenderListItem::positionListMarker):
101
        * rendering/RenderNamedFlowFragment.cpp:
102
        (WebCore::RenderNamedFlowFragment::maxPageLogicalHeight):
103
        * rendering/RenderObject.cpp:
104
        (WebCore::includeNonFixedHeight):
105
        (WebCore::RenderObject::checkBlockPositionedObjectsNeedLayout):
106
        (WebCore::RenderObject::containingBlock):
107
        (WebCore::RenderObject::handleDynamicFloatPositionChange):
108
        (WebCore::RenderObject::removeAnonymousWrappersForInlinesIfNecessary):
109
        (WebCore::RenderObject::getTextDecorationColors):
110
        * rendering/RenderRuby.cpp:
111
        (WebCore::rubyBeforeBlock):
112
        (WebCore::rubyAfterBlock):
113
        * rendering/RenderRubyBase.cpp:
114
        (WebCore::RenderRubyBase::moveInlineChildren):
115
        (WebCore::RenderRubyBase::moveBlockChildren):
116
        * rendering/RenderThemeMac.mm:
117
        (WebCore::RenderThemeMac::paintSnapshottedPluginOverlay):
118
        * rendering/TextAutosizer.cpp:
119
        (WebCore::TextAutosizer::processSubtree):
120
        (WebCore::TextAutosizer::processContainer):
121
        (WebCore::TextAutosizer::measureDescendantTextWidth):
122
        (WebCore::TextAutosizer::findDeepestBlockContainingAllText):
123
        (WebCore::TextAutosizer::findFirstTextLeafNotInCluster):
124
        * rendering/mathml/RenderMathMLRoot.cpp:
125
        (WebCore::RenderMathMLRoot::layout):
126
1
2014-10-08  Jer Noble  <jer.noble@apple.com>
127
2014-10-08  Jer Noble  <jer.noble@apple.com>
2
128
3
        Unreviewed follow-up fix for r174460. Do not register for KVOs if the object does not respond to the requested property.
129
        Unreviewed follow-up fix for r174460. Do not register for KVOs if the object does not respond to the requested property.
- a/Source/WebKit2/ChangeLog +14 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2014-10-07  Christophe Dumez  <cdumez@apple.com>
2
3
        Use is<>() / downcast<>() for RenderBlock objects
4
        https://bugs.webkit.org/show_bug.cgi?id=137512
5
6
        Reviewed by Darin Adler.
7
8
        Use is<>() / downcast<>() for RenderBlock objects and clean up the 
9
        surrounding code.
10
11
        * WebProcess/WebPage/ios/WebPageIOS.mm:
12
        (WebKit::WebPage::rangeForWebSelectionAtPosition):
13
        (WebKit::WebPage::contractedRangeFromHandle):
14
1
2014-10-08  Ada Chan  <adachan@apple.com>
15
2014-10-08  Ada Chan  <adachan@apple.com>
2
16
3
        Implement WKPageIsPlayingAudio().
17
        Implement WKPageIsPlayingAudio().
- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp -93 / +82 lines
Lines 186-222 static inline RenderObject* firstChildInContinuation(RenderInline& renderer) a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec1
186
    return nullptr;
186
    return nullptr;
187
}
187
}
188
188
189
static inline RenderObject* firstChildConsideringContinuation(RenderObject* renderer)
189
static inline RenderObject* firstChildConsideringContinuation(RenderObject& renderer)
190
{
190
{
191
    RenderObject* firstChild = renderer->firstChildSlow();
191
    RenderObject* firstChild = renderer.firstChildSlow();
192
192
193
    if (!firstChild && isInlineWithContinuation(renderer))
193
    if (!firstChild && isInlineWithContinuation(&renderer))
194
        firstChild = firstChildInContinuation(toRenderInline(*renderer));
194
        firstChild = firstChildInContinuation(downcast<RenderInline>(renderer));
195
195
196
    return firstChild;
196
    return firstChild;
197
}
197
}
198
198
199
199
200
static inline RenderObject* lastChildConsideringContinuation(RenderObject* renderer)
200
static inline RenderObject* lastChildConsideringContinuation(RenderObject& renderer)
201
{
201
{
202
    RenderObject* lastChild = renderer->lastChildSlow();
202
    if (!is<RenderInline>(renderer) && !is<RenderBlock>(renderer))
203
    RenderObject* prev;
203
        return &renderer;
204
    RenderObject* cur = renderer;
205
204
206
    if (!cur->isRenderInline() && !cur->isRenderBlock())
205
    RenderObject* lastChild = downcast<RenderBoxModelObject>(renderer).lastChild();
207
        return renderer;
206
    RenderBoxModelObject* previous;
207
    for (auto* current = &downcast<RenderBoxModelObject>(renderer); current; ) {
208
        previous = current;
208
209
209
    while (cur) {
210
        if (RenderObject* newLastChild = current->lastChild())
210
        prev = cur;
211
            lastChild = newLastChild;
211
212
212
        if (RenderObject* lc = cur->lastChildSlow())
213
        if (is<RenderInline>(*current)) {
213
            lastChild = lc;
214
            current = downcast<RenderInline>(*current).inlineElementContinuation();
214
215
            ASSERT_UNUSED(previous, current || !downcast<RenderInline>(*previous).continuation());
215
        if (cur->isRenderInline()) {
216
            cur = toRenderInline(cur)->inlineElementContinuation();
217
            ASSERT_UNUSED(prev, cur || !toRenderInline(prev)->continuation());
218
        } else
216
        } else
219
            cur = toRenderBlock(cur)->inlineElementContinuation();
217
            current = downcast<RenderBlock>(*current).inlineElementContinuation();
220
    }
218
    }
221
219
222
    return lastChild;
220
    return lastChild;
Lines 227-233 AccessibilityObject* AccessibilityRenderObject::firstChild() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec2
227
    if (!m_renderer)
225
    if (!m_renderer)
228
        return nullptr;
226
        return nullptr;
229
    
227
    
230
    RenderObject* firstChild = firstChildConsideringContinuation(m_renderer);
228
    RenderObject* firstChild = firstChildConsideringContinuation(*m_renderer);
231
229
232
    // If an object can't have children, then it is using this method to help
230
    // If an object can't have children, then it is using this method to help
233
    // calculate some internal property (like its description).
231
    // calculate some internal property (like its description).
Lines 244-250 AccessibilityObject* AccessibilityRenderObject::lastChild() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec3
244
    if (!m_renderer)
242
    if (!m_renderer)
245
        return nullptr;
243
        return nullptr;
246
244
247
    RenderObject* lastChild = lastChildConsideringContinuation(m_renderer);
245
    RenderObject* lastChild = lastChildConsideringContinuation(*m_renderer);
248
246
249
    if (!lastChild && !canHaveChildren())
247
    if (!lastChild && !canHaveChildren())
250
        return AccessibilityNodeObject::lastChild();
248
        return AccessibilityNodeObject::lastChild();
Lines 252-318 AccessibilityObject* AccessibilityRenderObject::lastChild() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec4
252
    return axObjectCache()->getOrCreate(lastChild);
250
    return axObjectCache()->getOrCreate(lastChild);
253
}
251
}
254
252
255
static inline RenderInline* startOfContinuations(RenderObject* r)
253
static inline RenderInline* startOfContinuations(RenderObject& renderer)
256
{
254
{
257
    if (r->isInlineElementContinuation())
255
    if (renderer.isInlineElementContinuation())
258
        return toRenderInline(r->node()->renderer());
256
        return downcast<RenderInline>(renderer.node()->renderer());
259
257
260
    // Blocks with a previous continuation always have a next continuation
258
    // Blocks with a previous continuation always have a next continuation
261
    if (r->isRenderBlock() && toRenderBlock(r)->inlineElementContinuation())
259
    if (is<RenderBlock>(renderer) && downcast<RenderBlock>(renderer).inlineElementContinuation())
262
        return toRenderInline(toRenderBlock(r)->inlineElementContinuation()->element()->renderer());
260
        return downcast<RenderInline>(downcast<RenderBlock>(renderer).inlineElementContinuation()->element()->renderer());
263
261
264
    return nullptr;
262
    return nullptr;
265
}
263
}
266
264
267
static inline RenderObject* endOfContinuations(RenderObject* renderer)
265
static inline RenderObject* endOfContinuations(RenderObject& renderer)
268
{
266
{
269
    RenderObject* prev = renderer;
267
    if (!is<RenderInline>(renderer) && !is<RenderBlock>(renderer))
270
    RenderObject* cur = renderer;
268
        return &renderer;
271
272
    if (!cur->isRenderInline() && !cur->isRenderBlock())
273
        return renderer;
274
269
275
    while (cur) {
270
    auto* previous = &downcast<RenderBoxModelObject>(renderer);
276
        prev = cur;
271
    for (auto* current = previous; current; ) {
277
        if (cur->isRenderInline()) {
272
        previous = current;
278
            cur = toRenderInline(cur)->inlineElementContinuation();
273
        if (is<RenderInline>(*current)) {
279
            ASSERT(cur || !toRenderInline(prev)->continuation());
274
            current = downcast<RenderInline>(*current).inlineElementContinuation();
275
            ASSERT(current || !downcast<RenderInline>(*previous).continuation());
280
        } else 
276
        } else 
281
            cur = toRenderBlock(cur)->inlineElementContinuation();
277
            current = downcast<RenderBlock>(*current).inlineElementContinuation();
282
    }
278
    }
283
279
284
    return prev;
280
    return previous;
285
}
281
}
286
282
287
283
288
static inline RenderObject* childBeforeConsideringContinuations(RenderInline* r, RenderObject* child)
284
static inline RenderObject* childBeforeConsideringContinuations(RenderInline* renderer, RenderObject* child)
289
{
285
{
290
    RenderBoxModelObject* curContainer = r;
286
    RenderObject* previous = nullptr;
291
    RenderObject* cur = nullptr;
287
    for (RenderBoxModelObject* currentContainer = renderer; currentContainer; ) {
292
    RenderObject* prev = nullptr;
288
        if (is<RenderInline>(*currentContainer)) {
293
289
            auto* current = currentContainer->firstChild();
294
    while (curContainer) {
290
            while (current) {
295
        if (curContainer->isRenderInline()) {
291
                if (current == child)
296
            cur = curContainer->firstChild();
292
                    return previous;
297
            while (cur) {
293
                previous = current;
298
                if (cur == child)
294
                current = current->nextSibling();
299
                    return prev;
300
                prev = cur;
301
                cur = cur->nextSibling();
302
            }
295
            }
303
296
304
            curContainer = toRenderInline(curContainer)->continuation();
297
            currentContainer = downcast<RenderInline>(*currentContainer).continuation();
305
        } else if (curContainer->isRenderBlock()) {
298
        } else if (is<RenderBlock>(*currentContainer)) {
306
            if (curContainer == child)
299
            if (currentContainer == child)
307
                return prev;
300
                return previous;
308
301
309
            prev = curContainer;
302
            previous = currentContainer;
310
            curContainer = toRenderBlock(curContainer)->inlineElementContinuation();
303
            currentContainer = downcast<RenderBlock>(*currentContainer).inlineElementContinuation();
311
        }
304
        }
312
    }
305
    }
313
306
314
    ASSERT_NOT_REACHED();
307
    ASSERT_NOT_REACHED();
315
316
    return nullptr;
308
    return nullptr;
317
}
309
}
318
310
Lines 332-346 AccessibilityObject* AccessibilityRenderObject::previousSibling() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec5
332
    // Case 1: The node is a block and is an inline's continuation. In that case, the inline's
324
    // Case 1: The node is a block and is an inline's continuation. In that case, the inline's
333
    // last child is our previous sibling (or further back in the continuation chain)
325
    // last child is our previous sibling (or further back in the continuation chain)
334
    RenderInline* startOfConts;
326
    RenderInline* startOfConts;
335
    if (m_renderer->isRenderBlock() && (startOfConts = startOfContinuations(m_renderer)))
327
    if (is<RenderBox>(*m_renderer) && (startOfConts = startOfContinuations(*m_renderer)))
336
        previousSibling = childBeforeConsideringContinuations(startOfConts, m_renderer);
328
        previousSibling = childBeforeConsideringContinuations(startOfConts, m_renderer);
337
329
338
    // Case 2: Anonymous block parent of the end of a continuation - skip all the way to before
330
    // Case 2: Anonymous block parent of the end of a continuation - skip all the way to before
339
    // the parent of the start, since everything in between will be linked up via the continuation.
331
    // the parent of the start, since everything in between will be linked up via the continuation.
340
    else if (m_renderer->isAnonymousBlock() && firstChildIsInlineContinuation(m_renderer)) {
332
    else if (m_renderer->isAnonymousBlock() && firstChildIsInlineContinuation(m_renderer)) {
341
        RenderObject* firstParent = startOfContinuations(m_renderer->firstChildSlow())->parent();
333
        auto* firstParent = startOfContinuations(*m_renderer->firstChildSlow())->parent();
342
        while (firstChildIsInlineContinuation(firstParent))
334
        while (firstChildIsInlineContinuation(firstParent))
343
            firstParent = startOfContinuations(firstParent->firstChildSlow())->parent();
335
            firstParent = startOfContinuations(*firstParent->firstChild())->parent();
344
        previousSibling = firstParent->previousSibling();
336
        previousSibling = firstParent->previousSibling();
345
    }
337
    }
346
338
Lines 350-356 AccessibilityObject* AccessibilityRenderObject::previousSibling() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec6
350
342
351
    // Case 4: This node has no previous siblings, but its parent is an inline,
343
    // Case 4: This node has no previous siblings, but its parent is an inline,
352
    // and is another node's inline continutation. Follow the continuation chain.
344
    // and is another node's inline continutation. Follow the continuation chain.
353
    else if (m_renderer->parent()->isRenderInline() && (startOfConts = startOfContinuations(m_renderer->parent())))
345
    else if (is<RenderInline>(*m_renderer->parent()) && (startOfConts = startOfContinuations(*m_renderer->parent())))
354
        previousSibling = childBeforeConsideringContinuations(startOfConts, m_renderer->parent()->firstChild());
346
        previousSibling = childBeforeConsideringContinuations(startOfConts, m_renderer->parent()->firstChild());
355
347
356
    if (!previousSibling)
348
    if (!previousSibling)
Lines 375-389 AccessibilityObject* AccessibilityRenderObject::nextSibling() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec7
375
    // Case 1: node is a block and has an inline continuation. Next sibling is the inline continuation's
367
    // Case 1: node is a block and has an inline continuation. Next sibling is the inline continuation's
376
    // first child.
368
    // first child.
377
    RenderInline* inlineContinuation;
369
    RenderInline* inlineContinuation;
378
    if (m_renderer->isRenderBlock() && (inlineContinuation = toRenderBlock(m_renderer)->inlineElementContinuation()))
370
    if (is<RenderBlock>(*m_renderer) && (inlineContinuation = downcast<RenderBlock>(*m_renderer).inlineElementContinuation()))
379
        nextSibling = firstChildConsideringContinuation(inlineContinuation);
371
        nextSibling = firstChildConsideringContinuation(*inlineContinuation);
380
372
381
    // Case 2: Anonymous block parent of the start of a continuation - skip all the way to
373
    // Case 2: Anonymous block parent of the start of a continuation - skip all the way to
382
    // after the parent of the end, since everything in between will be linked up via the continuation.
374
    // after the parent of the end, since everything in between will be linked up via the continuation.
383
    else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(m_renderer)) {
375
    else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(m_renderer)) {
384
        RenderElement* lastParent = endOfContinuations(toRenderBlock(m_renderer)->lastChild())->parent();
376
        RenderElement* lastParent = endOfContinuations(*downcast<RenderBlock>(*m_renderer).lastChild())->parent();
385
        while (lastChildHasContinuation(lastParent))
377
        while (lastChildHasContinuation(lastParent))
386
            lastParent = endOfContinuations(lastParent->lastChild())->parent();
378
            lastParent = endOfContinuations(*lastParent->lastChild())->parent();
387
        nextSibling = lastParent->nextSibling();
379
        nextSibling = lastParent->nextSibling();
388
    }
380
    }
389
381
Lines 394-408 AccessibilityObject* AccessibilityRenderObject::nextSibling() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec8
394
    // Case 4: node is an inline with a continuation. Next sibling is the next sibling of the end 
386
    // Case 4: node is an inline with a continuation. Next sibling is the next sibling of the end 
395
    // of the continuation chain.
387
    // of the continuation chain.
396
    else if (isInlineWithContinuation(m_renderer))
388
    else if (isInlineWithContinuation(m_renderer))
397
        nextSibling = endOfContinuations(m_renderer)->nextSibling();
389
        nextSibling = endOfContinuations(*m_renderer)->nextSibling();
398
390
399
    // Case 5: node has no next sibling, and its parent is an inline with a continuation.
391
    // Case 5: node has no next sibling, and its parent is an inline with a continuation.
400
    else if (isInlineWithContinuation(m_renderer->parent())) {
392
    else if (isInlineWithContinuation(m_renderer->parent())) {
401
        auto continuation = toRenderInline(m_renderer->parent())->continuation();
393
        auto& continuation = *downcast<RenderInline>(*m_renderer->parent()).continuation();
402
        
394
        
403
        // Case 5a: continuation is a block - in this case the block itself is the next sibling.
395
        // Case 5a: continuation is a block - in this case the block itself is the next sibling.
404
        if (continuation->isRenderBlock())
396
        if (is<RenderBlock>(continuation))
405
            nextSibling = continuation;
397
            nextSibling = &continuation;
406
        // Case 5b: continuation is an inline - in this case the inline's first child is the next sibling
398
        // Case 5b: continuation is an inline - in this case the inline's first child is the next sibling
407
        else
399
        else
408
            nextSibling = firstChildConsideringContinuation(continuation);
400
            nextSibling = firstChildConsideringContinuation(continuation);
Lines 414-426 AccessibilityObject* AccessibilityRenderObject::nextSibling() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec9
414
    return axObjectCache()->getOrCreate(nextSibling);
406
    return axObjectCache()->getOrCreate(nextSibling);
415
}
407
}
416
408
417
static RenderBoxModelObject* nextContinuation(RenderObject* renderer)
409
static RenderBoxModelObject* nextContinuation(RenderObject& renderer)
418
{
410
{
419
    ASSERT(renderer);
411
    if (is<RenderInline>(renderer) && !renderer.isReplaced())
420
    if (renderer->isRenderInline() && !renderer->isReplaced())
412
        return downcast<RenderInline>(renderer).continuation();
421
        return toRenderInline(renderer)->continuation();
413
    if (is<RenderBlock>(renderer))
422
    if (renderer->isRenderBlock())
414
        return downcast<RenderBlock>(renderer).inlineElementContinuation();
423
        return toRenderBlock(renderer)->inlineElementContinuation();
424
    return nullptr;
415
    return nullptr;
425
}
416
}
426
    
417
    
Lines 435-446 RenderObject* AccessibilityRenderObject::renderParentObject() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec10
435
    // is the start of the continuation chain.
426
    // is the start of the continuation chain.
436
    RenderInline* startOfConts = nullptr;
427
    RenderInline* startOfConts = nullptr;
437
    RenderObject* firstChild = nullptr;
428
    RenderObject* firstChild = nullptr;
438
    if (m_renderer->isRenderBlock() && (startOfConts = startOfContinuations(m_renderer)))
429
    if (is<RenderBlock>(*m_renderer) && (startOfConts = startOfContinuations(*m_renderer)))
439
        parent = startOfConts;
430
        parent = startOfConts;
440
431
441
    // Case 2: node's parent is an inline which is some node's continuation; parent is 
432
    // Case 2: node's parent is an inline which is some node's continuation; parent is 
442
    // the earliest node in the continuation chain.
433
    // the earliest node in the continuation chain.
443
    else if (parent && parent->isRenderInline() && (startOfConts = startOfContinuations(parent)))
434
    else if (is<RenderInline>(parent) && (startOfConts = startOfContinuations(*parent)))
444
        parent = startOfConts;
435
        parent = startOfConts;
445
    
436
    
446
    // Case 3: The first sibling is the beginning of a continuation chain. Find the origin of that continuation.
437
    // Case 3: The first sibling is the beginning of a continuation chain. Find the origin of that continuation.
Lines 448-454 RenderObject* AccessibilityRenderObject::renderParentObject() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec11
448
        // Get the node's renderer and follow that continuation chain until the first child is found
439
        // Get the node's renderer and follow that continuation chain until the first child is found
449
        RenderObject* nodeRenderFirstChild = firstChild->node()->renderer();
440
        RenderObject* nodeRenderFirstChild = firstChild->node()->renderer();
450
        while (nodeRenderFirstChild != firstChild) {
441
        while (nodeRenderFirstChild != firstChild) {
451
            for (RenderObject* contsTest = nodeRenderFirstChild; contsTest; contsTest = nextContinuation(contsTest)) {
442
            for (RenderObject* contsTest = nodeRenderFirstChild; contsTest; contsTest = nextContinuation(*contsTest)) {
452
                if (contsTest == firstChild) {
443
                if (contsTest == firstChild) {
453
                    parent = nodeRenderFirstChild->parent();
444
                    parent = nodeRenderFirstChild->parent();
454
                    break;
445
                    break;
Lines 566-590 Element* AccessibilityRenderObject::anchorElement() const a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec12
566
    if (!cache)
557
    if (!cache)
567
        return nullptr;
558
        return nullptr;
568
    
559
    
569
    RenderObject* currRenderer;
560
    RenderObject* currentRenderer;
570
    
561
    
571
    // Search up the render tree for a RenderObject with a DOM node.  Defer to an earlier continuation, though.
562
    // Search up the render tree for a RenderObject with a DOM node.  Defer to an earlier continuation, though.
572
    for (currRenderer = m_renderer; currRenderer && !currRenderer->node(); currRenderer = currRenderer->parent()) {
563
    for (currentRenderer = m_renderer; currentRenderer && !currentRenderer->node(); currentRenderer = currentRenderer->parent()) {
573
        if (currRenderer->isAnonymousBlock()) {
564
        if (currentRenderer->isAnonymousBlock()) {
574
            RenderObject* continuation = toRenderBlock(currRenderer)->continuation();
565
            if (RenderObject* continuation = downcast<RenderBlock>(*currentRenderer).continuation())
575
            if (continuation)
576
                return cache->getOrCreate(continuation)->anchorElement();
566
                return cache->getOrCreate(continuation)->anchorElement();
577
        }
567
        }
578
    }
568
    }
579
    
569
    
580
    // bail if none found
570
    // bail if none found
581
    if (!currRenderer)
571
    if (!currentRenderer)
582
        return 0;
572
        return nullptr;
583
    
573
    
584
    // search up the DOM tree for an anchor element
574
    // search up the DOM tree for an anchor element
585
    // NOTE: this assumes that any non-image with an anchor is an HTMLAnchorElement
575
    // NOTE: this assumes that any non-image with an anchor is an HTMLAnchorElement
586
    Node* node = currRenderer->node();
576
    for (Node* node = currentRenderer->node(); node; node = node->parentNode()) {
587
    for ( ; node; node = node->parentNode()) {
588
        if (is<HTMLAnchorElement>(*node) || (node->renderer() && cache->getOrCreate(node->renderer())->isAnchor()))
577
        if (is<HTMLAnchorElement>(*node) || (node->renderer() && cache->getOrCreate(node->renderer())->isAnchor()))
589
            return downcast<Element>(node);
578
            return downcast<Element>(node);
590
    }
579
    }
Lines 1677-1690 void AccessibilityRenderObject::setValue(const String& string) a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp_sec13
1677
        return;
1666
        return;
1678
    Element& element = downcast<Element>(*m_renderer->node());
1667
    Element& element = downcast<Element>(*m_renderer->node());
1679
1668
1680
    if (!m_renderer->isBoxModelObject())
1669
    if (!is<RenderBoxModelObject>(*m_renderer))
1681
        return;
1670
        return;
1682
    RenderBoxModelObject* renderer = toRenderBoxModelObject(m_renderer);
1671
    RenderBoxModelObject& renderer = downcast<RenderBoxModelObject>(*m_renderer);
1683
1672
1684
    // FIXME: Do we want to do anything here for ARIA textboxes?
1673
    // FIXME: Do we want to do anything here for ARIA textboxes?
1685
    if (renderer->isTextField() && is<HTMLInputElement>(element))
1674
    if (renderer.isTextField() && is<HTMLInputElement>(element))
1686
        downcast<HTMLInputElement>(element).setValue(string);
1675
        downcast<HTMLInputElement>(element).setValue(string);
1687
    else if (renderer->isTextArea() && is<HTMLTextAreaElement>(element))
1676
    else if (renderer.isTextArea() && is<HTMLTextAreaElement>(element))
1688
        downcast<HTMLTextAreaElement>(element).setValue(string);
1677
        downcast<HTMLTextAreaElement>(element).setValue(string);
1689
}
1678
}
1690
1679
- a/Source/WebCore/bindings/objc/DOMUIKitExtensions.mm -12 / +12 lines
Lines 207-223 - (NSArray *)borderRadii a/Source/WebCore/bindings/objc/DOMUIKitExtensions.mm_sec1
207
207
208
- (BOOL)containsOnlyInlineObjects
208
- (BOOL)containsOnlyInlineObjects
209
{
209
{
210
    RenderObject * renderer = core(self)->renderer();
210
    RenderObject* renderer = core(self)->renderer();
211
    return  (renderer &&
211
    return renderer
212
             renderer->childrenInline() &&
212
        && renderer->childrenInline()
213
             (renderer->isRenderBlock() && toRenderBlock(renderer)->inlineElementContinuation() == nil) &&
213
        && (is<RenderBlock>(*renderer) && !downcast<RenderBlock>(*renderer).inlineElementContinuation())
214
             !renderer->isTable());
214
        && !renderer->isTable();
215
}
215
}
216
216
217
- (BOOL)isSelectableBlock
217
- (BOOL)isSelectableBlock
218
{
218
{
219
    RenderObject * renderer = core(self)->renderer();
219
    RenderObject* renderer = core(self)->renderer();
220
    return (renderer && (renderer->isRenderBlockFlow() || (renderer->isRenderBlock() && toRenderBlock(renderer)->inlineElementContinuation() != nil)));
220
    return renderer && (is<RenderBlockFlow>(*renderer) || (is<RenderBlock>(*renderer) && downcast<RenderBlock>(*renderer).inlineElementContinuation() != nil));
221
}
221
}
222
222
223
- (DOMRange *)rangeOfContainingParagraph
223
- (DOMRange *)rangeOfContainingParagraph
Lines 344-355 - (int)structuralComplexityContribution a/Source/WebCore/bindings/objc/DOMUIKitExtensions.mm_sec2
344
            result = INT_MAX;
344
            result = INT_MAX;
345
        } else if (renderer->isEmpty()) {
345
        } else if (renderer->isEmpty()) {
346
            result = 0;
346
            result = 0;
347
        } else if (renderer->isRenderBlockFlow() || (renderer->isRenderBlock() && toRenderBlock(renderer)->inlineElementContinuation() != 0)) {
347
        } else if (is<RenderBlockFlow>(*renderer) || (is<RenderBlock>(*renderer) && downcast<RenderBlock>(*renderer).inlineElementContinuation())) {
348
            BOOL noCost = NO;
348
            BOOL noCost = NO;
349
            if (renderer->isBox()) {
349
            if (is<RenderBox>(*renderer)) {
350
                RenderBox &asBox = renderer->enclosingBox();
350
                RenderBox& asBox = renderer->enclosingBox();
351
                RenderObject *parent = asBox.parent();
351
                RenderObject* parent = asBox.parent();
352
                RenderBox *parentRenderBox = (parent && parent->isBox()) ? toRenderBox(parent) : 0;
352
                RenderBox* parentRenderBox = is<RenderBox>(parent) ? downcast<RenderBox>(parent) : nullptr;
353
                if (parentRenderBox && asBox.width() == parentRenderBox->width()) {
353
                if (parentRenderBox && asBox.width() == parentRenderBox->width()) {
354
                    noCost = YES;
354
                    noCost = YES;
355
                }
355
                }
- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp -3 / +3 lines
Lines 1007-1013 static PassRef<CSSValue> valueForGridTrackList(GridTrackSizingDirection directio a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp_sec1
1007
{
1007
{
1008
    const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style->gridColumns() : style->gridRows();
1008
    const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style->gridColumns() : style->gridRows();
1009
    const OrderedNamedGridLinesMap& orderedNamedGridLines = direction == ForColumns ? style->orderedNamedGridColumnLines() : style->orderedNamedGridRowLines();
1009
    const OrderedNamedGridLinesMap& orderedNamedGridLines = direction == ForColumns ? style->orderedNamedGridColumnLines() : style->orderedNamedGridRowLines();
1010
    bool isRenderGrid = renderer && renderer->isRenderGrid();
1010
    bool isRenderGrid = is<RenderGrid>(renderer);
1011
1011
1012
    // Handle the 'none' case.
1012
    // Handle the 'none' case.
1013
    bool trackListIsEmpty = trackSizes.isEmpty();
1013
    bool trackListIsEmpty = trackSizes.isEmpty();
Lines 1015-1021 static PassRef<CSSValue> valueForGridTrackList(GridTrackSizingDirection directio a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp_sec2
1015
        // For grids we should consider every listed track, whether implicitly or explicitly created. If we don't have
1015
        // For grids we should consider every listed track, whether implicitly or explicitly created. If we don't have
1016
        // any explicit track and there are no children then there are no implicit tracks. We cannot simply check the
1016
        // any explicit track and there are no children then there are no implicit tracks. We cannot simply check the
1017
        // number of rows/columns in our internal grid representation because it's always at least 1x1 (see r143331).
1017
        // number of rows/columns in our internal grid representation because it's always at least 1x1 (see r143331).
1018
        trackListIsEmpty = !toRenderBlock(renderer)->firstChild();
1018
        trackListIsEmpty = !downcast<RenderBlock>(*renderer).firstChild();
1019
    }
1019
    }
1020
1020
1021
    if (trackListIsEmpty) {
1021
    if (trackListIsEmpty) {
Lines 1025-1031 static PassRef<CSSValue> valueForGridTrackList(GridTrackSizingDirection directio a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp_sec3
1025
1025
1026
    auto list = CSSValueList::createSpaceSeparated();
1026
    auto list = CSSValueList::createSpaceSeparated();
1027
    if (isRenderGrid) {
1027
    if (isRenderGrid) {
1028
        const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? toRenderGrid(renderer)->columnPositions() : toRenderGrid(renderer)->rowPositions();
1028
        const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? downcast<RenderGrid>(*renderer).columnPositions() : downcast<RenderGrid>(*renderer).rowPositions();
1029
        // There are at least #tracks + 1 grid lines (trackPositions). Apart from that, the grid container can generate implicit grid tracks,
1029
        // There are at least #tracks + 1 grid lines (trackPositions). Apart from that, the grid container can generate implicit grid tracks,
1030
        // so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid.
1030
        // so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid.
1031
        ASSERT(trackPositions.size() - 1 >= trackSizes.size());
1031
        ASSERT(trackPositions.size() - 1 >= trackSizes.size());
- a/Source/WebCore/editing/CompositeEditCommand.cpp -8 / +8 lines
Lines 55-64 a/Source/WebCore/editing/CompositeEditCommand.cpp_sec1
55
#include "RemoveCSSPropertyCommand.h"
55
#include "RemoveCSSPropertyCommand.h"
56
#include "RemoveNodeCommand.h"
56
#include "RemoveNodeCommand.h"
57
#include "RemoveNodePreservingChildrenCommand.h"
57
#include "RemoveNodePreservingChildrenCommand.h"
58
#include "RenderBlockFlow.h"
59
#include "RenderText.h"
58
#include "ReplaceNodeWithSpanCommand.h"
60
#include "ReplaceNodeWithSpanCommand.h"
59
#include "ReplaceSelectionCommand.h"
61
#include "ReplaceSelectionCommand.h"
60
#include "RenderBlock.h"
61
#include "RenderText.h"
62
#include "ScopedEventQueue.h"
62
#include "ScopedEventQueue.h"
63
#include "SetNodeAttributeCommand.h"
63
#include "SetNodeAttributeCommand.h"
64
#include "SplitElementCommand.h"
64
#include "SplitElementCommand.h"
Lines 929-949 PassRefPtr<Node> CompositeEditCommand::insertBlockPlaceholder(const Position& po a/Source/WebCore/editing/CompositeEditCommand.cpp_sec2
929
PassRefPtr<Node> CompositeEditCommand::addBlockPlaceholderIfNeeded(Element* container)
929
PassRefPtr<Node> CompositeEditCommand::addBlockPlaceholderIfNeeded(Element* container)
930
{
930
{
931
    if (!container)
931
    if (!container)
932
        return 0;
932
        return nullptr;
933
933
934
    document().updateLayoutIgnorePendingStylesheets();
934
    document().updateLayoutIgnorePendingStylesheets();
935
935
936
    RenderObject* renderer = container->renderer();
936
    RenderObject* renderer = container->renderer();
937
    if (!renderer || !renderer->isRenderBlockFlow())
937
    if (!is<RenderBlockFlow>(renderer))
938
        return 0;
938
        return nullptr;
939
    
939
    
940
    // append the placeholder to make sure it follows
940
    // append the placeholder to make sure it follows
941
    // any unrendered blocks
941
    // any unrendered blocks
942
    RenderBlock* block = toRenderBlock(renderer);
942
    RenderBlockFlow& blockFlow = downcast<RenderBlockFlow>(*renderer);
943
    if (block->height() == 0 || (block->isListItem() && block->isEmpty()))
943
    if (!blockFlow.height() || (blockFlow.isListItem() && blockFlow.isEmpty()))
944
        return appendBlockPlaceholder(container);
944
        return appendBlockPlaceholder(container);
945
945
946
    return 0;
946
    return nullptr;
947
}
947
}
948
948
949
// Assumes that the position is at a placeholder and does the removal without much checking.
949
// Assumes that the position is at a placeholder and does the removal without much checking.
- a/Source/WebCore/editing/TextIterator.cpp -1 / +1 lines
Lines 963-969 bool TextIterator::shouldRepresentNodeOffsetZero() a/Source/WebCore/editing/TextIterator.cpp_sec1
963
    // Additionally, if the range we are iterating over contains huge sections of unrendered content, 
963
    // Additionally, if the range we are iterating over contains huge sections of unrendered content, 
964
    // we would create VisiblePositions on every call to this function without this check.
964
    // we would create VisiblePositions on every call to this function without this check.
965
    if (!m_node->renderer() || m_node->renderer()->style().visibility() != VISIBLE
965
    if (!m_node->renderer() || m_node->renderer()->style().visibility() != VISIBLE
966
        || (m_node->renderer()->isRenderBlockFlow() && !toRenderBlock(m_node->renderer())->height() && !m_node->hasTagName(bodyTag)))
966
        || (is<RenderBlockFlow>(*m_node->renderer()) && !downcast<RenderBlockFlow>(*m_node->renderer()).height() && !is<HTMLBodyElement>(*m_node)))
967
        return false;
967
        return false;
968
968
969
    // The startPos.isNotNull() check is needed because the start could be before the body,
969
    // The startPos.isNotNull() check is needed because the start could be before the body,
- a/Source/WebCore/page/ios/FrameIOS.mm -3 / +3 lines
Lines 552-562 int Frame::preferredHeight() const a/Source/WebCore/page/ios/FrameIOS.mm_sec1
552
        return 0;
552
        return 0;
553
553
554
    RenderObject* renderer = body->renderer();
554
    RenderObject* renderer = body->renderer();
555
    if (!renderer || !renderer->isRenderBlock())
555
    if (!is<RenderBlock>(renderer))
556
        return 0;
556
        return 0;
557
557
558
    RenderBlock* block = toRenderBlock(renderer);
558
    RenderBlock& block = downcast<RenderBlock>(*renderer);
559
    return block->height() + block->marginTop() + block->marginBottom();
559
    return block.height() + block.marginTop() + block.marginBottom();
560
}
560
}
561
561
562
int Frame::innerLineHeight(DOMNode* domNode) const
562
int Frame::innerLineHeight(DOMNode* domNode) const
- a/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h -4 / +4 lines
Lines 44-50 static inline RenderBlock* containingBlockForFixedPosition(RenderElement* parent a/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h_sec1
44
    while (object && !object->canContainFixedPositionObjects())
44
    while (object && !object->canContainFixedPositionObjects())
45
        object = object->parent();
45
        object = object->parent();
46
    ASSERT(!object || !object->isAnonymousBlock());
46
    ASSERT(!object || !object->isAnonymousBlock());
47
    return toRenderBlock(object);
47
    return downcast<RenderBlock>(object);
48
}
48
}
49
49
50
static inline RenderBlock* containingBlockForAbsolutePosition(RenderElement* parent)
50
static inline RenderBlock* containingBlockForAbsolutePosition(RenderElement* parent)
Lines 57-69 static inline RenderBlock* containingBlockForAbsolutePosition(RenderElement* par a/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h_sec2
57
    // not the inline itself, to avoid having a positioned objects list in all RenderInlines
57
    // not the inline itself, to avoid having a positioned objects list in all RenderInlines
58
    // and use RenderBlock* as RenderElement::containingBlock's return type.
58
    // and use RenderBlock* as RenderElement::containingBlock's return type.
59
    // Use RenderBlock::container() to obtain the inline.
59
    // Use RenderBlock::container() to obtain the inline.
60
    if (object && !object->isRenderBlock())
60
    if (object && !is<RenderBlock>(*object))
61
        object = object->containingBlock();
61
        object = object->containingBlock();
62
62
63
    while (object && object->isAnonymousBlock())
63
    while (object && object->isAnonymousBlock())
64
        object = object->containingBlock();
64
        object = object->containingBlock();
65
65
66
    return toRenderBlock(object);
66
    return downcast<RenderBlock>(object);
67
}
67
}
68
68
69
static inline RenderBlock* containingBlockForObjectInFlow(RenderElement* parent)
69
static inline RenderBlock* containingBlockForObjectInFlow(RenderElement* parent)
Lines 71-77 static inline RenderBlock* containingBlockForObjectInFlow(RenderElement* parent) a/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h_sec3
71
    RenderElement* object = parent;
71
    RenderElement* object = parent;
72
    while (object && isNonRenderBlockInline(*object))
72
    while (object && isNonRenderBlockInline(*object))
73
        object = object->parent();
73
        object = object->parent();
74
    return toRenderBlock(object);
74
    return downcast<RenderBlock>(object);
75
}
75
}
76
76
77
class LogicalSelectionOffsetCaches {
77
class LogicalSelectionOffsetCaches {
- a/Source/WebCore/rendering/RenderBlock.cpp -152 / +79 lines
Lines 272-288 void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle& newSt a/Source/WebCore/rendering/RenderBlock.cpp_sec1
272
        else if (oldStyle->position() == StaticPosition) {
272
        else if (oldStyle->position() == StaticPosition) {
273
            // Remove our absolutely positioned descendants from their current containing block.
273
            // Remove our absolutely positioned descendants from their current containing block.
274
            // They will be inserted into our positioned objects list during layout.
274
            // They will be inserted into our positioned objects list during layout.
275
            auto cb = parent();
275
            auto containingBlock = parent();
276
            while (cb && (cb->style().position() == StaticPosition || (cb->isInline() && !cb->isReplaced())) && !cb->isRenderView()) {
276
            while (containingBlock && (containingBlock->style().position() == StaticPosition || (containingBlock->isInline() && !containingBlock->isReplaced())) && !containingBlock->isRenderView()) {
277
                if (cb->style().position() == RelativePosition && cb->isInline() && !cb->isReplaced()) {
277
                if (containingBlock->style().position() == RelativePosition && containingBlock->isInline() && !containingBlock->isReplaced()) {
278
                    cb = cb->containingBlock();
278
                    containingBlock = containingBlock->containingBlock();
279
                    break;
279
                    break;
280
                }
280
                }
281
                cb = cb->parent();
281
                containingBlock = containingBlock->parent();
282
            }
282
            }
283
            
283
            
284
            if (cb->isRenderBlock())
284
            if (is<RenderBlock>(*containingBlock))
285
                toRenderBlock(cb)->removePositionedObjects(this, NewContainingBlock);
285
                downcast<RenderBlock>(*containingBlock).removePositionedObjects(this, NewContainingBlock);
286
        }
286
        }
287
    }
287
    }
288
288
Lines 332-350 RenderBlock* RenderBlock::continuationBefore(RenderObject* beforeChild) a/Source/WebCore/rendering/RenderBlock.cpp_sec2
332
    if (beforeChild && beforeChild->parent() == this)
332
    if (beforeChild && beforeChild->parent() == this)
333
        return this;
333
        return this;
334
334
335
    RenderBlock* curr = toRenderBlock(continuation());
336
    RenderBlock* nextToLast = this;
335
    RenderBlock* nextToLast = this;
337
    RenderBlock* last = this;
336
    RenderBlock* last = this;
338
    while (curr) {
337
    for (auto* current = downcast<RenderBlock>(continuation()); current; current = downcast<RenderBlock>(current->continuation())) {
339
        if (beforeChild && beforeChild->parent() == curr) {
338
        if (beforeChild && beforeChild->parent() == current) {
340
            if (curr->firstChild() == beforeChild)
339
            if (current->firstChild() == beforeChild)
341
                return last;
340
                return last;
342
            return curr;
341
            return current;
343
        }
342
        }
344
343
345
        nextToLast = last;
344
        nextToLast = last;
346
        last = curr;
345
        last = current;
347
        curr = toRenderBlock(curr->continuation());
348
    }
346
    }
349
347
350
    if (!beforeChild && !last->firstChild())
348
    if (!beforeChild && !last->firstChild())
Lines 413-489 RenderPtr<RenderBlock> RenderBlock::clone() const a/Source/WebCore/rendering/RenderBlock.cpp_sec3
413
    return cloneBlock;
411
    return cloneBlock;
414
}
412
}
415
413
416
void RenderBlock::splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock,
417
                              RenderBlock* middleBlock,
418
                              RenderObject* beforeChild, RenderBoxModelObject* oldCont)
419
{
420
    // Create a clone of this inline.
421
    RenderPtr<RenderBlock> cloneBlock = clone();
422
    if (!isAnonymousBlock())
423
        cloneBlock->setContinuation(oldCont);
424
425
    if (!beforeChild && isAfterContent(lastChild()))
426
        beforeChild = lastChild();
427
428
    // If we are moving inline children from |this| to cloneBlock, then we need
429
    // to clear our line box tree.
430
    if (beforeChild && childrenInline())
431
        deleteLines();
432
433
    // Now take all of the children from beforeChild to the end and remove
434
    // them from |this| and place them in the clone.
435
    moveChildrenTo(cloneBlock.get(), beforeChild, 0, true);
436
    
437
    // Hook |clone| up as the continuation of the middle block.
438
    if (!cloneBlock->isAnonymousBlock())
439
        middleBlock->setContinuation(cloneBlock.get());
440
441
    // We have been reparented and are now under the fromBlock.  We need
442
    // to walk up our block parent chain until we hit the containing anonymous columns block.
443
    // Once we hit the anonymous columns block we're done.
444
    RenderBoxModelObject* curr = toRenderBoxModelObject(parent());
445
    RenderBoxModelObject* currChild = this;
446
    RenderObject* currChildNextSibling = currChild->nextSibling();
447
448
    while (curr && curr->isDescendantOf(fromBlock) && curr != fromBlock) {
449
        RenderBlock* blockCurr = toRenderBlock(curr);
450
        
451
        // Create a new clone.
452
        RenderPtr<RenderBlock> cloneChild = WTF::move(cloneBlock);
453
        cloneBlock = blockCurr->clone();
454
455
        // Insert our child clone as the first child.
456
        cloneBlock->addChildIgnoringContinuation(cloneChild.leakPtr(), 0);
457
458
        // Hook the clone up as a continuation of |curr|.  Note we do encounter
459
        // anonymous blocks possibly as we walk up the block chain.  When we split an
460
        // anonymous block, there's no need to do any continuation hookup, since we haven't
461
        // actually split a real element.
462
        if (!blockCurr->isAnonymousBlock()) {
463
            oldCont = blockCurr->continuation();
464
            blockCurr->setContinuation(cloneBlock.get());
465
            cloneBlock->setContinuation(oldCont);
466
        }
467
468
        // Now we need to take all of the children starting from the first child
469
        // *after* currChild and append them all to the clone.
470
        blockCurr->moveChildrenTo(cloneBlock.get(), currChildNextSibling, 0, true);
471
472
        // Keep walking up the chain.
473
        currChild = curr;
474
        currChildNextSibling = currChild->nextSibling();
475
        curr = toRenderBoxModelObject(curr->parent());
476
    }
477
478
    // Now we are at the columns block level. We need to put the clone into the toBlock.
479
    toBlock->insertChildInternal(cloneBlock.leakPtr(), nullptr, NotifyChildren);
480
481
    // Now take all the children after currChild and remove them from the fromBlock
482
    // and put them in the toBlock.
483
    if (currChildNextSibling && currChildNextSibling->parent() == fromBlock)
484
        fromBlock->moveChildrenTo(toBlock, currChildNextSibling, 0, true);
485
}
486
487
void RenderBlock::addChild(RenderObject* newChild, RenderObject* beforeChild)
414
void RenderBlock::addChild(RenderObject* newChild, RenderObject* beforeChild)
488
{
415
{
489
    if (continuation() && !isAnonymousBlock())
416
    if (continuation() && !isAnonymousBlock())
Lines 559-565 void RenderBlock::addChildIgnoringContinuation(RenderObject* newChild, RenderObj a/Source/WebCore/rendering/RenderBlock.cpp_sec4
559
        RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : lastChild();
486
        RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : lastChild();
560
487
561
        if (afterChild && afterChild->isAnonymousBlock()) {
488
        if (afterChild && afterChild->isAnonymousBlock()) {
562
            toRenderBlock(afterChild)->addChild(newChild);
489
            downcast<RenderBlock>(*afterChild).addChild(newChild);
563
            return;
490
            return;
564
        }
491
        }
565
492
Lines 576-583 void RenderBlock::addChildIgnoringContinuation(RenderObject* newChild, RenderObj a/Source/WebCore/rendering/RenderBlock.cpp_sec5
576
503
577
    RenderBox::addChild(newChild, beforeChild);
504
    RenderBox::addChild(newChild, beforeChild);
578
 
505
 
579
    if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isRenderBlock())
506
    if (madeBoxesNonInline && is<RenderBlock>(parent()) && isAnonymousBlock())
580
        toRenderBlock(parent())->removeLeftoverAnonymousBlock(this);
507
        downcast<RenderBlock>(*parent()).removeLeftoverAnonymousBlock(this);
581
    // this object may be dead here
508
    // this object may be dead here
582
}
509
}
583
510
Lines 722-732 void RenderBlock::removeLeftoverAnonymousBlock(RenderBlock* child) a/Source/WebCore/rendering/RenderBlock.cpp_sec6
722
    child->destroy();
649
    child->destroy();
723
}
650
}
724
651
725
static bool canMergeAnonymousBlock(RenderBlock* anonymousBlock)
652
static bool canMergeAnonymousBlock(RenderBlock& anonymousBlock)
726
{
653
{
727
    if (anonymousBlock->beingDestroyed() || anonymousBlock->continuation())
654
    if (anonymousBlock.beingDestroyed() || anonymousBlock.continuation())
728
        return false;
655
        return false;
729
    if (anonymousBlock->isRubyRun() || anonymousBlock->isRubyBase())
656
    if (anonymousBlock.isRubyRun() || anonymousBlock.isRubyBase())
730
        return false;
657
        return false;
731
    return true;
658
    return true;
732
}
659
}
Lines 739-762 static bool canMergeContiguousAnonymousBlocks(RenderObject& oldChild, RenderObje a/Source/WebCore/rendering/RenderBlock.cpp_sec7
739
    if (previous) {
666
    if (previous) {
740
        if (!previous->isAnonymousBlock())
667
        if (!previous->isAnonymousBlock())
741
            return false;
668
            return false;
742
        RenderBlock* previousAnonymousBlock = toRenderBlock(previous);
669
        RenderBlock& previousAnonymousBlock = downcast<RenderBlock>(*previous);
743
        if (!canMergeAnonymousBlock(previousAnonymousBlock))
670
        if (!canMergeAnonymousBlock(previousAnonymousBlock))
744
            return false;
671
            return false;
745
    }
672
    }
746
    if (next) {
673
    if (next) {
747
        if (!next->isAnonymousBlock())
674
        if (!next->isAnonymousBlock())
748
            return false;
675
            return false;
749
        RenderBlock* nextAnonymousBlock = toRenderBlock(next);
676
        RenderBlock& nextAnonymousBlock = downcast<RenderBlock>(*next);
750
        if (!canMergeAnonymousBlock(nextAnonymousBlock))
677
        if (!canMergeAnonymousBlock(nextAnonymousBlock))
751
            return false;
678
            return false;
752
    }
679
    }
753
    return true;
680
    return true;
754
}
681
}
755
682
756
void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderBlock* child)
683
void RenderBlock::collapseAnonymousBoxChild(RenderBlock& parent, RenderBlock* child)
757
{
684
{
758
    parent->setNeedsLayoutAndPrefWidthsRecalc();
685
    parent.setNeedsLayoutAndPrefWidthsRecalc();
759
    parent->setChildrenInline(child->childrenInline());
686
    parent.setChildrenInline(child->childrenInline());
760
    RenderObject* nextSibling = child->nextSibling();
687
    RenderObject* nextSibling = child->nextSibling();
761
688
762
    RenderFlowThread* childFlowThread = child->flowThreadContainingBlock();
689
    RenderFlowThread* childFlowThread = child->flowThreadContainingBlock();
Lines 764-771 void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderBlock* ch a/Source/WebCore/rendering/RenderBlock.cpp_sec8
764
    if (childFlowThread && childFlowThread->isRenderNamedFlowThread())
691
    if (childFlowThread && childFlowThread->isRenderNamedFlowThread())
765
        toRenderNamedFlowThread(childFlowThread)->removeFlowChildInfo(child);
692
        toRenderNamedFlowThread(childFlowThread)->removeFlowChildInfo(child);
766
693
767
    parent->removeChildInternal(*child, child->hasLayer() ? NotifyChildren : DontNotifyChildren);
694
    parent.removeChildInternal(*child, child->hasLayer() ? NotifyChildren : DontNotifyChildren);
768
    child->moveAllChildrenTo(parent, nextSibling, child->hasLayer());
695
    child->moveAllChildrenTo(&parent, nextSibling, child->hasLayer());
769
    // Delete the now-empty block's lines and nuke it.
696
    // Delete the now-empty block's lines and nuke it.
770
    child->deleteLines();
697
    child->deleteLines();
771
    child->destroy();
698
    child->destroy();
Lines 786-829 RenderObject* RenderBlock::removeChild(RenderObject& oldChild) a/Source/WebCore/rendering/RenderBlock.cpp_sec9
786
    bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, prev, next);
713
    bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, prev, next);
787
    if (canMergeAnonymousBlocks && prev && next) {
714
    if (canMergeAnonymousBlocks && prev && next) {
788
        prev->setNeedsLayoutAndPrefWidthsRecalc();
715
        prev->setNeedsLayoutAndPrefWidthsRecalc();
789
        RenderBlock* nextBlock = toRenderBlock(next);
716
        RenderBlock& nextBlock = downcast<RenderBlock>(*next);
790
        RenderBlock* prevBlock = toRenderBlock(prev);
717
        RenderBlock& prevBlock = downcast<RenderBlock>(*prev);
791
       
718
       
792
        if (prev->childrenInline() != next->childrenInline()) {
719
        if (prev->childrenInline() != next->childrenInline()) {
793
            RenderBlock* inlineChildrenBlock = prev->childrenInline() ? prevBlock : nextBlock;
720
            RenderBlock& inlineChildrenBlock = prev->childrenInline() ? prevBlock : nextBlock;
794
            RenderBlock* blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock;
721
            RenderBlock& blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock;
795
            
722
            
796
            // Place the inline children block inside of the block children block instead of deleting it.
723
            // Place the inline children block inside of the block children block instead of deleting it.
797
            // In order to reuse it, we have to reset it to just be a generic anonymous block.  Make sure
724
            // In order to reuse it, we have to reset it to just be a generic anonymous block.  Make sure
798
            // to clear out inherited column properties by just making a new style, and to also clear the
725
            // to clear out inherited column properties by just making a new style, and to also clear the
799
            // column span flag if it is set.
726
            // column span flag if it is set.
800
            ASSERT(!inlineChildrenBlock->continuation());
727
            ASSERT(!inlineChildrenBlock.continuation());
801
            // Cache this value as it might get changed in setStyle() call.
728
            // Cache this value as it might get changed in setStyle() call.
802
            bool inlineChildrenBlockHasLayer = inlineChildrenBlock->hasLayer();
729
            bool inlineChildrenBlockHasLayer = inlineChildrenBlock.hasLayer();
803
            inlineChildrenBlock->setStyle(RenderStyle::createAnonymousStyleWithDisplay(&style(), BLOCK));
730
            inlineChildrenBlock.setStyle(RenderStyle::createAnonymousStyleWithDisplay(&style(), BLOCK));
804
            removeChildInternal(*inlineChildrenBlock, inlineChildrenBlockHasLayer ? NotifyChildren : DontNotifyChildren);
731
            removeChildInternal(inlineChildrenBlock, inlineChildrenBlockHasLayer ? NotifyChildren : DontNotifyChildren);
805
            
732
            
806
            // Now just put the inlineChildrenBlock inside the blockChildrenBlock.
733
            // Now just put the inlineChildrenBlock inside the blockChildrenBlock.
807
            RenderObject* beforeChild = prev == inlineChildrenBlock ? blockChildrenBlock->firstChild() : nullptr;
734
            RenderObject* beforeChild = prev == &inlineChildrenBlock ? blockChildrenBlock.firstChild() : nullptr;
808
            blockChildrenBlock->insertChildInternal(inlineChildrenBlock, beforeChild,
735
            blockChildrenBlock.insertChildInternal(&inlineChildrenBlock, beforeChild,
809
                (inlineChildrenBlockHasLayer || blockChildrenBlock->hasLayer()) ? NotifyChildren : DontNotifyChildren);
736
                (inlineChildrenBlockHasLayer || blockChildrenBlock.hasLayer()) ? NotifyChildren : DontNotifyChildren);
810
            next->setNeedsLayoutAndPrefWidthsRecalc();
737
            next->setNeedsLayoutAndPrefWidthsRecalc();
811
            
738
            
812
            // inlineChildrenBlock got reparented to blockChildrenBlock, so it is no longer a child
739
            // inlineChildrenBlock got reparented to blockChildrenBlock, so it is no longer a child
813
            // of "this". we null out prev or next so that is not used later in the function.
740
            // of "this". we null out prev or next so that is not used later in the function.
814
            if (inlineChildrenBlock == prevBlock)
741
            if (&inlineChildrenBlock == &prevBlock)
815
                prev = 0;
742
                prev = nullptr;
816
            else
743
            else
817
                next = 0;
744
                next = nullptr;
818
        } else {
745
        } else {
819
            // Take all the children out of the |next| block and put them in
746
            // Take all the children out of the |next| block and put them in
820
            // the |prev| block.
747
            // the |prev| block.
821
            nextBlock->moveAllChildrenIncludingFloatsTo(prevBlock, nextBlock->hasLayer() || prevBlock->hasLayer());
748
            nextBlock.moveAllChildrenIncludingFloatsTo(&prevBlock, nextBlock.hasLayer() || prevBlock.hasLayer());
822
            
749
            
823
            // Delete the now-empty block's lines and nuke it.
750
            // Delete the now-empty block's lines and nuke it.
824
            nextBlock->deleteLines();
751
            nextBlock.deleteLines();
825
            nextBlock->destroy();
752
            nextBlock.destroy();
826
            next = 0;
753
            next = nullptr;
827
        }
754
        }
828
    }
755
    }
829
756
Lines 836-852 RenderObject* RenderBlock::removeChild(RenderObject& oldChild) a/Source/WebCore/rendering/RenderBlock.cpp_sec10
836
        // The removal has knocked us down to containing only a single anonymous
763
        // The removal has knocked us down to containing only a single anonymous
837
        // box.  We can go ahead and pull the content right back up into our
764
        // box.  We can go ahead and pull the content right back up into our
838
        // box.
765
        // box.
839
        collapseAnonymousBoxChild(this, toRenderBlock(child));
766
        collapseAnonymousBoxChild(*this, downcast<RenderBlock>(child));
840
        nextSibling = nullptr;
767
        nextSibling = nullptr;
841
    } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousBlock())) && canCollapseAnonymousBlockChild()) {
768
    } else if (((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousBlock())) && canCollapseAnonymousBlockChild()) {
842
        // It's possible that the removal has knocked us down to a single anonymous
769
        // It's possible that the removal has knocked us down to a single anonymous
843
        // block with pseudo-style element siblings (e.g. first-letter). If these
770
        // block with pseudo-style element siblings (e.g. first-letter). If these
844
        // are floating, then we need to pull the content up also.
771
        // are floating, then we need to pull the content up also.
845
        RenderBlock* anonBlock = toRenderBlock((prev && prev->isAnonymousBlock()) ? prev : next);
772
        RenderBlock* anonBlock = downcast<RenderBlock>((prev && prev->isAnonymousBlock()) ? prev : next);
846
        if ((anonBlock->previousSibling() || anonBlock->nextSibling())
773
        if ((anonBlock->previousSibling() || anonBlock->nextSibling())
847
            && (!anonBlock->previousSibling() || (anonBlock->previousSibling()->style().styleType() != NOPSEUDO && anonBlock->previousSibling()->isFloating() && !anonBlock->previousSibling()->previousSibling()))
774
            && (!anonBlock->previousSibling() || (anonBlock->previousSibling()->style().styleType() != NOPSEUDO && anonBlock->previousSibling()->isFloating() && !anonBlock->previousSibling()->previousSibling()))
848
            && (!anonBlock->nextSibling() || (anonBlock->nextSibling()->style().styleType() != NOPSEUDO && anonBlock->nextSibling()->isFloating() && !anonBlock->nextSibling()->nextSibling()))) {
775
            && (!anonBlock->nextSibling() || (anonBlock->nextSibling()->style().styleType() != NOPSEUDO && anonBlock->nextSibling()->isFloating() && !anonBlock->nextSibling()->nextSibling()))) {
849
            collapseAnonymousBoxChild(this, anonBlock);
776
            collapseAnonymousBoxChild(*this, anonBlock);
850
            nextSibling = nullptr;
777
            nextSibling = nullptr;
851
        }
778
        }
852
    }
779
    }
Lines 864-886 RenderObject* RenderBlock::removeChild(RenderObject& oldChild) a/Source/WebCore/rendering/RenderBlock.cpp_sec11
864
            auto containingBlockIgnoringAnonymous = containingBlock();
791
            auto containingBlockIgnoringAnonymous = containingBlock();
865
            while (containingBlockIgnoringAnonymous && containingBlockIgnoringAnonymous->isAnonymousBlock())
792
            while (containingBlockIgnoringAnonymous && containingBlockIgnoringAnonymous->isAnonymousBlock())
866
                containingBlockIgnoringAnonymous = containingBlockIgnoringAnonymous->containingBlock();
793
                containingBlockIgnoringAnonymous = containingBlockIgnoringAnonymous->containingBlock();
867
            for (RenderObject* curr = this; curr; curr = curr->previousInPreOrder(containingBlockIgnoringAnonymous)) {
794
            for (RenderObject* current = this; current; current = current->previousInPreOrder(containingBlockIgnoringAnonymous)) {
868
                if (curr->virtualContinuation() != this)
795
                if (current->virtualContinuation() != this)
869
                    continue;
796
                    continue;
870
797
871
                // Found our previous continuation. We just need to point it to
798
                // Found our previous continuation. We just need to point it to
872
                // |this|'s next continuation.
799
                // |this|'s next continuation.
873
                RenderBoxModelObject* nextContinuation = continuation();
800
                RenderBoxModelObject* nextContinuation = continuation();
874
                if (curr->isRenderInline())
801
                if (is<RenderInline>(*current))
875
                    toRenderInline(curr)->setContinuation(nextContinuation);
802
                    downcast<RenderInline>(*current).setContinuation(nextContinuation);
876
                else if (curr->isRenderBlock())
803
                else if (is<RenderBlock>(*current))
877
                    toRenderBlock(curr)->setContinuation(nextContinuation);
804
                    downcast<RenderBlock>(*current).setContinuation(nextContinuation);
878
                else
805
                else
879
                    ASSERT_NOT_REACHED();
806
                    ASSERT_NOT_REACHED();
880
807
881
                break;
808
                break;
882
            }
809
            }
883
            setContinuation(0);
810
            setContinuation(nullptr);
884
            destroy();
811
            destroy();
885
        }
812
        }
886
    }
813
    }
Lines 1741-1751 RenderBlock* RenderBlock::blockElementContinuation() const a/Source/WebCore/rendering/RenderBlock.cpp_sec12
1741
{
1668
{
1742
    RenderBoxModelObject* currentContinuation = continuation();
1669
    RenderBoxModelObject* currentContinuation = continuation();
1743
    if (!currentContinuation || currentContinuation->isInline())
1670
    if (!currentContinuation || currentContinuation->isInline())
1744
        return 0;
1671
        return nullptr;
1745
    RenderBlock* nextContinuation = toRenderBlock(currentContinuation);
1672
    RenderBlock& nextContinuation = downcast<RenderBlock>(*currentContinuation);
1746
    if (nextContinuation->isAnonymousBlock())
1673
    if (nextContinuation.isAnonymousBlock())
1747
        return nextContinuation->blockElementContinuation();
1674
        return nextContinuation.blockElementContinuation();
1748
    return nextContinuation;
1675
    return &nextContinuation;
1749
}
1676
}
1750
    
1677
    
1751
static ContinuationOutlineTableMap* continuationOutlineTable()
1678
static ContinuationOutlineTableMap* continuationOutlineTable()
Lines 2042-2048 GapRects RenderBlock::blockSelectionGaps(RenderBlock& rootBlock, const LayoutPoi a/Source/WebCore/rendering/RenderBlock.cpp_sec13
2042
            lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logicalBottom(), cache);
1969
            lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logicalBottom(), cache);
2043
        } else if (childState != SelectionNone) {
1970
        } else if (childState != SelectionNone) {
2044
            // We must be a block that has some selected object inside it.  Go ahead and recur.
1971
            // We must be a block that has some selected object inside it.  Go ahead and recur.
2045
            result.unite(toRenderBlock(curr)->selectionGaps(rootBlock, rootBlockPhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offsetFromRootBlock.height() + curr->y()), 
1972
            result.unite(downcast<RenderBlock>(*curr).selectionGaps(rootBlock, rootBlockPhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offsetFromRootBlock.height() + curr->y()),
2046
                lastLogicalTop, lastLogicalLeft, lastLogicalRight, childCache, paintInfo));
1973
                lastLogicalTop, lastLogicalLeft, lastLogicalRight, childCache, paintInfo));
2047
        }
1974
        }
2048
    }
1975
    }
Lines 2162-2190 LayoutUnit RenderBlock::logicalRightSelectionOffset(RenderBlock& rootBlock, Layo a/Source/WebCore/rendering/RenderBlock.cpp_sec14
2162
RenderBlock* RenderBlock::blockBeforeWithinSelectionRoot(LayoutSize& offset) const
2089
RenderBlock* RenderBlock::blockBeforeWithinSelectionRoot(LayoutSize& offset) const
2163
{
2090
{
2164
    if (isSelectionRoot())
2091
    if (isSelectionRoot())
2165
        return 0;
2092
        return nullptr;
2166
2093
2167
    const RenderElement* object = this;
2094
    const RenderElement* object = this;
2168
    RenderObject* sibling;
2095
    RenderObject* sibling;
2169
    do {
2096
    do {
2170
        sibling = object->previousSibling();
2097
        sibling = object->previousSibling();
2171
        while (sibling && (!sibling->isRenderBlock() || toRenderBlock(sibling)->isSelectionRoot()))
2098
        while (sibling && (!is<RenderBlock>(*sibling) || downcast<RenderBlock>(*sibling).isSelectionRoot()))
2172
            sibling = sibling->previousSibling();
2099
            sibling = sibling->previousSibling();
2173
2100
2174
        offset -= LayoutSize(toRenderBlock(object)->logicalLeft(), toRenderBlock(object)->logicalTop());
2101
        offset -= LayoutSize(downcast<RenderBlock>(*object).logicalLeft(), downcast<RenderBlock>(*object).logicalTop());
2175
        object = object->parent();
2102
        object = object->parent();
2176
    } while (!sibling && object && object->isRenderBlock() && !toRenderBlock(object)->isSelectionRoot());
2103
    } while (!sibling && is<RenderBlock>(object) && !downcast<RenderBlock>(*object).isSelectionRoot());
2177
2104
2178
    if (!sibling)
2105
    if (!sibling)
2179
        return 0;
2106
        return nullptr;
2180
2107
2181
    RenderBlock* beforeBlock = toRenderBlock(sibling);
2108
    RenderBlock* beforeBlock = downcast<RenderBlock>(sibling);
2182
2109
2183
    offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop());
2110
    offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop());
2184
2111
2185
    RenderObject* child = beforeBlock->lastChild();
2112
    RenderObject* child = beforeBlock->lastChild();
2186
    while (child && child->isRenderBlock()) {
2113
    while (is<RenderBlock>(child)) {
2187
        beforeBlock = toRenderBlock(child);
2114
        beforeBlock = downcast<RenderBlock>(child);
2188
        offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop());
2115
        offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop());
2189
        child = beforeBlock->lastChild();
2116
        child = beforeBlock->lastChild();
2190
    }
2117
    }
Lines 2682-2688 static inline bool isChildHitTestCandidate(const RenderBox& box, const RenderReg a/Source/WebCore/rendering/RenderBlock.cpp_sec15
2682
        return false;
2609
        return false;
2683
    if (!region)
2610
    if (!region)
2684
        return true;
2611
        return true;
2685
    const RenderBlock& block = box.isRenderBlock() ? toRenderBlock(box) : *box.containingBlock();
2612
    const RenderBlock& block = is<RenderBlock>(box) ? downcast<RenderBlock>(box) : *box.containingBlock();
2686
    return block.regionAtBlockOffset(point.y()) == region;
2613
    return block.regionAtBlockOffset(point.y()) == region;
2687
}
2614
}
2688
2615
Lines 3042-3052 RenderBlock* RenderBlock::firstLineBlock() const a/Source/WebCore/rendering/RenderBlock.cpp_sec16
3042
        if (firstLineBlock->isReplaced() || firstLineBlock->isFloating()
2969
        if (firstLineBlock->isReplaced() || firstLineBlock->isFloating()
3043
            || !parentBlock || parentBlock->firstChild() != firstLineBlock || !isRenderBlockFlowOrRenderButton(*parentBlock))
2970
            || !parentBlock || parentBlock->firstChild() != firstLineBlock || !isRenderBlockFlowOrRenderButton(*parentBlock))
3044
            break;
2971
            break;
3045
        firstLineBlock = toRenderBlock(parentBlock);
2972
        firstLineBlock = downcast<RenderBlock>(parentBlock);
3046
    } 
2973
    } 
3047
    
2974
    
3048
    if (!hasPseudo)
2975
    if (!hasPseudo)
3049
        return 0;
2976
        return nullptr;
3050
    
2977
    
3051
    return firstLineBlock;
2978
    return firstLineBlock;
3052
}
2979
}
Lines 3125-3135 static inline RenderBlock* findFirstLetterBlock(RenderBlock* start) a/Source/WebCore/rendering/RenderBlock.cpp_sec17
3125
        RenderElement* parentBlock = firstLetterBlock->parent();
3052
        RenderElement* parentBlock = firstLetterBlock->parent();
3126
        if (firstLetterBlock->isReplaced() || !parentBlock || parentBlock->firstChild() != firstLetterBlock
3053
        if (firstLetterBlock->isReplaced() || !parentBlock || parentBlock->firstChild() != firstLetterBlock
3127
            || !isRenderBlockFlowOrRenderButton(*parentBlock))
3054
            || !isRenderBlockFlowOrRenderButton(*parentBlock))
3128
            return 0;
3055
            return nullptr;
3129
        firstLetterBlock = toRenderBlock(parentBlock);
3056
        firstLetterBlock = downcast<RenderBlock>(parentBlock);
3130
    } 
3057
    } 
3131
3058
3132
    return 0;
3059
    return nullptr;
3133
}
3060
}
3134
3061
3135
void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderObject* currentChild)
3062
void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderObject* currentChild)
Lines 3421-3428 const RenderStyle& RenderBlock::outlineStyleForRepaint() const a/Source/WebCore/rendering/RenderBlock.cpp_sec18
3421
void RenderBlock::childBecameNonInline(RenderObject*)
3348
void RenderBlock::childBecameNonInline(RenderObject*)
3422
{
3349
{
3423
    makeChildrenNonInline();
3350
    makeChildrenNonInline();
3424
    if (isAnonymousBlock() && parent() && parent()->isRenderBlock())
3351
    if (isAnonymousBlock() && is<RenderBlock>(parent()))
3425
        toRenderBlock(parent())->removeLeftoverAnonymousBlock(this);
3352
        downcast<RenderBlock>(*parent()).removeLeftoverAnonymousBlock(this);
3426
    // |this| may be dead here
3353
    // |this| may be dead here
3427
}
3354
}
3428
3355
Lines 3671-3682 bool RenderBlock::hasMarginBeforeQuirk(const RenderBox& child) const a/Source/WebCore/rendering/RenderBlock.cpp_sec19
3671
    // If the child has the same directionality as we do, then we can just return its
3598
    // If the child has the same directionality as we do, then we can just return its
3672
    // margin quirk.
3599
    // margin quirk.
3673
    if (!child.isWritingModeRoot())
3600
    if (!child.isWritingModeRoot())
3674
        return child.isRenderBlock() ? toRenderBlock(child).hasMarginBeforeQuirk() : child.style().hasMarginBeforeQuirk();
3601
        return is<RenderBlock>(child) ? downcast<RenderBlock>(child).hasMarginBeforeQuirk() : child.style().hasMarginBeforeQuirk();
3675
    
3602
    
3676
    // The child has a different directionality. If the child is parallel, then it's just
3603
    // The child has a different directionality. If the child is parallel, then it's just
3677
    // flipped relative to us. We can use the opposite edge.
3604
    // flipped relative to us. We can use the opposite edge.
3678
    if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
3605
    if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
3679
        return child.isRenderBlock() ? toRenderBlock(child).hasMarginAfterQuirk() : child.style().hasMarginAfterQuirk();
3606
        return is<RenderBlock>(child) ? downcast<RenderBlock>(child).hasMarginAfterQuirk() : child.style().hasMarginAfterQuirk();
3680
    
3607
    
3681
    // The child is perpendicular to us and box sides are never quirky in html.css, and we don't really care about
3608
    // The child is perpendicular to us and box sides are never quirky in html.css, and we don't really care about
3682
    // whether or not authors specified quirky ems, since they're an implementation detail.
3609
    // whether or not authors specified quirky ems, since they're an implementation detail.
Lines 3688-3699 bool RenderBlock::hasMarginAfterQuirk(const RenderBox& child) const a/Source/WebCore/rendering/RenderBlock.cpp_sec20
3688
    // If the child has the same directionality as we do, then we can just return its
3615
    // If the child has the same directionality as we do, then we can just return its
3689
    // margin quirk.
3616
    // margin quirk.
3690
    if (!child.isWritingModeRoot())
3617
    if (!child.isWritingModeRoot())
3691
        return child.isRenderBlock() ? toRenderBlock(child).hasMarginAfterQuirk() : child.style().hasMarginAfterQuirk();
3618
        return is<RenderBlock>(child) ? downcast<RenderBlock>(child).hasMarginAfterQuirk() : child.style().hasMarginAfterQuirk();
3692
    
3619
    
3693
    // The child has a different directionality. If the child is parallel, then it's just
3620
    // The child has a different directionality. If the child is parallel, then it's just
3694
    // flipped relative to us. We can use the opposite edge.
3621
    // flipped relative to us. We can use the opposite edge.
3695
    if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
3622
    if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
3696
        return child.isRenderBlock() ? toRenderBlock(child).hasMarginBeforeQuirk() : child.style().hasMarginBeforeQuirk();
3623
        return is<RenderBlock>(child) ? downcast<RenderBlock>(child).hasMarginBeforeQuirk() : child.style().hasMarginBeforeQuirk();
3697
    
3624
    
3698
    // The child is perpendicular to us and box sides are never quirky in html.css, and we don't really care about
3625
    // The child is perpendicular to us and box sides are never quirky in html.css, and we don't really care about
3699
    // whether or not authors specified quirky ems, since they're an implementation detail.
3626
    // whether or not authors specified quirky ems, since they're an implementation detail.
- a/Source/WebCore/rendering/RenderBlock.h -7 / +1 lines
Lines 195-201 public: a/Source/WebCore/rendering/RenderBlock.h_sec1
195
195
196
    static RenderBlock* createAnonymousWithParentRendererAndDisplay(const RenderObject*, EDisplay = BLOCK);
196
    static RenderBlock* createAnonymousWithParentRendererAndDisplay(const RenderObject*, EDisplay = BLOCK);
197
    RenderBlock* createAnonymousBlock(EDisplay display = BLOCK) const { return createAnonymousWithParentRendererAndDisplay(this, display); }
197
    RenderBlock* createAnonymousBlock(EDisplay display = BLOCK) const { return createAnonymousWithParentRendererAndDisplay(this, display); }
198
    static void collapseAnonymousBoxChild(RenderBlock* parent, RenderBlock* child);
198
    static void collapseAnonymousBoxChild(RenderBlock& parent, RenderBlock* child);
199
199
200
    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const override;
200
    virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const override;
201
201
Lines 486-495 private: a/Source/WebCore/rendering/RenderBlock.h_sec2
486
486
487
    bool expandsToEncloseOverhangingFloats() const;
487
    bool expandsToEncloseOverhangingFloats() const;
488
488
489
    void splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
490
                     RenderObject* beforeChild, RenderBoxModelObject* oldCont);
491
    void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
492
                   RenderObject* newChild, RenderBoxModelObject* oldCont);
493
    RenderPtr<RenderBlock> clone() const;
489
    RenderPtr<RenderBlock> clone() const;
494
    RenderBlock* continuationBefore(RenderObject* beforeChild);
490
    RenderBlock* continuationBefore(RenderObject* beforeChild);
495
491
Lines 530-537 private: a/Source/WebCore/rendering/RenderBlock.h_sec3
530
    static bool s_canPropagateFloatIntoSibling;
526
    static bool s_canPropagateFloatIntoSibling;
531
};
527
};
532
528
533
RENDER_OBJECT_TYPE_CASTS(RenderBlock, isRenderBlock())
534
535
LayoutUnit blockDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
529
LayoutUnit blockDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
536
LayoutUnit inlineDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
530
LayoutUnit inlineDirectionOffset(RenderBlock& rootBlock, const LayoutSize& offsetFromRootBlock);
537
VisiblePosition positionForPointRespectingEditingBoundaries(RenderBlock&, RenderBox&, const LayoutPoint&);
531
VisiblePosition positionForPointRespectingEditingBoundaries(RenderBlock&, RenderBox&, const LayoutPoint&);
- a/Source/WebCore/rendering/RenderBlockFlow.cpp -12 / +12 lines
Lines 1219-1228 void RenderBlockFlow::marginBeforeEstimateForChild(RenderBox& child, LayoutUnit& a/Source/WebCore/rendering/RenderBlockFlow.cpp_sec1
1219
    // Make sure to update the block margins now for the grandchild box so that we're looking at current values.
1219
    // Make sure to update the block margins now for the grandchild box so that we're looking at current values.
1220
    if (grandchildBox->needsLayout()) {
1220
    if (grandchildBox->needsLayout()) {
1221
        grandchildBox->computeAndSetBlockDirectionMargins(this);
1221
        grandchildBox->computeAndSetBlockDirectionMargins(this);
1222
        if (grandchildBox->isRenderBlock()) {
1222
        if (is<RenderBlock>(*grandchildBox)) {
1223
            RenderBlock* grandchildBlock = toRenderBlock(grandchildBox);
1223
            RenderBlock& grandchildBlock = downcast<RenderBlock>(*grandchildBox);
1224
            grandchildBlock->setHasMarginBeforeQuirk(grandchildBox->style().hasMarginBeforeQuirk());
1224
            grandchildBlock.setHasMarginBeforeQuirk(grandchildBox->style().hasMarginBeforeQuirk());
1225
            grandchildBlock->setHasMarginAfterQuirk(grandchildBox->style().hasMarginAfterQuirk());
1225
            grandchildBlock.setHasMarginAfterQuirk(grandchildBox->style().hasMarginAfterQuirk());
1226
        }
1226
        }
1227
    }
1227
    }
1228
1228
Lines 1274-1281 LayoutUnit RenderBlockFlow::estimateLogicalTopPosition(RenderBox& child, const M a/Source/WebCore/rendering/RenderBlockFlow.cpp_sec2
1274
        // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
1274
        // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
1275
        logicalTopEstimate = adjustForUnsplittableChild(child, logicalTopEstimate);
1275
        logicalTopEstimate = adjustForUnsplittableChild(child, logicalTopEstimate);
1276
        
1276
        
1277
        if (!child.selfNeedsLayout() && child.isRenderBlock())
1277
        if (!child.selfNeedsLayout() && is<RenderBlock>(child))
1278
            logicalTopEstimate += toRenderBlock(child).paginationStrut();
1278
            logicalTopEstimate += downcast<RenderBlock>(child).paginationStrut();
1279
    }
1279
    }
1280
1280
1281
    return logicalTopEstimate;
1281
    return logicalTopEstimate;
Lines 1522-1528 LayoutUnit RenderBlockFlow::applyAfterBreak(RenderBox& child, LayoutUnit logical a/Source/WebCore/rendering/RenderBlockFlow.cpp_sec3
1522
1522
1523
LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopAfterClear, LayoutUnit estimateWithoutPagination, RenderBox& child, bool atBeforeSideOfBlock)
1523
LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopAfterClear, LayoutUnit estimateWithoutPagination, RenderBox& child, bool atBeforeSideOfBlock)
1524
{
1524
{
1525
    RenderBlock* childRenderBlock = child.isRenderBlock() ? toRenderBlock(&child) : nullptr;
1525
    RenderBlock* childRenderBlock = is<RenderBlock>(child) ? &downcast<RenderBlock>(child) : nullptr;
1526
1526
1527
    if (estimateWithoutPagination != logicalTopAfterClear) {
1527
    if (estimateWithoutPagination != logicalTopAfterClear) {
1528
        // Our guess prior to pagination movement was wrong. Before we attempt to paginate, let's try again at the new
1528
        // Our guess prior to pagination movement was wrong. Before we attempt to paginate, let's try again at the new
Lines 2457-2463 bool RenderBlockFlow::positionNewFloats() a/Source/WebCore/rendering/RenderBlockFlow.cpp_sec4
2457
            // See if we have a pagination strut that is making us move down further.
2457
            // See if we have a pagination strut that is making us move down further.
2458
            // Note that an unsplittable child can't also have a pagination strut, so this is
2458
            // Note that an unsplittable child can't also have a pagination strut, so this is
2459
            // exclusive with the case above.
2459
            // exclusive with the case above.
2460
            RenderBlock* childBlock = childBox.isRenderBlock() ? toRenderBlock(&childBox) : nullptr;
2460
            RenderBlock* childBlock = is<RenderBlock>(childBox) ? &downcast<RenderBlock>(childBox) : nullptr;
2461
            if (childBlock && childBlock->paginationStrut()) {
2461
            if (childBlock && childBlock->paginationStrut()) {
2462
                newLogicalTop += childBlock->paginationStrut();
2462
                newLogicalTop += childBlock->paginationStrut();
2463
                childBlock->setPaginationStrut(0);
2463
                childBlock->setPaginationStrut(0);
Lines 2729-2744 void RenderBlockFlow::markSiblingsWithFloatsForLayout(RenderBox* floatToRemove) a/Source/WebCore/rendering/RenderBlockFlow.cpp_sec5
2729
    auto end = floatingObjectSet.end();
2729
    auto end = floatingObjectSet.end();
2730
2730
2731
    for (RenderObject* next = nextSibling(); next; next = next->nextSibling()) {
2731
    for (RenderObject* next = nextSibling(); next; next = next->nextSibling()) {
2732
        if (!next->isRenderBlockFlow() || next->isFloatingOrOutOfFlowPositioned() || toRenderBlock(next)->avoidsFloats())
2732
        if (!is<RenderBlockFlow>(*next) || next->isFloatingOrOutOfFlowPositioned() || downcast<RenderBlockFlow>(*next).avoidsFloats())
2733
            continue;
2733
            continue;
2734
2734
2735
        RenderBlockFlow* nextBlock = toRenderBlockFlow(next);
2735
        RenderBlockFlow& nextBlock = downcast<RenderBlockFlow>(*next);
2736
        for (auto it = floatingObjectSet.begin(); it != end; ++it) {
2736
        for (auto it = floatingObjectSet.begin(); it != end; ++it) {
2737
            RenderBox& floatingBox = (*it)->renderer();
2737
            RenderBox& floatingBox = (*it)->renderer();
2738
            if (floatToRemove && &floatingBox != floatToRemove)
2738
            if (floatToRemove && &floatingBox != floatToRemove)
2739
                continue;
2739
                continue;
2740
            if (nextBlock->containsFloat(floatingBox))
2740
            if (nextBlock.containsFloat(floatingBox))
2741
                nextBlock->markAllDescendantsWithFloatsForLayout(&floatingBox);
2741
                nextBlock.markAllDescendantsWithFloatsForLayout(&floatingBox);
2742
        }
2742
        }
2743
    }
2743
    }
2744
}
2744
}
- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp -2 / +2 lines
Lines 1894-1901 bool RenderBlockFlow::positionNewFloatOnLine(FloatingObject* newFloat, FloatingO a/Source/WebCore/rendering/RenderBlockLineLayout.cpp_sec1
1894
1894
1895
            if (updateRegionRangeForBoxChild(floatingObject->renderer()))
1895
            if (updateRegionRangeForBoxChild(floatingObject->renderer()))
1896
                floatBox.setNeedsLayout(MarkOnlyThis);
1896
                floatBox.setNeedsLayout(MarkOnlyThis);
1897
            else if (floatBox.isRenderBlock())
1897
            else if (is<RenderBlock>(floatBox))
1898
                toRenderBlock(floatBox).setChildNeedsLayout(MarkOnlyThis);
1898
                downcast<RenderBlock>(floatBox).setChildNeedsLayout(MarkOnlyThis);
1899
            floatBox.layoutIfNeeded();
1899
            floatBox.layoutIfNeeded();
1900
1900
1901
            // Save the old logical top before calling removePlacedObject which will set
1901
            // Save the old logical top before calling removePlacedObject which will set
- a/Source/WebCore/rendering/RenderBox.cpp -68 / +68 lines
Lines 2947-2966 LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(Length logicalHeight) co a/Source/WebCore/rendering/RenderBox.cpp_sec1
2947
        case Calculated:
2947
        case Calculated:
2948
        {
2948
        {
2949
            auto cb = isOutOfFlowPositioned() ? container() : containingBlock();
2949
            auto cb = isOutOfFlowPositioned() ? container() : containingBlock();
2950
            while (cb->isAnonymous() && !cb->isRenderView()) {
2950
            while (cb->isAnonymous() && !is<RenderView>(*cb)) {
2951
                cb = cb->containingBlock();
2951
                cb = cb->containingBlock();
2952
                toRenderBlock(cb)->addPercentHeightDescendant(const_cast<RenderBox&>(*this));
2952
                downcast<RenderBlock>(*cb).addPercentHeightDescendant(const_cast<RenderBox&>(*this));
2953
            }
2953
            }
2954
2954
2955
            // FIXME: This calculation is not patched for block-flow yet.
2955
            // FIXME: This calculation is not patched for block-flow yet.
2956
            // https://bugs.webkit.org/show_bug.cgi?id=46500
2956
            // https://bugs.webkit.org/show_bug.cgi?id=46500
2957
            if (cb->isOutOfFlowPositioned() && cb->style().height().isAuto() && !(cb->style().top().isAuto() || cb->style().bottom().isAuto())) {
2957
            if (cb->isOutOfFlowPositioned() && cb->style().height().isAuto() && !(cb->style().top().isAuto() || cb->style().bottom().isAuto())) {
2958
                ASSERT_WITH_SECURITY_IMPLICATION(cb->isRenderBlock());
2958
                ASSERT_WITH_SECURITY_IMPLICATION(cb->isRenderBlock());
2959
                RenderBlock* block = toRenderBlock(cb);
2959
                RenderBlock& block = downcast<RenderBlock>(*cb);
2960
                LogicalExtentComputedValues computedValues;
2960
                LogicalExtentComputedValues computedValues;
2961
                block->computeLogicalHeight(block->logicalHeight(), 0, computedValues);
2961
                block.computeLogicalHeight(block.logicalHeight(), 0, computedValues);
2962
                LayoutUnit newContentHeight = computedValues.m_extent - block->borderAndPaddingLogicalHeight() - block->scrollbarLogicalHeight();
2962
                LayoutUnit newContentHeight = computedValues.m_extent - block.borderAndPaddingLogicalHeight() - block.scrollbarLogicalHeight();
2963
                LayoutUnit newHeight = block->adjustContentBoxLogicalHeightForBoxSizing(newContentHeight);
2963
                LayoutUnit newHeight = block.adjustContentBoxLogicalHeightForBoxSizing(newContentHeight);
2964
                return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logicalHeight, newHeight));
2964
                return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logicalHeight, newHeight));
2965
            }
2965
            }
2966
            
2966
            
Lines 2984-2990 LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(Length logicalHeight) co a/Source/WebCore/rendering/RenderBox.cpp_sec2
2984
                        availableHeight = std::max(availableHeight, intrinsicLogicalHeight());
2984
                        availableHeight = std::max(availableHeight, intrinsicLogicalHeight());
2985
                        return valueForLength(logicalHeight, availableHeight - borderAndPaddingLogicalHeight());
2985
                        return valueForLength(logicalHeight, availableHeight - borderAndPaddingLogicalHeight());
2986
                    }
2986
                    }
2987
                    toRenderBlock(cb)->addPercentHeightDescendant(const_cast<RenderBox&>(*this));
2987
                    downcast<RenderBlock>(*cb).addPercentHeightDescendant(const_cast<RenderBox&>(*this));
2988
                    cb = cb->containingBlock();
2988
                    cb = cb->containingBlock();
2989
                }
2989
                }
2990
            }
2990
            }
Lines 3023-3033 LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogi a/Source/WebCore/rendering/RenderBox.cpp_sec3
3023
3023
3024
    // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical writing-mode.
3024
    // FIXME: Check logicalTop/logicalBottom here to correctly handle vertical writing-mode.
3025
    // https://bugs.webkit.org/show_bug.cgi?id=46500
3025
    // https://bugs.webkit.org/show_bug.cgi?id=46500
3026
    if (isRenderBlock() && isOutOfFlowPositioned() && style().height().isAuto() && !(style().top().isAuto() || style().bottom().isAuto())) {
3026
    if (is<RenderBlock>(*this) && isOutOfFlowPositioned() && style().height().isAuto() && !(style().top().isAuto() || style().bottom().isAuto())) {
3027
        RenderBlock* block = const_cast<RenderBlock*>(toRenderBlock(this));
3027
        RenderBlock& block = const_cast<RenderBlock&>(downcast<RenderBlock>(*this));
3028
        LogicalExtentComputedValues computedValues;
3028
        LogicalExtentComputedValues computedValues;
3029
        block->computeLogicalHeight(block->logicalHeight(), 0, computedValues);
3029
        block.computeLogicalHeight(block.logicalHeight(), 0, computedValues);
3030
        LayoutUnit newContentHeight = computedValues.m_extent - block->borderAndPaddingLogicalHeight() - block->scrollbarLogicalHeight();
3030
        LayoutUnit newContentHeight = computedValues.m_extent - block.borderAndPaddingLogicalHeight() - block.scrollbarLogicalHeight();
3031
        return adjustContentBoxLogicalHeightForBoxSizing(newContentHeight);
3031
        return adjustContentBoxLogicalHeightForBoxSizing(newContentHeight);
3032
    }
3032
    }
3033
3033
Lines 3072-3110 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo a/Source/WebCore/rendering/RenderBox.cpp_sec4
3072
    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
3072
    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
3073
        return containingBlockLogicalHeightForPositioned(containingBlock, false);
3073
        return containingBlockLogicalHeightForPositioned(containingBlock, false);
3074
3074
3075
    if (containingBlock->isBox()) {
3075
    if (is<RenderBox>(*containingBlock)) {
3076
        bool isFixedPosition = style().position() == FixedPosition;
3076
        bool isFixedPosition = style().position() == FixedPosition;
3077
3077
3078
        RenderFlowThread* flowThread = flowThreadContainingBlock();
3078
        RenderFlowThread* flowThread = flowThreadContainingBlock();
3079
        if (!flowThread) {
3079
        if (!flowThread) {
3080
            if (isFixedPosition && containingBlock->isRenderView())
3080
            if (isFixedPosition && is<RenderView>(*containingBlock))
3081
                return toRenderView(containingBlock)->clientLogicalWidthForFixedPosition();
3081
                return downcast<RenderView>(*containingBlock).clientLogicalWidthForFixedPosition();
3082
3082
3083
            return toRenderBox(containingBlock)->clientLogicalWidth();
3083
            return downcast<RenderBox>(*containingBlock).clientLogicalWidth();
3084
        }
3084
        }
3085
3085
3086
        if (isFixedPosition && containingBlock->isRenderNamedFlowThread())
3086
        if (isFixedPosition && is<RenderNamedFlowThread>(*containingBlock))
3087
            return containingBlock->view().clientLogicalWidth();
3087
            return containingBlock->view().clientLogicalWidth();
3088
3088
3089
        if (!containingBlock->isRenderBlock())
3089
        if (!is<RenderBlock>(*containingBlock))
3090
            return toRenderBox(*containingBlock).clientLogicalWidth();
3090
            return downcast<RenderBox>(*containingBlock).clientLogicalWidth();
3091
3091
3092
        const RenderBlock* cb = toRenderBlock(containingBlock);
3092
        const RenderBlock& cb = downcast<RenderBlock>(*containingBlock);
3093
        RenderBoxRegionInfo* boxInfo = 0;
3093
        RenderBoxRegionInfo* boxInfo = nullptr;
3094
        if (!region) {
3094
        if (!region) {
3095
            if (containingBlock->isRenderFlowThread() && !checkForPerpendicularWritingMode)
3095
            if (containingBlock->isRenderFlowThread() && !checkForPerpendicularWritingMode)
3096
                return toRenderFlowThread(containingBlock)->contentLogicalWidthOfFirstRegion();
3096
                return toRenderFlowThread(containingBlock)->contentLogicalWidthOfFirstRegion();
3097
            if (isWritingModeRoot()) {
3097
            if (isWritingModeRoot()) {
3098
                LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage();
3098
                LayoutUnit cbPageOffset = cb.offsetFromLogicalTopOfFirstPage();
3099
                RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset);
3099
                RenderRegion* cbRegion = cb.regionAtBlockOffset(cbPageOffset);
3100
                if (cbRegion)
3100
                if (cbRegion)
3101
                    boxInfo = cb->renderBoxRegionInfo(cbRegion);
3101
                    boxInfo = cb.renderBoxRegionInfo(cbRegion);
3102
            }
3102
            }
3103
        } else if (region && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
3103
        } else if (region && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
3104
            RenderRegion* containingBlockRegion = cb->clampToStartAndEndRegions(region);
3104
            RenderRegion* containingBlockRegion = cb.clampToStartAndEndRegions(region);
3105
            boxInfo = cb->renderBoxRegionInfo(containingBlockRegion);
3105
            boxInfo = cb.renderBoxRegionInfo(containingBlockRegion);
3106
        }
3106
        }
3107
        return (boxInfo) ? std::max<LayoutUnit>(0, cb->clientLogicalWidth() - (cb->logicalWidth() - boxInfo->logicalWidth())) : cb->clientLogicalWidth();
3107
        return (boxInfo) ? std::max<LayoutUnit>(0, cb.clientLogicalWidth() - (cb.logicalWidth() - boxInfo->logicalWidth())) : cb.clientLogicalWidth();
3108
    }
3108
    }
3109
3109
3110
    ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositioned());
3110
    ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositioned());
Lines 3133-3169 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo a/Source/WebCore/rendering/RenderBox.cpp_sec5
3133
LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const
3133
LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const
3134
{
3134
{
3135
    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
3135
    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
3136
        return containingBlockLogicalWidthForPositioned(containingBlock, 0, false);
3136
        return containingBlockLogicalWidthForPositioned(containingBlock, nullptr, false);
3137
3137
3138
    if (containingBlock->isBox()) {
3138
    if (containingBlock->isBox()) {
3139
        bool isFixedPosition = style().position() == FixedPosition;
3139
        bool isFixedPosition = style().position() == FixedPosition;
3140
3140
3141
        if (isFixedPosition && containingBlock->isRenderView())
3141
        if (isFixedPosition && is<RenderView>(*containingBlock))
3142
            return toRenderView(containingBlock)->clientLogicalHeightForFixedPosition();
3142
            return downcast<RenderView>(*containingBlock).clientLogicalHeightForFixedPosition();
3143
3143
3144
        const RenderBlock* cb = containingBlock->isRenderBlock() ? toRenderBlock(containingBlock) : containingBlock->containingBlock();
3144
        const RenderBlock* cb = is<RenderBlock>(*containingBlock) ? downcast<RenderBlock>(containingBlock) : containingBlock->containingBlock();
3145
        LayoutUnit result = cb->clientLogicalHeight();
3145
        LayoutUnit result = cb->clientLogicalHeight();
3146
        RenderFlowThread* flowThread = flowThreadContainingBlock();
3146
        RenderFlowThread* flowThread = flowThreadContainingBlock();
3147
        if (flowThread && containingBlock->isRenderFlowThread() && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
3147
        if (flowThread && is<RenderFlowThread>(*containingBlock) && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
3148
            if (containingBlock->isRenderNamedFlowThread() && isFixedPosition)
3148
            if (is<RenderNamedFlowThread>(*containingBlock) && isFixedPosition)
3149
                return containingBlock->view().clientLogicalHeight();
3149
                return containingBlock->view().clientLogicalHeight();
3150
            return toRenderFlowThread(containingBlock)->contentLogicalHeightOfFirstRegion();
3150
            return downcast<RenderFlowThread>(*containingBlock).contentLogicalHeightOfFirstRegion();
3151
        }
3151
        }
3152
        return result;
3152
        return result;
3153
    }
3153
    }
3154
        
3154
        
3155
    ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositioned());
3155
    ASSERT(is<RenderInline>(*containingBlock) && containingBlock->isInFlowPositioned());
3156
3156
3157
    const RenderInline* flow = toRenderInline(containingBlock);
3157
    const RenderInline& flow = downcast<RenderInline>(*containingBlock);
3158
    InlineFlowBox* first = flow->firstLineBox();
3158
    InlineFlowBox* first = flow.firstLineBox();
3159
    InlineFlowBox* last = flow->lastLineBox();
3159
    InlineFlowBox* last = flow.lastLineBox();
3160
3160
3161
    // If the containing block is empty, return a height of 0.
3161
    // If the containing block is empty, return a height of 0.
3162
    if (!first || !last)
3162
    if (!first || !last)
3163
        return 0;
3163
        return 0;
3164
3164
3165
    LayoutUnit heightResult;
3165
    LayoutUnit heightResult;
3166
    LayoutRect boundingBox = flow->linesBoundingBox();
3166
    LayoutRect boundingBox = flow.linesBoundingBox();
3167
    if (containingBlock->isHorizontalWritingMode())
3167
    if (containingBlock->isHorizontalWritingMode())
3168
        heightResult = boundingBox.height();
3168
        heightResult = boundingBox.height();
3169
    else
3169
    else
Lines 3180-3192 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh a/Source/WebCore/rendering/RenderBox.cpp_sec6
3180
    // FIXME: The static distance computation has not been patched for mixed writing modes yet.
3180
    // FIXME: The static distance computation has not been patched for mixed writing modes yet.
3181
    if (child->parent()->style().direction() == LTR) {
3181
    if (child->parent()->style().direction() == LTR) {
3182
        LayoutUnit staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
3182
        LayoutUnit staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
3183
        for (auto curr = child->parent(); curr && curr != containerBlock; curr = curr->container()) {
3183
        for (auto current = child->parent(); current && current != containerBlock; current = current->container()) {
3184
            if (curr->isBox()) {
3184
            if (is<RenderBox>(*current)) {
3185
                staticPosition += toRenderBox(curr)->logicalLeft();
3185
                staticPosition += downcast<RenderBox>(*current).logicalLeft();
3186
                if (region && toRenderBox(curr)->isRenderBlock()) {
3186
                if (region && is<RenderBlock>(*current)) {
3187
                    const RenderBlock* cb = toRenderBlock(curr);
3187
                    const RenderBlock& currentBlock = downcast<RenderBlock>(*current);
3188
                    region = cb->clampToStartAndEndRegions(region);
3188
                    region = currentBlock.clampToStartAndEndRegions(region);
3189
                    RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region);
3189
                    RenderBoxRegionInfo* boxInfo = currentBlock.renderBoxRegionInfo(region);
3190
                    if (boxInfo)
3190
                    if (boxInfo)
3191
                        staticPosition += boxInfo->logicalLeft();
3191
                        staticPosition += boxInfo->logicalLeft();
3192
                }
3192
                }
Lines 3196-3220 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh a/Source/WebCore/rendering/RenderBox.cpp_sec7
3196
    } else {
3196
    } else {
3197
        RenderBox& enclosingBox = child->parent()->enclosingBox();
3197
        RenderBox& enclosingBox = child->parent()->enclosingBox();
3198
        LayoutUnit staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft();
3198
        LayoutUnit staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft();
3199
        for (RenderElement* curr = &enclosingBox; curr; curr = curr->container()) {
3199
        for (RenderElement* current = &enclosingBox; current; current = current->container()) {
3200
            if (curr->isBox()) {
3200
            if (is<RenderBox>(*current)) {
3201
                if (curr != containerBlock)
3201
                if (current != containerBlock)
3202
                    staticPosition -= toRenderBox(curr)->logicalLeft();
3202
                    staticPosition -= downcast<RenderBox>(*current).logicalLeft();
3203
                if (curr == &enclosingBox)
3203
                if (current == &enclosingBox)
3204
                    staticPosition -= enclosingBox.logicalWidth();
3204
                    staticPosition -= enclosingBox.logicalWidth();
3205
                if (region && curr->isRenderBlock()) {
3205
                if (region && is<RenderBlock>(*current)) {
3206
                    const RenderBlock* cb = toRenderBlock(curr);
3206
                    const RenderBlock& currentBlock = downcast<RenderBlock>(*current);
3207
                    region = cb->clampToStartAndEndRegions(region);
3207
                    region = currentBlock.clampToStartAndEndRegions(region);
3208
                    RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region);
3208
                    RenderBoxRegionInfo* boxInfo = currentBlock.renderBoxRegionInfo(region);
3209
                    if (boxInfo) {
3209
                    if (boxInfo) {
3210
                        if (curr != containerBlock)
3210
                        if (current != containerBlock)
3211
                            staticPosition -= cb->logicalWidth() - (boxInfo->logicalLeft() + boxInfo->logicalWidth());
3211
                            staticPosition -= currentBlock.logicalWidth() - (boxInfo->logicalLeft() + boxInfo->logicalWidth());
3212
                        if (curr == &enclosingBox)
3212
                        if (current == &enclosingBox)
3213
                            staticPosition += enclosingBox.logicalWidth() - boxInfo->logicalWidth();
3213
                            staticPosition += enclosingBox.logicalWidth() - boxInfo->logicalWidth();
3214
                    }
3214
                    }
3215
                }
3215
                }
3216
            }
3216
            }
3217
            if (curr == containerBlock)
3217
            if (current == containerBlock)
3218
                break;
3218
                break;
3219
        }
3219
        }
3220
        logicalRight.setValue(Fixed, staticPosition);
3220
        logicalRight.setValue(Fixed, staticPosition);
Lines 3338-3351 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu a/Source/WebCore/rendering/RenderBox.cpp_sec8
3338
    // Adjust logicalLeft if we need to for the flipped version of our writing mode in regions.
3338
    // Adjust logicalLeft if we need to for the flipped version of our writing mode in regions.
3339
    // FIXME: Add support for other types of objects as containerBlock, not only RenderBlock.
3339
    // FIXME: Add support for other types of objects as containerBlock, not only RenderBlock.
3340
    RenderFlowThread* flowThread = flowThreadContainingBlock();
3340
    RenderFlowThread* flowThread = flowThreadContainingBlock();
3341
    if (flowThread && !region && isWritingModeRoot() && isHorizontalWritingMode() == containerBlock->isHorizontalWritingMode() && containerBlock->isRenderBlock()) {
3341
    if (flowThread && !region && isWritingModeRoot() && isHorizontalWritingMode() == containerBlock->isHorizontalWritingMode() && is<RenderBlock>(*containerBlock)) {
3342
        ASSERT(containerBlock->canHaveBoxInfoInRegion());
3342
        ASSERT(containerBlock->canHaveBoxInfoInRegion());
3343
        LayoutUnit logicalLeftPos = computedValues.m_position;
3343
        LayoutUnit logicalLeftPos = computedValues.m_position;
3344
        const RenderBlock* cb = toRenderBlock(containerBlock);
3344
        const RenderBlock& renderBlock = downcast<RenderBlock>(*containerBlock);
3345
        LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage();
3345
        LayoutUnit cbPageOffset = renderBlock.offsetFromLogicalTopOfFirstPage();
3346
        RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset);
3346
        RenderRegion* cbRegion = renderBlock.regionAtBlockOffset(cbPageOffset);
3347
        if (cbRegion) {
3347
        if (cbRegion) {
3348
            RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion);
3348
            RenderBoxRegionInfo* boxInfo = renderBlock.renderBoxRegionInfo(cbRegion);
3349
            if (boxInfo) {
3349
            if (boxInfo) {
3350
                logicalLeftPos += boxInfo->logicalLeft();
3350
                logicalLeftPos += boxInfo->logicalLeft();
3351
                computedValues.m_position = logicalLeftPos;
3351
                computedValues.m_position = logicalLeftPos;
Lines 3655-3668 void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp a/Source/WebCore/rendering/RenderBox.cpp_sec9
3655
    // Adjust logicalTop if we need to for perpendicular writing modes in regions.
3655
    // Adjust logicalTop if we need to for perpendicular writing modes in regions.
3656
    // FIXME: Add support for other types of objects as containerBlock, not only RenderBlock.
3656
    // FIXME: Add support for other types of objects as containerBlock, not only RenderBlock.
3657
    RenderFlowThread* flowThread = flowThreadContainingBlock();
3657
    RenderFlowThread* flowThread = flowThreadContainingBlock();
3658
    if (flowThread && isHorizontalWritingMode() != containerBlock->isHorizontalWritingMode() && containerBlock->isRenderBlock()) {
3658
    if (flowThread && isHorizontalWritingMode() != containerBlock->isHorizontalWritingMode() && is<RenderBlock>(*containerBlock)) {
3659
        ASSERT(containerBlock->canHaveBoxInfoInRegion());
3659
        ASSERT(containerBlock->canHaveBoxInfoInRegion());
3660
        LayoutUnit logicalTopPos = computedValues.m_position;
3660
        LayoutUnit logicalTopPos = computedValues.m_position;
3661
        const RenderBlock* cb = toRenderBlock(containerBlock);
3661
        const RenderBlock& renderBox = downcast<RenderBlock>(*containerBlock);
3662
        LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage() - logicalLeft();
3662
        LayoutUnit cbPageOffset = renderBox.offsetFromLogicalTopOfFirstPage() - logicalLeft();
3663
        RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset);
3663
        RenderRegion* cbRegion = renderBox.regionAtBlockOffset(cbPageOffset);
3664
        if (cbRegion) {
3664
        if (cbRegion) {
3665
            RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion);
3665
            RenderBoxRegionInfo* boxInfo = renderBox.renderBoxRegionInfo(cbRegion);
3666
            if (boxInfo) {
3666
            if (boxInfo) {
3667
                logicalTopPos += boxInfo->logicalLeft();
3667
                logicalTopPos += boxInfo->logicalLeft();
3668
                computedValues.m_position = logicalTopPos;
3668
                computedValues.m_position = logicalTopPos;
- a/Source/WebCore/rendering/RenderBoxModelObject.cpp -9 / +9 lines
Lines 213-223 static LayoutSize accumulateInFlowPositionOffsets(const RenderObject* child) a/Source/WebCore/rendering/RenderBoxModelObject.cpp_sec1
213
    if (!child->isAnonymousBlock() || !child->isInFlowPositioned())
213
    if (!child->isAnonymousBlock() || !child->isInFlowPositioned())
214
        return LayoutSize();
214
        return LayoutSize();
215
    LayoutSize offset;
215
    LayoutSize offset;
216
    RenderElement* p = toRenderBlock(child)->inlineElementContinuation();
216
    RenderElement* p = downcast<RenderBlock>(*child).inlineElementContinuation();
217
    while (p && p->isRenderInline()) {
217
    while (is<RenderInline>(p)) {
218
        if (p->isInFlowPositioned()) {
218
        if (p->isInFlowPositioned()) {
219
            RenderInline* renderInline = toRenderInline(p);
219
            RenderInline& renderInline = downcast<RenderInline>(*p);
220
            offset += renderInline->offsetForInFlowPosition();
220
            offset += renderInline.offsetForInFlowPosition();
221
        }
221
        }
222
        p = p->parent();
222
        p = p->parent();
223
    }
223
    }
Lines 2674-2680 void RenderBoxModelObject::moveChildTo(RenderBoxModelObject* toBoxModelObject, R a/Source/WebCore/rendering/RenderBoxModelObject.cpp_sec2
2674
{
2674
{
2675
    // We assume that callers have cleared their positioned objects list for child moves (!fullRemoveInsert) so the
2675
    // We assume that callers have cleared their positioned objects list for child moves (!fullRemoveInsert) so the
2676
    // positioned renderer maps don't become stale. It would be too slow to do the map lookup on each call.
2676
    // positioned renderer maps don't become stale. It would be too slow to do the map lookup on each call.
2677
    ASSERT(!fullRemoveInsert || !isRenderBlock() || !toRenderBlock(this)->hasPositionedObjects());
2677
    ASSERT(!fullRemoveInsert || !is<RenderBlock>(*this) || !downcast<RenderBlock>(*this).hasPositionedObjects());
2678
2678
2679
    ASSERT(this == child->parent());
2679
    ASSERT(this == child->parent());
2680
    ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2680
    ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
Lines 2695-2704 void RenderBoxModelObject::moveChildrenTo(RenderBoxModelObject* toBoxModelObject a/Source/WebCore/rendering/RenderBoxModelObject.cpp_sec3
2695
    // This condition is rarely hit since this function is usually called on
2695
    // This condition is rarely hit since this function is usually called on
2696
    // anonymous blocks which can no longer carry positioned objects (see r120761)
2696
    // anonymous blocks which can no longer carry positioned objects (see r120761)
2697
    // or when fullRemoveInsert is false.
2697
    // or when fullRemoveInsert is false.
2698
    if (fullRemoveInsert && isRenderBlock()) {
2698
    if (fullRemoveInsert && is<RenderBlock>(*this)) {
2699
        toRenderBlock(this)->removePositionedObjects(0);
2699
        downcast<RenderBlock>(*this).removePositionedObjects(nullptr);
2700
        if (isRenderBlockFlow())
2700
        if (is<RenderBlockFlow>(*this))
2701
            toRenderBlockFlow(this)->removeFloatingObjects(); 
2701
            downcast<RenderBlockFlow>(*this).removeFloatingObjects();
2702
    }
2702
    }
2703
2703
2704
    ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2704
    ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
- a/Source/WebCore/rendering/RenderElement.cpp -3 / +3 lines
Lines 762-768 void RenderElement::propagateStyleToAnonymousChildren(StylePropagationType propa a/Source/WebCore/rendering/RenderElement.cpp_sec1
762
        if (!elementChild.isAnonymous() || elementChild.style().styleType() != NOPSEUDO)
762
        if (!elementChild.isAnonymous() || elementChild.style().styleType() != NOPSEUDO)
763
            continue;
763
            continue;
764
764
765
        if (propagationType == PropagateToBlockChildrenOnly && !elementChild.isRenderBlock())
765
        if (propagationType == PropagateToBlockChildrenOnly && !is<RenderBlock>(elementChild))
766
            continue;
766
            continue;
767
767
768
#if ENABLE(FULLSCREEN_API)
768
#if ENABLE(FULLSCREEN_API)
Lines 771-777 void RenderElement::propagateStyleToAnonymousChildren(StylePropagationType propa a/Source/WebCore/rendering/RenderElement.cpp_sec2
771
#endif
771
#endif
772
772
773
        // RenderFlowThreads are updated through the RenderView::styleDidChange function.
773
        // RenderFlowThreads are updated through the RenderView::styleDidChange function.
774
        if (elementChild.isRenderFlowThread())
774
        if (is<RenderFlowThread>(elementChild))
775
            continue;
775
            continue;
776
776
777
        auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), elementChild.style().display());
777
        auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), elementChild.style().display());
Lines 784-790 void RenderElement::propagateStyleToAnonymousChildren(StylePropagationType propa a/Source/WebCore/rendering/RenderElement.cpp_sec3
784
784
785
        // Preserve the position style of anonymous block continuations as they can have relative or sticky position when
785
        // Preserve the position style of anonymous block continuations as they can have relative or sticky position when
786
        // they contain block descendants of relative or sticky positioned inlines.
786
        // they contain block descendants of relative or sticky positioned inlines.
787
        if (elementChild.isInFlowPositioned() && toRenderBlock(elementChild).isAnonymousBlockContinuation())
787
        if (elementChild.isInFlowPositioned() && downcast<RenderBlock>(elementChild).isAnonymousBlockContinuation())
788
            newStyle.get().setPosition(elementChild.style().position());
788
            newStyle.get().setPosition(elementChild.style().position());
789
789
790
        elementChild.setStyle(WTF::move(newStyle));
790
        elementChild.setStyle(WTF::move(newStyle));
- a/Source/WebCore/rendering/RenderFlowThread.cpp -6 / +6 lines
Lines 473-488 LayoutPoint RenderFlowThread::adjustedPositionRelativeToOffsetParent(const Rende a/Source/WebCore/rendering/RenderFlowThread.cpp_sec1
473
            
473
            
474
            // Get the logical top coordinate of the current object.
474
            // Get the logical top coordinate of the current object.
475
            LayoutUnit top = 0;
475
            LayoutUnit top = 0;
476
            if (boxModelObject.isRenderBlock())
476
            if (is<RenderBlock>(boxModelObject))
477
                top = toRenderBlock(boxModelObject).offsetFromLogicalTopOfFirstPage();
477
                top = downcast<RenderBlock>(boxModelObject).offsetFromLogicalTopOfFirstPage();
478
            else {
478
            else {
479
                if (boxModelObject.containingBlock())
479
                if (boxModelObject.containingBlock())
480
                    top = boxModelObject.containingBlock()->offsetFromLogicalTopOfFirstPage();
480
                    top = boxModelObject.containingBlock()->offsetFromLogicalTopOfFirstPage();
481
                
481
                
482
                if (boxModelObject.isBox())
482
                if (is<RenderBox>(boxModelObject))
483
                    top += toRenderBox(boxModelObject).topLeftLocation().y();
483
                    top += downcast<RenderBox>(boxModelObject).topLeftLocation().y();
484
                else if (boxModelObject.isRenderInline())
484
                else if (is<RenderInline>(boxModelObject))
485
                    top -= toRenderInline(boxModelObject).borderTop();
485
                    top -= downcast<RenderInline>(boxModelObject).borderTop();
486
            }
486
            }
487
            
487
            
488
            // Get the logical top of the region this object starts in
488
            // Get the logical top of the region this object starts in
- a/Source/WebCore/rendering/RenderFullScreen.cpp -2 / +2 lines
Lines 149-162 void RenderFullScreen::unwrapRenderer(bool& requiresRenderTreeRebuild) a/Source/WebCore/rendering/RenderFullScreen.cpp_sec1
149
        if (child != lastChild())
149
        if (child != lastChild())
150
            requiresRenderTreeRebuild = true;
150
            requiresRenderTreeRebuild = true;
151
        else if (child && child->isAnonymousBlock()) {
151
        else if (child && child->isAnonymousBlock()) {
152
            auto& anonymousBlock = toRenderBlock(*child);
152
            auto& anonymousBlock = downcast<RenderBlock>(*child);
153
            if (anonymousBlock.firstChild() != anonymousBlock.lastChild())
153
            if (anonymousBlock.firstChild() != anonymousBlock.lastChild())
154
                requiresRenderTreeRebuild = true;
154
                requiresRenderTreeRebuild = true;
155
        }
155
        }
156
156
157
        while ((child = firstChild())) {
157
        while ((child = firstChild())) {
158
            if (child->isAnonymousBlock() && !requiresRenderTreeRebuild) {
158
            if (child->isAnonymousBlock() && !requiresRenderTreeRebuild) {
159
                if (auto* nonAnonymousChild = toRenderBlock(*child).firstChild())
159
                if (auto* nonAnonymousChild = downcast<RenderBlock>(*child).firstChild())
160
                    child = nonAnonymousChild;
160
                    child = nonAnonymousChild;
161
                else {
161
                else {
162
                    child->removeFromParent();
162
                    child->removeFromParent();
- a/Source/WebCore/rendering/RenderInline.cpp -31 / +31 lines
Lines 121-130 RenderInline* RenderInline::inlineElementContinuation() const a/Source/WebCore/rendering/RenderInline.cpp_sec1
121
    if (!continuation)
121
    if (!continuation)
122
        return nullptr;
122
        return nullptr;
123
123
124
    if (continuation->isRenderInline())
124
    if (is<RenderInline>(*continuation))
125
        return toRenderInline(continuation);
125
        return downcast<RenderInline>(continuation);
126
126
127
    return continuation->isRenderBlock() ? toRenderBlock(continuation)->inlineElementContinuation() : nullptr;
127
    return is<RenderBlock>(*continuation) ? downcast<RenderBlock>(*continuation).inlineElementContinuation() : nullptr;
128
}
128
}
129
129
130
void RenderInline::updateFromStyle()
130
void RenderInline::updateFromStyle()
Lines 152-172 static void updateStyleOfAnonymousBlockContinuations(RenderBox* box, const Rende a/Source/WebCore/rendering/RenderInline.cpp_sec2
152
        if (box->style().position() == newStyle->position())
152
        if (box->style().position() == newStyle->position())
153
            continue;
153
            continue;
154
        
154
        
155
        if (!box->isRenderBlock())
155
        if (!is<RenderBlock>(*box))
156
            continue;
156
            continue;
157
157
158
        RenderBlock* block = toRenderBlock(box);
158
        RenderBlock& block = downcast<RenderBlock>(*box);
159
        if (!block->isAnonymousBlockContinuation())
159
        if (!block.isAnonymousBlockContinuation())
160
            continue;
160
            continue;
161
        
161
        
162
        // If we are no longer in-flow positioned but our descendant block(s) still have an in-flow positioned ancestor then
162
        // If we are no longer in-flow positioned but our descendant block(s) still have an in-flow positioned ancestor then
163
        // their containing anonymous block should keep its in-flow positioning. 
163
        // their containing anonymous block should keep its in-flow positioning. 
164
        RenderInline* cont = block->inlineElementContinuation();
164
        RenderInline* continuation = block.inlineElementContinuation();
165
        if (oldStyle->hasInFlowPosition() && inFlowPositionedInlineAncestor(cont))
165
        if (oldStyle->hasInFlowPosition() && inFlowPositionedInlineAncestor(continuation))
166
            continue;
166
            continue;
167
        auto blockStyle = RenderStyle::createAnonymousStyleWithDisplay(&block->style(), BLOCK);
167
        auto blockStyle = RenderStyle::createAnonymousStyleWithDisplay(&block.style(), BLOCK);
168
        blockStyle.get().setPosition(newStyle->position());
168
        blockStyle.get().setPosition(newStyle->position());
169
        block->setStyle(WTF::move(blockStyle));
169
        block.setStyle(WTF::move(blockStyle));
170
    }
170
    }
171
}
171
}
172
172
Lines 196-202 void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt a/Source/WebCore/rendering/RenderInline.cpp_sec3
196
        // If any descendant blocks exist then they will be in the next anonymous block and its siblings.
196
        // If any descendant blocks exist then they will be in the next anonymous block and its siblings.
197
        RenderObject* block = containingBlock()->nextSibling();
197
        RenderObject* block = containingBlock()->nextSibling();
198
        ASSERT(block && block->isAnonymousBlock());
198
        ASSERT(block && block->isAnonymousBlock());
199
        updateStyleOfAnonymousBlockContinuations(toRenderBlock(block), &newStyle, oldStyle);
199
        updateStyleOfAnonymousBlockContinuations(downcast<RenderBlock>(block), &newStyle, oldStyle);
200
    }
200
    }
201
201
202
    if (!alwaysCreateLineBoxes()) {
202
    if (!alwaysCreateLineBoxes()) {
Lines 277-285 void RenderInline::addChild(RenderObject* newChild, RenderObject* beforeChild) a/Source/WebCore/rendering/RenderInline.cpp_sec4
277
277
278
static RenderBoxModelObject* nextContinuation(RenderObject* renderer)
278
static RenderBoxModelObject* nextContinuation(RenderObject* renderer)
279
{
279
{
280
    if (renderer->isInline() && !renderer->isReplaced())
280
    if (is<RenderInline>(*renderer) && !renderer->isReplaced())
281
        return toRenderInline(renderer)->continuation();
281
        return downcast<RenderInline>(*renderer).continuation();
282
    return toRenderBlock(renderer)->inlineElementContinuation();
282
    return downcast<RenderBlock>(*renderer).inlineElementContinuation();
283
}
283
}
284
284
285
RenderBoxModelObject* RenderInline::continuationBefore(RenderObject* beforeChild)
285
RenderBoxModelObject* RenderInline::continuationBefore(RenderObject* beforeChild)
Lines 443-449 void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, a/Source/WebCore/rendering/RenderInline.cpp_sec5
443
void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
443
void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
444
                             RenderObject* newChild, RenderBoxModelObject* oldCont)
444
                             RenderObject* newChild, RenderBoxModelObject* oldCont)
445
{
445
{
446
    RenderBlock* pre = 0;
446
    RenderBlock* pre = nullptr;
447
    RenderBlock* block = containingBlock();
447
    RenderBlock* block = containingBlock();
448
    
448
    
449
    // Delete our line boxes before we do the inline split into continuations.
449
    // Delete our line boxes before we do the inline split into continuations.
Lines 453-464 void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox a/Source/WebCore/rendering/RenderInline.cpp_sec6
453
    if (block->isAnonymousBlock() && (!block->parent() || !block->parent()->createsAnonymousWrapper())) {
453
    if (block->isAnonymousBlock() && (!block->parent() || !block->parent()->createsAnonymousWrapper())) {
454
        // We can reuse this block and make it the preBlock of the next continuation.
454
        // We can reuse this block and make it the preBlock of the next continuation.
455
        pre = block;
455
        pre = block;
456
        pre->removePositionedObjects(0);
456
        pre->removePositionedObjects(nullptr);
457
        // FIXME-BLOCKFLOW: The enclosing method should likely be switched over
457
        // FIXME-BLOCKFLOW: The enclosing method should likely be switched over
458
        // to only work on RenderBlockFlow, in which case this conversion can be
458
        // to only work on RenderBlockFlow, in which case this conversion can be
459
        // removed.
459
        // removed.
460
        if (pre->isRenderBlockFlow())
460
        if (is<RenderBlockFlow>(*pre))
461
            toRenderBlockFlow(pre)->removeFloatingObjects();
461
            downcast<RenderBlockFlow>(*pre).removeFloatingObjects();
462
        block = block->containingBlock();
462
        block = block->containingBlock();
463
    } else {
463
    } else {
464
        // No anonymous block available for use.  Make one.
464
        // No anonymous block available for use.  Make one.
Lines 466-478 void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox a/Source/WebCore/rendering/RenderInline.cpp_sec7
466
        madeNewBeforeBlock = true;
466
        madeNewBeforeBlock = true;
467
    }
467
    }
468
468
469
    RenderBlock* post = toRenderBlock(pre->createAnonymousBoxWithSameTypeAs(block));
469
    RenderBlock& post = downcast<RenderBlock>(*pre->createAnonymousBoxWithSameTypeAs(block));
470
470
471
    RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nextSibling();
471
    RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nextSibling();
472
    if (madeNewBeforeBlock)
472
    if (madeNewBeforeBlock)
473
        block->insertChildInternal(pre, boxFirst, NotifyChildren);
473
        block->insertChildInternal(pre, boxFirst, NotifyChildren);
474
    block->insertChildInternal(newBlockBox, boxFirst, NotifyChildren);
474
    block->insertChildInternal(newBlockBox, boxFirst, NotifyChildren);
475
    block->insertChildInternal(post, boxFirst, NotifyChildren);
475
    block->insertChildInternal(&post, boxFirst, NotifyChildren);
476
    block->setChildrenInline(false);
476
    block->setChildrenInline(false);
477
    
477
    
478
    if (madeNewBeforeBlock) {
478
    if (madeNewBeforeBlock) {
Lines 486-492 void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox a/Source/WebCore/rendering/RenderInline.cpp_sec8
486
        }
486
        }
487
    }
487
    }
488
488
489
    splitInlines(pre, post, newBlockBox, beforeChild, oldCont);
489
    splitInlines(pre, &post, newBlockBox, beforeChild, oldCont);
490
490
491
    // We already know the newBlockBox isn't going to contain inline kids, so avoid wasting
491
    // We already know the newBlockBox isn't going to contain inline kids, so avoid wasting
492
    // time in makeChildrenNonInline by just setting this explicitly up front.
492
    // time in makeChildrenNonInline by just setting this explicitly up front.
Lines 502-508 void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox a/Source/WebCore/rendering/RenderInline.cpp_sec9
502
    // make new line boxes instead of leaving the old line boxes around.
502
    // make new line boxes instead of leaving the old line boxes around.
503
    pre->setNeedsLayoutAndPrefWidthsRecalc();
503
    pre->setNeedsLayoutAndPrefWidthsRecalc();
504
    block->setNeedsLayoutAndPrefWidthsRecalc();
504
    block->setNeedsLayoutAndPrefWidthsRecalc();
505
    post->setNeedsLayoutAndPrefWidthsRecalc();
505
    post.setNeedsLayoutAndPrefWidthsRecalc();
506
}
506
}
507
507
508
void RenderInline::addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild)
508
void RenderInline::addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild)
Lines 853-873 bool RenderInline::hitTestCulledInline(const HitTestRequest& request, HitTestRes a/Source/WebCore/rendering/RenderInline.cpp_sec10
853
VisiblePosition RenderInline::positionForPoint(const LayoutPoint& point, const RenderRegion* region)
853
VisiblePosition RenderInline::positionForPoint(const LayoutPoint& point, const RenderRegion* region)
854
{
854
{
855
    // FIXME: Does not deal with relative or sticky positioned inlines (should it?)
855
    // FIXME: Does not deal with relative or sticky positioned inlines (should it?)
856
    RenderBlock* cb = containingBlock();
856
    RenderBlock& containingBlock = *this->containingBlock();
857
    if (firstLineBox()) {
857
    if (firstLineBox()) {
858
        // This inline actually has a line box.  We must have clicked in the border/padding of one of these boxes.  We
858
        // This inline actually has a line box.  We must have clicked in the border/padding of one of these boxes.  We
859
        // should try to find a result by asking our containing block.
859
        // should try to find a result by asking our containing block.
860
        return cb->positionForPoint(point, region);
860
        return containingBlock.positionForPoint(point, region);
861
    }
861
    }
862
862
863
    // Translate the coords from the pre-anonymous block to the post-anonymous block.
863
    // Translate the coords from the pre-anonymous block to the post-anonymous block.
864
    LayoutPoint parentBlockPoint = cb->location() + point;  
864
    LayoutPoint parentBlockPoint = containingBlock.location() + point;
865
    RenderBoxModelObject* c = continuation();
865
    RenderBoxModelObject* continuation = this->continuation();
866
    while (c) {
866
    while (continuation) {
867
        RenderBox* contBlock = c->isInline() ? c->containingBlock() : toRenderBlock(c);
867
        RenderBlock* currentBlock = continuation->isInline() ? continuation->containingBlock() : downcast<RenderBlock>(continuation);
868
        if (c->isInline() || c->firstChild())
868
        if (continuation->isInline() || continuation->firstChild())
869
            return c->positionForPoint(parentBlockPoint - contBlock->locationOffset(), region);
869
            return continuation->positionForPoint(parentBlockPoint - currentBlock->locationOffset(), region);
870
        c = toRenderBlock(c)->inlineElementContinuation();
870
        continuation = downcast<RenderBlock>(*continuation).inlineElementContinuation();
871
    }
871
    }
872
    
872
    
873
    return RenderBoxModelObject::positionForPoint(point, region);
873
    return RenderBoxModelObject::positionForPoint(point, region);
- a/Source/WebCore/rendering/RenderLayer.cpp -3 / +3 lines
Lines 3298-3305 void RenderLayer::updateScrollbarsAfterLayout() a/Source/WebCore/rendering/RenderLayer.cpp_sec1
3298
                // Our proprietary overflow: overlay value doesn't trigger a layout.
3298
                // Our proprietary overflow: overlay value doesn't trigger a layout.
3299
                m_inOverflowRelayout = true;
3299
                m_inOverflowRelayout = true;
3300
                renderer().setNeedsLayout(MarkOnlyThis);
3300
                renderer().setNeedsLayout(MarkOnlyThis);
3301
                if (renderer().isRenderBlock()) {
3301
                if (is<RenderBlock>(renderer())) {
3302
                    RenderBlock& block = toRenderBlock(renderer());
3302
                    RenderBlock& block = downcast<RenderBlock>(renderer());
3303
                    block.scrollbarsChanged(autoHorizontalScrollBarChanged, autoVerticalScrollBarChanged);
3303
                    block.scrollbarsChanged(autoHorizontalScrollBarChanged, autoVerticalScrollBarChanged);
3304
                    block.layoutBlock(true);
3304
                    block.layoutBlock(true);
3305
                } else
3305
                } else
Lines 5417-5423 void RenderLayer::calculateRects(const ClipRectsContext& clipRectsContext, const a/Source/WebCore/rendering/RenderLayer.cpp_sec2
5417
            else
5417
            else
5418
                layerBoundsWithVisualOverflow.moveBy(LayoutPoint(flowThread->width(), 0));
5418
                layerBoundsWithVisualOverflow.moveBy(LayoutPoint(flowThread->width(), 0));
5419
        } else {
5419
        } else {
5420
            RenderBlock* rendererContainingBlock = boxModelObject.enclosingBox().isRenderBlock() ? toRenderBlock(&boxModelObject.enclosingBox()) : 0;
5420
            RenderBlock* rendererContainingBlock = is<RenderBlock>(boxModelObject.enclosingBox()) ? &downcast<RenderBlock>(boxModelObject.enclosingBox()) : nullptr;
5421
            if (rendererContainingBlock)
5421
            if (rendererContainingBlock)
5422
                rendererContainingBlock->flipForWritingMode(layerBoundsWithVisualOverflow);
5422
                rendererContainingBlock->flipForWritingMode(layerBoundsWithVisualOverflow);
5423
        }
5423
        }
- a/Source/WebCore/rendering/RenderListItem.cpp -10 / +11 lines
Lines 27-34 a/Source/WebCore/rendering/RenderListItem.cpp_sec1
27
#include "ElementTraversal.h"
27
#include "ElementTraversal.h"
28
#include "HTMLNames.h"
28
#include "HTMLNames.h"
29
#include "HTMLOListElement.h"
29
#include "HTMLOListElement.h"
30
#include "HTMLUListElement.h"
30
#include "InlineElementBox.h"
31
#include "InlineElementBox.h"
31
#include "PseudoElement.h"
32
#include "PseudoElement.h"
33
#include "RenderInline.h"
32
#include "RenderListMarker.h"
34
#include "RenderListMarker.h"
33
#include "RenderMultiColumnFlowThread.h"
35
#include "RenderMultiColumnFlowThread.h"
34
#include "RenderView.h"
36
#include "RenderView.h"
Lines 227-251 static RenderBlock* getParentOfFirstLineBox(RenderBlock* curr, RenderObject* mar a/Source/WebCore/rendering/RenderListItem.cpp_sec2
227
        if (currChild == marker)
229
        if (currChild == marker)
228
            continue;
230
            continue;
229
231
230
        if (currChild->isInline() && (!currChild->isRenderInline() || curr->generatesLineBoxesForInlineChild(currChild)))
232
        if (currChild->isInline() && (!is<RenderInline>(*currChild) || curr->generatesLineBoxesForInlineChild(currChild)))
231
            return curr;
233
            return curr;
232
234
233
        if (currChild->isFloating() || currChild->isOutOfFlowPositioned())
235
        if (currChild->isFloating() || currChild->isOutOfFlowPositioned())
234
            continue;
236
            continue;
235
237
236
        if (currChild->isTable() || !currChild->isRenderBlock() || (currChild->isBox() && toRenderBox(currChild)->isWritingModeRoot()))
238
        if (currChild->isTable() || !is<RenderBlock>(*currChild) || (is<RenderBox>(*currChild) && downcast<RenderBox>(*currChild).isWritingModeRoot()))
237
            break;
239
            break;
238
240
239
        if (curr->isListItem() && inQuirksMode && currChild->node() &&
241
        if (curr->isListItem() && inQuirksMode && currChild->node() &&
240
            (currChild->node()->hasTagName(ulTag)|| currChild->node()->hasTagName(olTag)))
242
            (is<HTMLUListElement>(*currChild->node()) || is<HTMLOListElement>(*currChild->node())))
241
            break;
243
            break;
242
244
243
        RenderBlock* lineBox = getParentOfFirstLineBox(toRenderBlock(currChild), marker);
245
        if (RenderBlock* lineBox = getParentOfFirstLineBox(downcast<RenderBlock>(currChild), marker))
244
        if (lineBox)
245
            return lineBox;
246
            return lineBox;
246
    }
247
    }
247
248
248
    return 0;
249
    return nullptr;
249
}
250
}
250
251
251
void RenderListItem::updateValue()
252
void RenderListItem::updateValue()
Lines 294-300 void RenderListItem::insertOrMoveMarkerRendererIfNeeded() a/Source/WebCore/rendering/RenderListItem.cpp_sec3
294
        newParent->addChild(m_marker.get(), firstNonMarkerChild(newParent));
295
        newParent->addChild(m_marker.get(), firstNonMarkerChild(newParent));
295
        m_marker->updateMarginsAndContent();
296
        m_marker->updateMarginsAndContent();
296
        // If current parent is an anonymous block that has lost all its children, destroy it.
297
        // If current parent is an anonymous block that has lost all its children, destroy it.
297
        if (currentParent && currentParent->isAnonymousBlock() && !currentParent->firstChild() && !toRenderBlock(currentParent)->continuation())
298
        if (currentParent && currentParent->isAnonymousBlock() && !currentParent->firstChild() && !downcast<RenderBlock>(*currentParent).continuation())
298
            currentParent->destroy();
299
            currentParent->destroy();
299
    }
300
    }
300
301
Lines 406-416 void RenderListItem::positionListMarker() a/Source/WebCore/rendering/RenderListItem.cpp_sec4
406
                o = o->parentBox();
407
                o = o->parentBox();
407
                if (o->hasOverflowClip())
408
                if (o->hasOverflowClip())
408
                    propagateVisualOverflow = false;
409
                    propagateVisualOverflow = false;
409
                if (o->isRenderBlock()) {
410
                if (is<RenderBlock>(*o)) {
410
                    if (propagateVisualOverflow)
411
                    if (propagateVisualOverflow)
411
                        toRenderBlock(o)->addVisualOverflow(markerRect);
412
                        downcast<RenderBlock>(*o).addVisualOverflow(markerRect);
412
                    if (propagateLayoutOverflow)
413
                    if (propagateLayoutOverflow)
413
                        toRenderBlock(o)->addLayoutOverflow(markerRect);
414
                        downcast<RenderBlock>(*o).addLayoutOverflow(markerRect);
414
                }
415
                }
415
                if (o->hasOverflowClip())
416
                if (o->hasOverflowClip())
416
                    propagateLayoutOverflow = false;
417
                    propagateLayoutOverflow = false;
- a/Source/WebCore/rendering/RenderNamedFlowFragment.cpp -1 / +1 lines
Lines 184-190 LayoutUnit RenderNamedFlowFragment::maxPageLogicalHeight() const a/Source/WebCore/rendering/RenderNamedFlowFragment.cpp_sec1
184
    ASSERT(parent());
184
    ASSERT(parent());
185
185
186
    const RenderStyle& styleToUse = parent()->style();
186
    const RenderStyle& styleToUse = parent()->style();
187
    return styleToUse.logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : toRenderBlock(parent())->computeReplacedLogicalHeightUsing(styleToUse.logicalMaxHeight());
187
    return styleToUse.logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : downcast<RenderBlock>(*parent()).computeReplacedLogicalHeightUsing(styleToUse.logicalMaxHeight());
188
}
188
}
189
189
190
LayoutRect RenderNamedFlowFragment::flowThreadPortionRectForClipping(bool isFirstRegionInRange, bool isLastRegionInRange) const
190
LayoutRect RenderNamedFlowFragment::flowThreadPortionRectForClipping(bool isFirstRegionInRange, bool isLastRegionInRange) const
- a/Source/WebCore/rendering/RenderObject.cpp -42 / +41 lines
Lines 399-413 RenderObject* RenderObject::traverseNext(const RenderObject* stayWithin, Travers a/Source/WebCore/rendering/RenderObject.cpp_sec1
399
    return 0;
399
    return 0;
400
}
400
}
401
401
402
static RenderObject::BlockContentHeightType includeNonFixedHeight(const RenderObject* render)
402
static RenderObject::BlockContentHeightType includeNonFixedHeight(const RenderObject* renderer)
403
{
403
{
404
    const RenderStyle& style = render->style();
404
    const RenderStyle& style = renderer->style();
405
    if (style.height().type() == Fixed) {
405
    if (style.height().type() == Fixed) {
406
        if (render->isRenderBlock()) {
406
        if (is<RenderBlock>(*renderer)) {
407
            const RenderBlock* block = toRenderBlock(render);
408
            // For fixed height styles, if the overflow size of the element spills out of the specified
407
            // For fixed height styles, if the overflow size of the element spills out of the specified
409
            // height, assume we can apply text auto-sizing.
408
            // height, assume we can apply text auto-sizing.
410
            if (style.overflowY() == OVISIBLE && style.height().value() < block->layoutOverflowRect().maxY())
409
            if (style.overflowY() == OVISIBLE
410
                && style.height().value() < downcast<RenderBlock>(renderer).layoutOverflowRect().maxY())
411
                return RenderObject::OverflowHeight;
411
                return RenderObject::OverflowHeight;
412
        }
412
        }
413
        return RenderObject::FixedHeight;
413
        return RenderObject::FixedHeight;
Lines 672-679 void RenderObject::checkBlockPositionedObjectsNeedLayout() a/Source/WebCore/rendering/RenderObject.cpp_sec2
672
{
672
{
673
    ASSERT(!needsLayout());
673
    ASSERT(!needsLayout());
674
674
675
    if (isRenderBlock())
675
    if (is<RenderBlock>(*this))
676
        toRenderBlock(this)->checkPositionedObjectsNeedLayout();
676
        downcast<RenderBlock>(*this).checkPositionedObjectsNeedLayout();
677
}
677
}
678
#endif
678
#endif
679
679
Lines 720-741 void RenderObject::setLayerNeedsFullRepaintForPositionedMovementLayout() a/Source/WebCore/rendering/RenderObject.cpp_sec3
720
720
721
RenderBlock* RenderObject::containingBlock() const
721
RenderBlock* RenderObject::containingBlock() const
722
{
722
{
723
    auto o = parent();
723
    auto parent = this->parent();
724
    if (!o && isRenderScrollbarPart())
724
    if (!parent && is<RenderScrollbarPart>(*this))
725
        o = toRenderScrollbarPart(this)->rendererOwningScrollbar();
725
        parent = downcast<RenderScrollbarPart>(*this).rendererOwningScrollbar();
726
726
727
    const RenderStyle& style = this->style();
727
    const RenderStyle& style = this->style();
728
    if (!isText() && style.position() == FixedPosition)
728
    if (!is<RenderText>(*this) && style.position() == FixedPosition)
729
        o = containingBlockForFixedPosition(o);
729
        parent = containingBlockForFixedPosition(parent);
730
    else if (!isText() && style.position() == AbsolutePosition)
730
    else if (!is<RenderText>(*this) && style.position() == AbsolutePosition)
731
        o = containingBlockForAbsolutePosition(o);
731
        parent = containingBlockForAbsolutePosition(parent);
732
    else
732
    else
733
        o = containingBlockForObjectInFlow(o);
733
        parent = containingBlockForObjectInFlow(parent);
734
734
735
    if (!o || !o->isRenderBlock())
735
    if (!is<RenderBlock>(parent))
736
        return 0; // This can still happen in case of an orphaned tree
736
        return nullptr; // This can still happen in case of an orphaned tree
737
737
738
    return toRenderBlock(o);
738
    return downcast<RenderBlock>(parent);
739
}
739
}
740
740
741
void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, float x1, float y1, float x2, float y2,
741
void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, float x1, float y1, float x2, float y2,
Lines 1679-1688 void RenderObject::handleDynamicFloatPositionChange() a/Source/WebCore/rendering/RenderObject.cpp_sec4
1679
    setInline(style().isDisplayInlineType());
1679
    setInline(style().isDisplayInlineType());
1680
    if (isInline() != parent()->childrenInline()) {
1680
    if (isInline() != parent()->childrenInline()) {
1681
        if (!isInline())
1681
        if (!isInline())
1682
            toRenderBoxModelObject(parent())->childBecameNonInline(this);
1682
            downcast<RenderBoxModelObject>(*parent()).childBecameNonInline(this);
1683
        else {
1683
        else {
1684
            // An anonymous block must be made to wrap this inline.
1684
            // An anonymous block must be made to wrap this inline.
1685
            RenderBlock* block = toRenderBlock(parent())->createAnonymousBlock();
1685
            RenderBlock* block = downcast<RenderBlock>(*parent()).createAnonymousBlock();
1686
            parent()->insertChildInternal(block, this, RenderElement::NotifyChildren);
1686
            parent()->insertChildInternal(block, this, RenderElement::NotifyChildren);
1687
            parent()->removeChildInternal(*this, RenderElement::NotifyChildren);
1687
            parent()->removeChildInternal(*this, RenderElement::NotifyChildren);
1688
            block->insertChildInternal(this, nullptr, RenderElement::NotifyChildren);
1688
            block->insertChildInternal(this, nullptr, RenderElement::NotifyChildren);
Lines 1692-1699 void RenderObject::handleDynamicFloatPositionChange() a/Source/WebCore/rendering/RenderObject.cpp_sec5
1692
1692
1693
void RenderObject::removeAnonymousWrappersForInlinesIfNecessary()
1693
void RenderObject::removeAnonymousWrappersForInlinesIfNecessary()
1694
{
1694
{
1695
    RenderBlock* parentBlock = toRenderBlock(parent());
1695
    RenderBlock& parentBlock = downcast<RenderBlock>(*parent());
1696
    if (!parentBlock->canCollapseAnonymousBlockChild())
1696
    if (!parentBlock.canCollapseAnonymousBlockChild())
1697
        return;
1697
        return;
1698
1698
1699
    // We have changed to floated or out-of-flow positioning so maybe all our parent's
1699
    // We have changed to floated or out-of-flow positioning so maybe all our parent's
Lines 1701-1719 void RenderObject::removeAnonymousWrappersForInlinesIfNecessary() a/Source/WebCore/rendering/RenderObject.cpp_sec6
1701
    // otherwise we can proceed to stripping solitary anonymous wrappers from the inlines.
1701
    // otherwise we can proceed to stripping solitary anonymous wrappers from the inlines.
1702
    // FIXME: We should also handle split inlines here - we exclude them at the moment by returning
1702
    // FIXME: We should also handle split inlines here - we exclude them at the moment by returning
1703
    // if we find a continuation.
1703
    // if we find a continuation.
1704
    RenderObject* curr = parent()->firstChild();
1704
    RenderObject* current = parent()->firstChild();
1705
    while (curr && ((curr->isAnonymousBlock() && !toRenderBlock(curr)->isAnonymousBlockContinuation()) || curr->style().isFloating() || curr->style().hasOutOfFlowPosition()))
1705
    while (current && ((current->isAnonymousBlock() && !downcast<RenderBlock>(*current).isAnonymousBlockContinuation()) || current->style().isFloating() || current->style().hasOutOfFlowPosition()))
1706
        curr = curr->nextSibling();
1706
        current = current->nextSibling();
1707
1707
1708
    if (curr)
1708
    if (current)
1709
        return;
1709
        return;
1710
1710
1711
    curr = parent()->firstChild();
1711
    RenderObject* next;
1712
    while (curr) {
1712
    for (current = parent()->firstChild(); current; current = next) {
1713
        RenderObject* next = curr->nextSibling();
1713
        next = current->nextSibling();
1714
        if (curr->isAnonymousBlock())
1714
        if (current->isAnonymousBlock())
1715
            parentBlock->collapseAnonymousBoxChild(parentBlock, toRenderBlock(curr));
1715
            parentBlock.collapseAnonymousBoxChild(parentBlock, downcast<RenderBlock>(current));
1716
        curr = next;
1717
    }
1716
    }
1718
}
1717
}
1719
1718
Lines 2270-2281 static Color decorationColor(RenderStyle* style) a/Source/WebCore/rendering/RenderObject.cpp_sec7
2270
void RenderObject::getTextDecorationColors(int decorations, Color& underline, Color& overline,
2269
void RenderObject::getTextDecorationColors(int decorations, Color& underline, Color& overline,
2271
                                           Color& linethrough, bool quirksMode, bool firstlineStyle)
2270
                                           Color& linethrough, bool quirksMode, bool firstlineStyle)
2272
{
2271
{
2273
    RenderObject* curr = this;
2272
    RenderObject* current = this;
2274
    RenderStyle* styleToUse = 0;
2273
    RenderStyle* styleToUse = nullptr;
2275
    TextDecoration currDecs = TextDecorationNone;
2274
    TextDecoration currDecs = TextDecorationNone;
2276
    Color resultColor;
2275
    Color resultColor;
2277
    do {
2276
    do {
2278
        styleToUse = firstlineStyle ? &curr->firstLineStyle() : &curr->style();
2277
        styleToUse = firstlineStyle ? &current->firstLineStyle() : &current->style();
2279
        currDecs = styleToUse->textDecoration();
2278
        currDecs = styleToUse->textDecoration();
2280
        resultColor = decorationColor(styleToUse);
2279
        resultColor = decorationColor(styleToUse);
2281
        // Parameter 'decorations' is cast as an int to enable the bitwise operations below.
2280
        // Parameter 'decorations' is cast as an int to enable the bitwise operations below.
Lines 2293-2308 void RenderObject::getTextDecorationColors(int decorations, Color& underline, Co a/Source/WebCore/rendering/RenderObject.cpp_sec8
2293
                linethrough = resultColor;
2292
                linethrough = resultColor;
2294
            }
2293
            }
2295
        }
2294
        }
2296
        if (curr->isRubyText())
2295
        if (current->isRubyText())
2297
            return;
2296
            return;
2298
        curr = curr->parent();
2297
        current = current->parent();
2299
        if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuation())
2298
        if (current && current->isAnonymousBlock() && downcast<RenderBlock>(*current).continuation())
2300
            curr = toRenderBlock(curr)->continuation();
2299
            current = downcast<RenderBlock>(*current).continuation();
2301
    } while (curr && decorations && (!quirksMode || !curr->node() || (!is<HTMLAnchorElement>(*curr->node()) && !curr->node()->hasTagName(fontTag))));
2300
    } while (current && decorations && (!quirksMode || !current->node() || (!is<HTMLAnchorElement>(*current->node()) && !current->node()->hasTagName(fontTag))));
2302
2301
2303
    // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
2302
    // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
2304
    if (decorations && curr) {
2303
    if (decorations && current) {
2305
        styleToUse = firstlineStyle ? &curr->firstLineStyle() : &curr->style();
2304
        styleToUse = firstlineStyle ? &current->firstLineStyle() : &current->style();
2306
        resultColor = decorationColor(styleToUse);
2305
        resultColor = decorationColor(styleToUse);
2307
        if (decorations & TextDecorationUnderline)
2306
        if (decorations & TextDecorationUnderline)
2308
            underline = resultColor;
2307
            underline = resultColor;
- a/Source/WebCore/rendering/RenderRuby.cpp -2 / +2 lines
Lines 75-87 static inline bool isRubyAfterBlock(const RenderObject* object) a/Source/WebCore/rendering/RenderRuby.cpp_sec1
75
static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby)
75
static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby)
76
{
76
{
77
    RenderObject* child = ruby->firstChild();
77
    RenderObject* child = ruby->firstChild();
78
    return isRubyBeforeBlock(child) ? toRenderBlock(child) : 0;
78
    return isRubyBeforeBlock(child) ? downcast<RenderBlock>(child) : nullptr;
79
}
79
}
80
80
81
static inline RenderBlock* rubyAfterBlock(const RenderElement* ruby)
81
static inline RenderBlock* rubyAfterBlock(const RenderElement* ruby)
82
{
82
{
83
    RenderObject* child = ruby->lastChild();
83
    RenderObject* child = ruby->lastChild();
84
    return isRubyAfterBlock(child) ? toRenderBlock(child) : 0;
84
    return isRubyAfterBlock(child) ? downcast<RenderBlock>(child) : nullptr;
85
}
85
}
86
86
87
static RenderBlock* createAnonymousRubyInlineBlock(RenderObject& ruby)
87
static RenderBlock* createAnonymousRubyInlineBlock(RenderObject& ruby)
- a/Source/WebCore/rendering/RenderRubyBase.cpp -3 / +3 lines
Lines 92-98 void RenderRubyBase::moveInlineChildren(RenderRubyBase* toBase, RenderObject* be a/Source/WebCore/rendering/RenderRubyBase.cpp_sec1
92
        // If toBase has a suitable block, we re-use it, otherwise create a new one.
92
        // If toBase has a suitable block, we re-use it, otherwise create a new one.
93
        RenderObject* lastChild = toBase->lastChild();
93
        RenderObject* lastChild = toBase->lastChild();
94
        if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInline())
94
        if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInline())
95
            toBlock = toRenderBlock(lastChild);
95
            toBlock = downcast<RenderBlock>(lastChild);
96
        else {
96
        else {
97
            toBlock = toBase->createAnonymousBlock();
97
            toBlock = toBase->createAnonymousBlock();
98
            toBase->insertChildInternal(toBlock, nullptr, NotifyChildren);
98
            toBase->insertChildInternal(toBlock, nullptr, NotifyChildren);
Lines 118-125 void RenderRubyBase::moveBlockChildren(RenderRubyBase* toBase, RenderObject* bef a/Source/WebCore/rendering/RenderRubyBase.cpp_sec2
118
    RenderObject* lastChildThere = toBase->lastChild();
118
    RenderObject* lastChildThere = toBase->lastChild();
119
    if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline() 
119
    if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline() 
120
            && lastChildThere && lastChildThere->isAnonymousBlock() && lastChildThere->childrenInline()) {            
120
            && lastChildThere && lastChildThere->isAnonymousBlock() && lastChildThere->childrenInline()) {            
121
        RenderBlock* anonBlockHere = toRenderBlock(firstChildHere);
121
        RenderBlock* anonBlockHere = downcast<RenderBlock>(firstChildHere);
122
        RenderBlock* anonBlockThere = toRenderBlock(lastChildThere);
122
        RenderBlock* anonBlockThere = downcast<RenderBlock>(lastChildThere);
123
        anonBlockHere->moveAllChildrenTo(anonBlockThere, true);
123
        anonBlockHere->moveAllChildrenTo(anonBlockThere, true);
124
        anonBlockHere->deleteLines();
124
        anonBlockHere->deleteLines();
125
        anonBlockHere->destroy();
125
        anonBlockHere->destroy();
- a/Source/WebCore/rendering/RenderThemeMac.mm -6 / +4 lines
Lines 1821-1835 bool RenderThemeMac::paintSearchFieldResultsButton(const RenderObject& o, const a/Source/WebCore/rendering/RenderThemeMac.mm_sec1
1821
    return false;
1821
    return false;
1822
}
1822
}
1823
1823
1824
bool RenderThemeMac::paintSnapshottedPluginOverlay(const RenderObject& o, const PaintInfo& paintInfo, const IntRect&)
1824
bool RenderThemeMac::paintSnapshottedPluginOverlay(const RenderObject& renderer, const PaintInfo& paintInfo, const IntRect&)
1825
{
1825
{
1826
    if (paintInfo.phase != PaintPhaseBlockBackground)
1826
    if (paintInfo.phase != PaintPhaseBlockBackground)
1827
        return true;
1827
        return true;
1828
1828
1829
    if (!o.isRenderBlock())
1829
    if (!is<RenderBlock>(renderer))
1830
        return true;
1830
        return true;
1831
1831
1832
    const RenderBlock& renderBlock = *toRenderBlock(&o);
1832
    const RenderBlock& renderBlock = downcast<RenderBlock>(renderer);
1833
1833
1834
    LayoutUnit contentWidth = renderBlock.contentWidth();
1834
    LayoutUnit contentWidth = renderBlock.contentWidth();
1835
    LayoutUnit contentHeight = renderBlock.contentHeight();
1835
    LayoutUnit contentHeight = renderBlock.contentHeight();
Lines 1878-1890 bool RenderThemeMac::paintSnapshottedPluginOverlay(const RenderObject& o, const a/Source/WebCore/rendering/RenderThemeMac.mm_sec2
1878
1878
1879
    // We could draw the snapshot with that coordinates, but we need to make sure there
1879
    // We could draw the snapshot with that coordinates, but we need to make sure there
1880
    // isn't a composited layer between us and the plugInRenderer.
1880
    // isn't a composited layer between us and the plugInRenderer.
1881
    const RenderBox* renderBox = toRenderBox(&o);
1881
    for (auto* renderBox = &downcast<RenderBox>(renderer); renderBox != plugInRenderer; renderBox = renderBox->parentBox()) {
1882
    while (renderBox != plugInRenderer) {
1883
        if (renderBox->hasLayer() && renderBox->layer() && renderBox->layer()->isComposited()) {
1882
        if (renderBox->hasLayer() && renderBox->layer() && renderBox->layer()->isComposited()) {
1884
            snapshotAbsPos = -renderBox->location();
1883
            snapshotAbsPos = -renderBox->location();
1885
            break;
1884
            break;
1886
        }
1885
        }
1887
        renderBox = renderBox->parentBox();
1888
    }
1886
    }
1889
1887
1890
    LayoutSize pluginSize(plugInRenderer->contentWidth(), plugInRenderer->contentHeight());
1888
    LayoutSize pluginSize(plugInRenderer->contentWidth(), plugInRenderer->contentHeight());
- a/Source/WebCore/rendering/TextAutosizer.cpp -11 / +10 lines
Lines 126-132 bool TextAutosizer::processSubtree(RenderObject* layoutRoot) a/Source/WebCore/rendering/TextAutosizer.cpp_sec1
126
    }
126
    }
127
127
128
    // The layoutRoot could be neither a container nor a cluster, so walk up the tree till we find each of these.
128
    // The layoutRoot could be neither a container nor a cluster, so walk up the tree till we find each of these.
129
    RenderBlock* container = layoutRoot->isRenderBlock() ? toRenderBlock(layoutRoot) : layoutRoot->containingBlock();
129
    RenderBlock* container = is<RenderBlock>(*layoutRoot) ? downcast<RenderBlock>(layoutRoot) : layoutRoot->containingBlock();
130
    while (container && !isAutosizingContainer(container))
130
    while (container && !isAutosizingContainer(container))
131
        container = container->containingBlock();
131
        container = container->containingBlock();
132
132
Lines 204-217 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, T a/Source/WebCore/rendering/TextAutosizer.cpp_sec2
204
204
205
    RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot);
205
    RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot);
206
    while (descendant) {
206
    while (descendant) {
207
        if (descendant->isText()) {
207
        if (is<RenderText>(*descendant)) {
208
            if (localMultiplier != 1 && descendant->style()->textAutosizingMultiplier() == 1) {
208
            if (localMultiplier != 1 && descendant->style()->textAutosizingMultiplier() == 1) {
209
                setMultiplier(descendant, localMultiplier);
209
                setMultiplier(descendant, localMultiplier);
210
                setMultiplier(descendant->parent(), localMultiplier); // Parent does line spacing.
210
                setMultiplier(descendant->parent(), localMultiplier); // Parent does line spacing.
211
            }
211
            }
212
            // FIXME: Increase list marker size proportionately.
212
            // FIXME: Increase list marker size proportionately.
213
        } else if (isAutosizingContainer(descendant)) {
213
        } else if (isAutosizingContainer(descendant)) {
214
            RenderBlock* descendantBlock = toRenderBlock(descendant);
214
            RenderBlock* descendantBlock = downcast<RenderBlock>(descendant);
215
            TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
215
            TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
216
            if (isWiderDescendant(descendantBlock, clusterInfo) || isIndependentDescendant(descendantBlock))
216
            if (isWiderDescendant(descendantBlock, clusterInfo) || isIndependentDescendant(descendantBlock))
217
                processCluster(descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
217
                processCluster(descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
Lines 496-502 void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, Tex a/Source/WebCore/rendering/TextAutosizer.cpp_sec3
496
        if (!skipLocalText && is<RenderText>(*descendant))
496
        if (!skipLocalText && is<RenderText>(*descendant))
497
            textWidth += downcast<RenderText>(*descendant).renderedTextLength() * descendant->style()->specifiedFontSize();
497
            textWidth += downcast<RenderText>(*descendant).renderedTextLength() * descendant->style()->specifiedFontSize();
498
        else if (isAutosizingContainer(descendant)) {
498
        else if (isAutosizingContainer(descendant)) {
499
            RenderBlock* descendantBlock = toRenderBlock(descendant);
499
            RenderBlock* descendantBlock = downcast<RenderBlock>(descendant);
500
            if (!isAutosizingCluster(descendantBlock, clusterInfo))
500
            if (!isAutosizingCluster(descendantBlock, clusterInfo))
501
                measureDescendantTextWidth(descendantBlock, clusterInfo, minTextWidth, textWidth);
501
                measureDescendantTextWidth(descendantBlock, clusterInfo, minTextWidth, textWidth);
502
        }
502
        }
Lines 542-549 const RenderBlock* TextAutosizer::findDeepestBlockContainingAllText(const Render a/Source/WebCore/rendering/TextAutosizer.cpp_sec4
542
        lastNode = lastNode->parent();
542
        lastNode = lastNode->parent();
543
    }
543
    }
544
544
545
    if (firstNode->isRenderBlock())
545
    if (is<RenderBlock>(*firstNode))
546
        return toRenderBlock(firstNode);
546
        return downcast<RenderBlock>(firstNode);
547
547
548
    // containingBlock() should never leave the cluster, since it only skips ancestors when finding the
548
    // containingBlock() should never leave the cluster, since it only skips ancestors when finding the
549
    // container of position:absolute/fixed blocks, and those cannot exist between a cluster and its text
549
    // container of position:absolute/fixed blocks, and those cannot exist between a cluster and its text
Lines 558-578 const RenderBlock* TextAutosizer::findDeepestBlockContainingAllText(const Render a/Source/WebCore/rendering/TextAutosizer.cpp_sec5
558
const RenderObject* TextAutosizer::findFirstTextLeafNotInCluster(const RenderObject* parent, size_t& depth, TraversalDirection direction)
558
const RenderObject* TextAutosizer::findFirstTextLeafNotInCluster(const RenderObject* parent, size_t& depth, TraversalDirection direction)
559
{
559
{
560
    if (parent->isEmpty())
560
    if (parent->isEmpty())
561
        return parent->isText() ? parent : 0;
561
        return is<RenderText>(*parent) ? parent : nullptr;
562
562
563
    ++depth;
563
    ++depth;
564
    const RenderObject* child = (direction == FirstToLast) ? parent->firstChild() : parent->lastChild();
564
    const RenderObject* child = (direction == FirstToLast) ? parent->firstChild() : parent->lastChild();
565
    while (child) {
565
    while (child) {
566
        if (!isAutosizingContainer(child) || !isIndependentDescendant(toRenderBlock(child))) {
566
        if (!isAutosizingContainer(child) || !isIndependentDescendant(downcast<RenderBlock>(child))) {
567
            const RenderObject* leaf = findFirstTextLeafNotInCluster(child, depth, direction);
567
            if (const RenderObject* leaf = findFirstTextLeafNotInCluster(child, depth, direction))
568
            if (leaf)
569
                return leaf;
568
                return leaf;
570
        }
569
        }
571
        child = (direction == FirstToLast) ? child->nextSibling() : child->previousSibling();
570
        child = (direction == FirstToLast) ? child->nextSibling() : child->previousSibling();
572
    }
571
    }
573
    --depth;
572
    --depth;
574
573
575
    return 0;
574
    return nullptr;
576
}
575
}
577
576
578
namespace {
577
namespace {
- a/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp -1 / +1 lines
Lines 300-306 void RenderMathMLRoot::layout() a/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp_sec1
300
            auto index = indexWrapper();
300
            auto index = indexWrapper();
301
            float indexHeight = 0;
301
            float indexHeight = 0;
302
            if (!index->isEmpty())
302
            if (!index->isEmpty())
303
                indexHeight = toRenderBlock(index->firstChild())->logicalHeight();
303
                indexHeight = downcast<RenderBlock>(*index->firstChild()).logicalHeight();
304
            float indexTopMargin = (1.0 - m_degreeBottomRaisePercent) * radical->stretchSize() + radicalTopMargin - indexHeight;
304
            float indexTopMargin = (1.0 - m_degreeBottomRaisePercent) * radical->stretchSize() + radicalTopMargin - indexHeight;
305
            if (indexTopMargin < 0) {
305
            if (indexTopMargin < 0) {
306
                // If the index is too tall, we must add space at the top of renderer.
306
                // If the index is too tall, we must add space at the top of renderer.
- a/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm -2 / +2 lines
Lines 774-780 PassRefPtr<Range> WebPage::rangeForWebSelectionAtPosition(const IntPoint& point, a/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm_sec1
774
    if (!renderer || renderer->style().userSelect() == SELECT_NONE)
774
    if (!renderer || renderer->style().userSelect() == SELECT_NONE)
775
        return nullptr;
775
        return nullptr;
776
776
777
    if (renderer->childrenInline() && (renderer->isRenderBlock() && !toRenderBlock(renderer)->inlineElementContinuation()) && !renderer->isTable()) {
777
    if (renderer->childrenInline() && (is<RenderBlock>(*renderer) && !downcast<RenderBlock>(*renderer).inlineElementContinuation()) && !renderer->isTable()) {
778
        range = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionBackward);
778
        range = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionBackward);
779
        if (range && !range->collapsed(ASSERT_NO_EXCEPTION))
779
        if (range && !range->collapsed(ASSERT_NO_EXCEPTION))
780
            return range;
780
            return range;
Lines 1316-1322 PassRefPtr<Range> WebPage::contractedRangeFromHandle(Range* currentRange, Select a/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm_sec2
1316
        node = node->parentElement();
1316
        node = node->parentElement();
1317
1317
1318
    RenderObject* renderer = node->renderer();
1318
    RenderObject* renderer = node->renderer();
1319
    if (renderer && renderer->childrenInline() && (renderer->isRenderBlock() && !toRenderBlock(renderer)->inlineElementContinuation()) && !renderer->isTable())
1319
    if (renderer && renderer->childrenInline() && (is<RenderBlock>(*renderer) && !downcast<RenderBlock>(*renderer).inlineElementContinuation()) && !renderer->isTable())
1320
        flags = None;
1320
        flags = None;
1321
1321
1322
    return bestRange;
1322
    return bestRange;

Return to Bug 137512