Use is<>() / downcast<>() for RenderBlockFlow
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Oct 2014 16:17:06 +0000 (16:17 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Oct 2014 16:17:06 +0000 (16:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137545

Reviewed by Darin Adler.

Use is<>() / downcast<>() for RenderBlockFlow and clean up the
surrounding code.

No new tests, no behavior change.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
* dom/Element.cpp:
(WebCore::Element::renderNamedFlowFragment):
(WebCore::Element::webkitGetRegionFlowRanges):
* editing/Editor.cpp:
(WebCore::Editor::hasBidiSelection):
* inspector/InspectorOverlay.cpp:
(WebCore::buildObjectForRegionHighlight):
(WebCore::buildObjectForElementInfo):
* rendering/EllipsisBox.h:
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::innerTextIfTruncated):
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::removeChild):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::moveAllChildrenIncludingFloatsTo):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::rebuildFloatingObjectSetFromIntrudingFloats):
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::marginOffsetForSelfCollapsingBlock):
(WebCore::RenderBlockFlow::marginValuesForChild):
(WebCore::RenderBlockFlow::collapseMargins):
(WebCore::RenderBlockFlow::marginBeforeEstimateForChild):
(WebCore::RenderBlockFlow::handleAfterSideOfBlock):
(WebCore::RenderBlockFlow::mustDiscardMarginBeforeForChild):
(WebCore::RenderBlockFlow::mustDiscardMarginAfterForChild):
(WebCore::RenderBlockFlow::adjustBlockChildForPagination):
(WebCore::RenderBlockFlow::moveAllChildrenIncludingFloatsTo):
(WebCore::RenderBlockFlow::markAllDescendantsWithFloatsForLayout):
(WebCore::RenderBlockFlow::adjustForBorderFit):
(WebCore::getHeightForLineCount):
* rendering/RenderBlockFlow.h:
(WebCore::RenderElement::isRenderNamedFlowFragmentContainer):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::createLineBoxes):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintMaskForTextFillBox):
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
(WebCore::RenderDeprecatedFlexibleBox::clearLineClamp):
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::removeFlowChildInfo):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPositions):
(WebCore::expandClipRectForRegionAndReflection):
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
* rendering/RenderMultiColumnFlowThread.cpp:
(WebCore::RenderMultiColumnFlowThread::evacuateAndDestroy):
(WebCore::RenderMultiColumnFlowThread::processPossibleSpannerDescendant):
(WebCore::RenderMultiColumnFlowThread::flowThreadDescendantInserted):
* rendering/RenderMultiColumnFlowThread.h:
* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::heightAdjustedForSetOffset):
(WebCore::RenderMultiColumnSet::columnGap):
* rendering/RenderMultiColumnSet.h:
* rendering/RenderNamedFlowFragment.cpp:
(WebCore::RenderNamedFlowFragment::fragmentContainer):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::adjustComputedFontSizesOnBlocks):
(WebCore::RenderObject::resetTextAutosizing):
(WebCore::RenderObject::showLineTreeForThis):
(WebCore::RenderObject::showRenderSubTreeAndMark):
* rendering/RenderText.cpp:
(WebCore::RenderText::setText):
(WebCore::RenderText::ensureLineBoxes):
(WebCore::RenderText::simpleLineLayout):
* rendering/RenderTreeAsText.cpp:
(WebCore::write):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::selectionTopAdjustedForPrecedingBlock):
(WebCore::RootInlineBox::blockFlow):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::computeTextBoundingBox):
(WebCore::SimpleLineLayout::computeTextFirstRunLocation):
(WebCore::SimpleLineLayout::collectTextAbsoluteRects):
(WebCore::SimpleLineLayout::collectTextAbsoluteQuads):
* rendering/svg/SVGTextQuery.cpp:
(WebCore::flowBoxForRenderer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174504 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/rendering/EllipsisBox.h
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBlockFlow.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp
Source/WebCore/rendering/RenderMultiColumnFlowThread.h
Source/WebCore/rendering/RenderMultiColumnSet.cpp
Source/WebCore/rendering/RenderMultiColumnSet.h
Source/WebCore/rendering/RenderNamedFlowFragment.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
Source/WebCore/rendering/svg/SVGTextQuery.cpp

index 1924fce..a669d77 100644 (file)
@@ -1,3 +1,102 @@
+2014-10-09  Christophe Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for RenderBlockFlow
+        https://bugs.webkit.org/show_bug.cgi?id=137545
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for RenderBlockFlow and clean up the
+        surrounding code.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
+        * dom/Element.cpp:
+        (WebCore::Element::renderNamedFlowFragment):
+        (WebCore::Element::webkitGetRegionFlowRanges):
+        * editing/Editor.cpp:
+        (WebCore::Editor::hasBidiSelection):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::buildObjectForRegionHighlight):
+        (WebCore::buildObjectForElementInfo):
+        * rendering/EllipsisBox.h:
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::innerTextIfTruncated):
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::LayoutState):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::removeChild):
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::moveAllChildrenIncludingFloatsTo):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::rebuildFloatingObjectSetFromIntrudingFloats):
+        (WebCore::RenderBlockFlow::layoutBlockChild):
+        (WebCore::RenderBlockFlow::marginOffsetForSelfCollapsingBlock):
+        (WebCore::RenderBlockFlow::marginValuesForChild):
+        (WebCore::RenderBlockFlow::collapseMargins):
+        (WebCore::RenderBlockFlow::marginBeforeEstimateForChild):
+        (WebCore::RenderBlockFlow::handleAfterSideOfBlock):
+        (WebCore::RenderBlockFlow::mustDiscardMarginBeforeForChild):
+        (WebCore::RenderBlockFlow::mustDiscardMarginAfterForChild):
+        (WebCore::RenderBlockFlow::adjustBlockChildForPagination):
+        (WebCore::RenderBlockFlow::moveAllChildrenIncludingFloatsTo):
+        (WebCore::RenderBlockFlow::markAllDescendantsWithFloatsForLayout):
+        (WebCore::RenderBlockFlow::adjustForBorderFit):
+        (WebCore::getHeightForLineCount):
+        * rendering/RenderBlockFlow.h:
+        (WebCore::RenderElement::isRenderNamedFlowFragmentContainer):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::createLineBoxes):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::styleDidChange):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintMaskForTextFillBox):
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
+        (WebCore::RenderDeprecatedFlexibleBox::clearLineClamp):
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::removeFlowChildInfo):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPositions):
+        (WebCore::expandClipRectForRegionAndReflection):
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+        (WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
+        * rendering/RenderMultiColumnFlowThread.cpp:
+        (WebCore::RenderMultiColumnFlowThread::evacuateAndDestroy):
+        (WebCore::RenderMultiColumnFlowThread::processPossibleSpannerDescendant):
+        (WebCore::RenderMultiColumnFlowThread::flowThreadDescendantInserted):
+        * rendering/RenderMultiColumnFlowThread.h:
+        * rendering/RenderMultiColumnSet.cpp:
+        (WebCore::RenderMultiColumnSet::heightAdjustedForSetOffset):
+        (WebCore::RenderMultiColumnSet::columnGap):
+        * rendering/RenderMultiColumnSet.h:
+        * rendering/RenderNamedFlowFragment.cpp:
+        (WebCore::RenderNamedFlowFragment::fragmentContainer):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::adjustComputedFontSizesOnBlocks):
+        (WebCore::RenderObject::resetTextAutosizing):
+        (WebCore::RenderObject::showLineTreeForThis):
+        (WebCore::RenderObject::showRenderSubTreeAndMark):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::setText):
+        (WebCore::RenderText::ensureLineBoxes):
+        (WebCore::RenderText::simpleLineLayout):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::write):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::selectionTopAdjustedForPrecedingBlock):
+        (WebCore::RootInlineBox::blockFlow):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::computeTextBoundingBox):
+        (WebCore::SimpleLineLayout::computeTextFirstRunLocation):
+        (WebCore::SimpleLineLayout::collectTextAbsoluteRects):
+        (WebCore::SimpleLineLayout::collectTextAbsoluteQuads):
+        * rendering/svg/SVGTextQuery.cpp:
+        (WebCore::flowBoxForRenderer):
+
 2014-10-09  Philip Chimento  <philip.chimento@gmail.com>
 
         [GTK] Netscape plugin API symbol used outside feature guards
index f576914..e909604 100644 (file)
@@ -1285,8 +1285,8 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
         return false;
 #endif
     
-    if (m_renderer->isRenderBlockFlow() && m_renderer->childrenInline() && !canSetFocusAttribute())
-        return !toRenderBlockFlow(m_renderer)->hasLines() && !mouseButtonListener();
+    if (is<RenderBlockFlow>(*m_renderer) && m_renderer->childrenInline() && !canSetFocusAttribute())
+        return !downcast<RenderBlockFlow>(*m_renderer).hasLines() && !mouseButtonListener();
     
     // ignore images seemingly used as spacers
     if (isImage()) {
@@ -1298,9 +1298,9 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
         // First check the RenderImage's altText (which can be set through a style sheet, or come from the Element).
         // However, if this is not a native image, fallback to the attribute on the Element.
         AccessibilityObjectInclusion altTextInclusion = DefaultBehavior;
-        bool isRenderImage = m_renderer && m_renderer->isRenderImage();
+        bool isRenderImage = is<RenderImage>(m_renderer);
         if (isRenderImage)
-            altTextInclusion = objectInclusionFromAltText(toRenderImage(m_renderer)->altText());
+            altTextInclusion = objectInclusionFromAltText(downcast<RenderImage>(*m_renderer).altText());
         else
             altTextInclusion = objectInclusionFromAltText(getAttribute(altAttr).string());
 
@@ -1315,13 +1315,13 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
     
         if (isRenderImage) {
             // check for one-dimensional image
-            RenderImage* image = toRenderImage(m_renderer);
-            if (image->height() <= 1 || image->width() <= 1)
+            RenderImage& image = downcast<RenderImage>(*m_renderer);
+            if (image.height() <= 1 || image.width() <= 1)
                 return true;
             
             // check whether rendered image was stretched from one-dimensional file image
-            if (image->cachedImage()) {
-                LayoutSize imageSize = image->cachedImage()->imageSizeForRenderer(toRenderElement(m_renderer), image->view().zoomFactor());
+            if (image.cachedImage()) {
+                LayoutSize imageSize = image.cachedImage()->imageSizeForRenderer(toRenderElement(m_renderer), image.view().zoomFactor());
                 return imageSize.height() <= 1 || imageSize.width() <= 1;
             }
         }
index 11da351..a5b045d 100644 (file)
@@ -2494,7 +2494,7 @@ bool Element::isSpellCheckingEnabled() const
 RenderNamedFlowFragment* Element::renderNamedFlowFragment() const
 {
     if (renderer() && renderer()->isRenderNamedFlowFragmentContainer())
-        return toRenderBlockFlow(renderer())->renderNamedFlowFragment();
+        return downcast<RenderBlockFlow>(*renderer()).renderNamedFlowFragment();
 
     return nullptr;
 }
@@ -2554,9 +2554,9 @@ Vector<RefPtr<Range>> Element::webkitGetRegionFlowRanges() const
 
     document().updateLayoutIgnorePendingStylesheets();
     if (renderer() && renderer()->isRenderNamedFlowFragmentContainer()) {
-        RenderNamedFlowFragment* namedFlowFragment = toRenderBlockFlow(renderer())->renderNamedFlowFragment();
-        if (namedFlowFragment->isValid())
-            namedFlowFragment->getRanges(rangeObjects);
+        RenderNamedFlowFragment& namedFlowFragment = *downcast<RenderBlockFlow>(*renderer()).renderNamedFlowFragment();
+        if (namedFlowFragment.isValid())
+            namedFlowFragment.getRanges(rangeObjects);
     }
 
     return rangeObjects;
index 4a7afd8..c203395 100644 (file)
@@ -769,7 +769,7 @@ bool Editor::hasBidiSelection() const
         startNode = m_frame.selection().selection().visibleStart().deepEquivalent().deprecatedNode();
 
     auto renderer = startNode->renderer();
-    while (renderer && !renderer->isRenderBlockFlow())
+    while (renderer && !is<RenderBlockFlow>(*renderer))
         renderer = renderer->parent();
 
     if (!renderer)
@@ -778,7 +778,7 @@ bool Editor::hasBidiSelection() const
     if (!renderer->style().isLeftToRightDirection())
         return true;
 
-    return toRenderBlockFlow(renderer)->containsNonZeroBidiLevel();
+    return downcast<RenderBlockFlow>(*renderer).containsNonZeroBidiLevel();
 }
 
 TriState Editor::selectionUnorderedListState() const
index e6f21bb..caca8e4 100644 (file)
@@ -379,10 +379,10 @@ static PassRefPtr<InspectorObject> buildObjectForRegionHighlight(FrameView* main
     if (!containingView)
         return nullptr;
 
-    RenderBlockFlow* regionContainer = toRenderBlockFlow(region->parent());
-    LayoutRect borderBox = regionContainer->borderBoxRect();
-    borderBox.setWidth(borderBox.width() + regionContainer->verticalScrollbarWidth());
-    borderBox.setHeight(borderBox.height() + regionContainer->horizontalScrollbarHeight());
+    RenderBlockFlow& regionContainer = downcast<RenderBlockFlow>(*region->parent());
+    LayoutRect borderBox = regionContainer.borderBoxRect();
+    borderBox.setWidth(borderBox.width() + regionContainer.verticalScrollbarWidth());
+    borderBox.setHeight(borderBox.height() + regionContainer.horizontalScrollbarHeight());
 
     // Create incoming and outgoing boxes that we use to chain the regions toghether.
     const LayoutSize linkBoxSize(10, 10);
@@ -397,9 +397,9 @@ static PassRefPtr<InspectorObject> buildObjectForRegionHighlight(FrameView* main
     incomingRectBox.move(0, linkBoxVerticalOffset);
     outgoingRectBox.move(0, -linkBoxVerticalOffset);
 
-    FloatQuad borderRectQuad = regionContainer->localToAbsoluteQuad(FloatRect(borderBox));
-    FloatQuad incomingRectQuad = regionContainer->localToAbsoluteQuad(FloatRect(incomingRectBox));
-    FloatQuad outgoingRectQuad = regionContainer->localToAbsoluteQuad(FloatRect(outgoingRectBox));
+    FloatQuad borderRectQuad = regionContainer.localToAbsoluteQuad(FloatRect(borderBox));
+    FloatQuad incomingRectQuad = regionContainer.localToAbsoluteQuad(FloatRect(incomingRectBox));
+    FloatQuad outgoingRectQuad = regionContainer.localToAbsoluteQuad(FloatRect(outgoingRectBox));
 
     contentsQuadToPage(mainView, containingView, borderRectQuad);
     contentsQuadToPage(mainView, containingView, incomingRectQuad);
@@ -711,13 +711,12 @@ static PassRefPtr<InspectorObject> buildObjectForElementInfo(Node* node)
     elementInfo->setString("nodeHeight", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), *modelObject) : boundingBox.height()));
     
     if (renderer->isRenderNamedFlowFragmentContainer()) {
-        RenderNamedFlowFragment* region = toRenderBlockFlow(renderer)->renderNamedFlowFragment();
-        if (region->isValid()) {
-            RenderFlowThread* flowThread = region->flowThread();
-            ASSERT(flowThread && flowThread->isRenderNamedFlowThread());
+        RenderNamedFlowFragment& region = *downcast<RenderBlockFlow>(*renderer).renderNamedFlowFragment();
+        if (region.isValid()) {
+            RenderFlowThread* flowThread = region.flowThread();
             RefPtr<InspectorObject> regionFlowInfo = InspectorObject::create();
-            regionFlowInfo->setString("name", toRenderNamedFlowThread(flowThread)->flowThreadName());
-            regionFlowInfo->setArray("regions", buildObjectForCSSRegionsHighlight(region, flowThread));
+            regionFlowInfo->setString("name", downcast<RenderNamedFlowThread>(*flowThread).flowThreadName());
+            regionFlowInfo->setArray("regions", buildObjectForCSSRegionsHighlight(&region, flowThread));
             elementInfo->setObject("regionFlowInfo", regionFlowInfo.release());
         }
     }
index 22e30c4..f3cf8db 100644 (file)
@@ -36,7 +36,7 @@ public:
     void setSelectionState(RenderObject::SelectionState s) { m_selectionState = s; }
     IntRect selectionRect();
 
-    RenderBlockFlow& blockFlow() const { return toRenderBlockFlow(InlineBox::renderer()); }
+    RenderBlockFlow& blockFlow() const { return downcast<RenderBlockFlow>(InlineBox::renderer()); }
 
 private:
     void paintMarkupBox(PaintInfo&, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const RenderStyle&);
index ff84f67..6b5c1f2 100644 (file)
@@ -243,12 +243,12 @@ String HitTestResult::innerTextIfTruncated(TextDirection& dir) const
             continue;
 
         if (auto renderer = downcast<Element>(*truncatedNode).renderer()) {
-            if (renderer->isRenderBlockFlow()) {
-                RenderBlockFlow* block = toRenderBlockFlow(renderer);
-                if (block->style().textOverflow()) {
-                    for (RootInlineBox* line = block->firstRootBox(); line; line = line->nextRootBox()) {
+            if (is<RenderBlockFlow>(*renderer)) {
+                RenderBlockFlow& block = downcast<RenderBlockFlow>(*renderer);
+                if (block.style().textOverflow()) {
+                    for (RootInlineBox* line = block.firstRootBox(); line; line = line->nextRootBox()) {
                         if (line->hasEllipsisBox()) {
-                            dir = block->style().direction();
+                            dir = block.style().direction();
                             return downcast<Element>(*truncatedNode).innerText();
                         }
                     }
index 2dd1422..bbe1706 100644 (file)
@@ -116,8 +116,8 @@ LayoutState::LayoutState(std::unique_ptr<LayoutState> next, RenderBox* renderer,
         toRenderMultiColumnFlowThread(renderer)->computeLineGridPaginationOrigin(*this);
 
     // If we have a new grid to track, then add it to our set.
-    if (renderer->style().lineGrid() != RenderStyle::initialLineGrid() && renderer->isRenderBlockFlow())
-        establishLineGrid(toRenderBlockFlow(renderer));
+    if (renderer->style().lineGrid() != RenderStyle::initialLineGrid() && is<RenderBlockFlow>(*renderer))
+        establishLineGrid(downcast<RenderBlockFlow>(renderer));
 
     // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
 }
index aa1551f..bcba51c 100644 (file)
@@ -745,7 +745,7 @@ RenderObject* RenderBlock::removeChild(RenderObject& oldChild)
         } else {
             // Take all the children out of the |next| block and put them in
             // the |prev| block.
-            nextBlock.moveAllChildrenIncludingFloatsTo(&prevBlock, nextBlock.hasLayer() || prevBlock.hasLayer());
+            nextBlock.moveAllChildrenIncludingFloatsTo(prevBlock, nextBlock.hasLayer() || prevBlock.hasLayer());
             
             // Delete the now-empty block's lines and nuke it.
             nextBlock.deleteLines();
index b79f88e..72d4a88 100644 (file)
@@ -407,7 +407,7 @@ private:
     virtual void removeLeftoverAnonymousBlock(RenderBlock* child);
 
     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
-    virtual void moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fullRemoveInsert) { moveAllChildrenTo(toBlock, fullRemoveInsert); }
+    virtual void moveAllChildrenIncludingFloatsTo(RenderBlock& toBlock, bool fullRemoveInsert) { moveAllChildrenTo(&toBlock, fullRemoveInsert); }
 
     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild) override;
index ff96d51..dccd68d 100644 (file)
@@ -227,16 +227,16 @@ void RenderBlockFlow::rebuildFloatingObjectSetFromIntrudingFloats()
     // We should not process floats if the parent node is not a RenderBlock. Otherwise, we will add 
     // floats in an invalid context. This will cause a crash arising from a bad cast on the parent.
     // See <rdar://problem/8049753>, where float property is applied on a text node in a SVG.
-    if (!parent() || !parent()->isRenderBlockFlow())
+    if (!is<RenderBlockFlow>(parent()))
         return;
 
     // Attempt to locate a previous sibling with overhanging floats. We skip any elements that are
     // out of flow (like floating/positioned elements), and we also skip over any objects that may have shifted
     // to avoid floats.
-    RenderBlockFlow* parentBlock = toRenderBlockFlow(parent());
+    RenderBlockFlow& parentBlock = downcast<RenderBlockFlow>(*parent());
     bool parentHasFloats = false;
     RenderObject* prev = previousSibling();
-    while (prev && (prev->isFloatingOrOutOfFlowPositioned() || !prev->isBox() || !prev->isRenderBlockFlow() || toRenderBlockFlow(prev)->avoidsFloats())) {
+    while (prev && (prev->isFloatingOrOutOfFlowPositioned() || !is<RenderBox>(*prev) || !is<RenderBlockFlow>(*prev) || downcast<RenderBlockFlow>(*prev).avoidsFloats())) {
         if (prev->isFloating())
             parentHasFloats = true;
         prev = prev->previousSibling();
@@ -245,21 +245,21 @@ void RenderBlockFlow::rebuildFloatingObjectSetFromIntrudingFloats()
     // First add in floats from the parent. Self-collapsing blocks let their parent track any floats that intrude into
     // them (as opposed to floats they contain themselves) so check for those here too.
     LayoutUnit logicalTopOffset = logicalTop();
-    if (parentHasFloats || (parentBlock->lowestFloatLogicalBottom() > logicalTopOffset && prev && toRenderBlockFlow(prev)->isSelfCollapsingBlock()))
-        addIntrudingFloats(parentBlock, parentBlock->logicalLeftOffsetForContent(), logicalTopOffset);
+    if (parentHasFloats || (parentBlock.lowestFloatLogicalBottom() > logicalTopOffset && prev && downcast<RenderBlockFlow>(*prev).isSelfCollapsingBlock()))
+        addIntrudingFloats(&parentBlock, parentBlock.logicalLeftOffsetForContent(), logicalTopOffset);
     
     LayoutUnit logicalLeftOffset = 0;
     if (prev)
         logicalTopOffset -= toRenderBox(prev)->logicalTop();
     else {
-        prev = parentBlock;
-        logicalLeftOffset += parentBlock->logicalLeftOffsetForContent();
+        prev = &parentBlock;
+        logicalLeftOffset += parentBlock.logicalLeftOffsetForContent();
     }
 
     // Add overhanging floats from the previous RenderBlock, but only if it has a float that intrudes into our space.    
-    RenderBlockFlow* block = toRenderBlockFlow(prev);
-    if (block->m_floatingObjects && block->lowestFloatLogicalBottom() > logicalTopOffset)
-        addIntrudingFloats(block, logicalLeftOffset, logicalTopOffset);
+    RenderBlockFlow& block = downcast<RenderBlockFlow>(*prev);
+    if (block.m_floatingObjects && block.lowestFloatLogicalBottom() > logicalTopOffset)
+        addIntrudingFloats(&block, logicalLeftOffset, logicalTopOffset);
 
     if (childrenInline()) {
         LayoutUnit changeLogicalTop = LayoutUnit::max();
@@ -678,7 +678,7 @@ void RenderBlockFlow::layoutBlockChild(RenderBox& child, MarginInfo& marginInfo,
     setLogicalTopForChild(child, logicalTopEstimate, ApplyLayoutDelta);
     estimateRegionRangeForBoxChild(child);
 
-    RenderBlockFlow* childBlockFlow = child.isRenderBlockFlow() ? toRenderBlockFlow(&child) : nullptr;
+    RenderBlockFlow* childBlockFlow = is<RenderBlockFlow>(child) ? &downcast<RenderBlockFlow>(child) : nullptr;
     bool markDescendantsWithFloats = false;
     if (logicalTopEstimate != oldLogicalTop && !child.avoidsFloats() && childBlockFlow && childBlockFlow->containsFloats())
         markDescendantsWithFloats = true;
@@ -827,7 +827,7 @@ void RenderBlockFlow::adjustPositionedBlock(RenderBox& child, const MarginInfo&
 LayoutUnit RenderBlockFlow::marginOffsetForSelfCollapsingBlock()
 {
     ASSERT(isSelfCollapsingBlock());
-    RenderBlockFlow* parentBlock = toRenderBlockFlow(parent());
+    RenderBlockFlow* parentBlock = downcast<RenderBlockFlow>(parent());
     if (parentBlock && style().clear() && parentBlock->getClearDelta(*this, logicalHeight()))
         return marginValuesForChild(*this).positiveMarginBefore();
     return LayoutUnit();
@@ -900,7 +900,7 @@ RenderBlockFlow::MarginValues RenderBlockFlow::marginValuesForChild(RenderBox& c
     LayoutUnit beforeMargin = 0;
     LayoutUnit afterMargin = 0;
 
-    RenderBlockFlow* childRenderBlock = child.isRenderBlockFlow() ? toRenderBlockFlow(&child) : nullptr;
+    RenderBlockFlow* childRenderBlock = is<RenderBlockFlow>(child) ? &downcast<RenderBlockFlow>(child) : nullptr;
     
     // If the child has the same directionality as we do, then we can just return its
     // margins in the same direction.
@@ -1023,8 +1023,8 @@ LayoutUnit RenderBlockFlow::collapseMargins(RenderBox& child, MarginInfo& margin
     // If the child's previous sibling is a self-collapsing block that cleared a float then its top border edge has been set at the bottom border edge
     // of the float. Since we want to collapse the child's top margin with the self-collapsing block's top and bottom margins we need to adjust our parent's height to match the 
     // margin top of the self-collapsing block. If the resulting collapsed margin leaves the child still intruding into the float then we will want to clear it.
-    if (!marginInfo.canCollapseWithMarginBefore() && prev && prev->isRenderBlockFlow() && toRenderBlockFlow(prev)->isSelfCollapsingBlock()) {
-        clearanceForSelfCollapsingBlock = toRenderBlockFlow(prev)->marginOffsetForSelfCollapsingBlock();
+    if (!marginInfo.canCollapseWithMarginBefore() && is<RenderBlockFlow>(prev) && downcast<RenderBlockFlow>(*prev).isSelfCollapsingBlock()) {
+        clearanceForSelfCollapsingBlock = downcast<RenderBlockFlow>(*prev).marginOffsetForSelfCollapsingBlock();
         setLogicalHeight(logicalHeight() - clearanceForSelfCollapsingBlock);
     }
 
@@ -1091,10 +1091,10 @@ LayoutUnit RenderBlockFlow::collapseMargins(RenderBox& child, MarginInfo& margin
         setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
     }
 
-    if (prev && prev->isRenderBlockFlow() && !prev->isFloatingOrOutOfFlowPositioned()) {
+    if (is<RenderBlockFlow>(prev) && !prev->isFloatingOrOutOfFlowPositioned()) {
         // If |child| is a self-collapsing block it may have collapsed into a previous sibling and although it hasn't reduced the height of the parent yet
         // any floats from the parent will now overhang.
-        RenderBlockFlow& block = toRenderBlockFlow(*prev);
+        RenderBlockFlow& block = downcast<RenderBlockFlow>(*prev);
         LayoutUnit oldLogicalHeight = logicalHeight();
         setLogicalHeight(logicalTop);
         if (block.containsFloats() && !block.avoidsFloats() && (block.logicalTop() + block.lowestFloatLogicalBottom()) > logicalTop)
@@ -1195,10 +1195,10 @@ void RenderBlockFlow::marginBeforeEstimateForChild(RenderBox& child, LayoutUnit&
     positiveMarginBefore = std::max(positiveMarginBefore, beforeChildMargin);
     negativeMarginBefore = std::max(negativeMarginBefore, -beforeChildMargin);
 
-    if (!child.isRenderBlockFlow())
+    if (!is<RenderBlockFlow>(child))
         return;
     
-    RenderBlockFlow& childBlock = toRenderBlockFlow(child);
+    RenderBlockFlow& childBlock = downcast<RenderBlockFlow>(child);
     if (childBlock.childrenInline() || childBlock.isWritingModeRoot())
         return;
 
@@ -1314,8 +1314,8 @@ void RenderBlockFlow::handleAfterSideOfBlock(LayoutUnit beforeSide, LayoutUnit a
     // bottom edge of the float that the child clears. The correct vertical position for the margin-collapsing we want
     // to perform now is at the child's margin-top - so adjust our height to that position.
     RenderObject* lastBlock = lastChild();
-    if (lastBlock && lastBlock->isRenderBlockFlow() && toRenderBlockFlow(lastBlock)->isSelfCollapsingBlock())
-        setLogicalHeight(logicalHeight() - toRenderBlockFlow(lastBlock)->marginOffsetForSelfCollapsingBlock());
+    if (is<RenderBlockFlow>(lastBlock) && downcast<RenderBlockFlow>(*lastBlock).isSelfCollapsingBlock())
+        setLogicalHeight(logicalHeight() - downcast<RenderBlockFlow>(*lastBlock).marginOffsetForSelfCollapsingBlock());
 
     // If we can't collapse with children then go ahead and add in the bottom margin.
     if (!marginInfo.discardMargin() && (!marginInfo.canCollapseWithMarginAfter() && !marginInfo.canCollapseWithMarginBefore()
@@ -1403,9 +1403,9 @@ bool RenderBlockFlow::mustDiscardMarginBeforeForChild(const RenderBox& child) co
 {
     ASSERT(!child.selfNeedsLayout());
     if (!child.isWritingModeRoot())
-        return child.isRenderBlockFlow() ? toRenderBlockFlow(child).mustDiscardMarginBefore() : (child.style().marginBeforeCollapse() == MDISCARD);
+        return is<RenderBlockFlow>(child) ? downcast<RenderBlockFlow>(child).mustDiscardMarginBefore() : (child.style().marginBeforeCollapse() == MDISCARD);
     if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
-        return child.isRenderBlockFlow() ? toRenderBlockFlow(child).mustDiscardMarginAfter() : (child.style().marginAfterCollapse() == MDISCARD);
+        return is<RenderBlockFlow>(child) ? downcast<RenderBlockFlow>(child).mustDiscardMarginAfter() : (child.style().marginAfterCollapse() == MDISCARD);
 
     // FIXME: We return false here because the implementation is not geometrically complete. We have values only for before/after, not start/end.
     // In case the boxes are perpendicular we assume the property is not specified.
@@ -1416,9 +1416,9 @@ bool RenderBlockFlow::mustDiscardMarginAfterForChild(const RenderBox& child) con
 {
     ASSERT(!child.selfNeedsLayout());
     if (!child.isWritingModeRoot())
-        return child.isRenderBlockFlow() ? toRenderBlockFlow(child).mustDiscardMarginAfter() : (child.style().marginAfterCollapse() == MDISCARD);
+        return is<RenderBlockFlow>(child) ? downcast<RenderBlockFlow>(child).mustDiscardMarginAfter() : (child.style().marginAfterCollapse() == MDISCARD);
     if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
-        return child.isRenderBlockFlow() ? toRenderBlockFlow(child).mustDiscardMarginBefore() : (child.style().marginBeforeCollapse() == MDISCARD);
+        return is<RenderBlockFlow>(child) ? downcast<RenderBlockFlow>(child).mustDiscardMarginBefore() : (child.style().marginBeforeCollapse() == MDISCARD);
 
     // FIXME: See |mustDiscardMarginBeforeForChild| above.
     return false;
@@ -1540,7 +1540,7 @@ LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopA
         
         if (childRenderBlock) {
             if (!child.avoidsFloats() && childRenderBlock->containsFloats())
-                toRenderBlockFlow(childRenderBlock)->markAllDescendantsWithFloatsForLayout();
+                downcast<RenderBlockFlow>(*childRenderBlock).markAllDescendantsWithFloatsForLayout();
             if (!child.needsLayout())
                 child.markForPaginationRelayoutIfNeeded();
         }
@@ -2055,11 +2055,11 @@ void RenderBlockFlow::moveFloatsTo(RenderBlockFlow* toBlockFlow)
     }
 }
 
-void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fullRemoveInsert)
+void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock& toBlock, bool fullRemoveInsert)
 {
-    RenderBlockFlow* toBlockFlow = toRenderBlockFlow(toBlock);
-    moveAllChildrenTo(toBlockFlow, fullRemoveInsert);
-    moveFloatsTo(toBlockFlow);
+    RenderBlockFlow& toBlockFlow = downcast<RenderBlockFlow>(toBlock);
+    moveAllChildrenTo(&toBlockFlow, fullRemoveInsert);
+    moveFloatsTo(&toBlockFlow);
 }
 
 void RenderBlockFlow::addOverflowFromFloats()
@@ -2709,12 +2709,12 @@ void RenderBlockFlow::markAllDescendantsWithFloatsForLayout(RenderBox* floatToRe
     for (auto& block : childrenOfType<RenderBlock>(*this)) {
         if (!floatToRemove && block.isFloatingOrOutOfFlowPositioned())
             continue;
-        if (!block.isRenderBlockFlow()) {
+        if (!is<RenderBlockFlow>(block)) {
             if (block.shrinkToAvoidFloats() && block.everHadLayout())
                 block.setChildNeedsLayout(markParents);
             continue;
         }
-        auto& blockFlow = toRenderBlockFlow(block);
+        auto& blockFlow = downcast<RenderBlockFlow>(block);
         if ((floatToRemove ? blockFlow.containsFloat(*floatToRemove) : blockFlow.containsFloats()) || blockFlow.shrinkToAvoidFloats())
             blockFlow.markAllDescendantsWithFloatsForLayout(floatToRemove, inLayout);
     }
@@ -2885,8 +2885,8 @@ void RenderBlockFlow::adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutU
     } else {
         for (RenderBox* obj = firstChildBox(); obj; obj = obj->nextSiblingBox()) {
             if (!obj->isFloatingOrOutOfFlowPositioned()) {
-                if (obj->isRenderBlockFlow() && !obj->hasOverflowClip())
-                    toRenderBlockFlow(obj)->adjustForBorderFit(x + obj->x(), left, right);
+                if (is<RenderBlockFlow>(*obj) && !obj->hasOverflowClip())
+                    downcast<RenderBlockFlow>(*obj).adjustForBorderFit(x + obj->x(), left, right);
                 else if (obj->style().visibility() == VISIBLE) {
                     // We are a replaced element or some kind of non-block-flow object.
                     left = std::min(left, x + obj->x());
@@ -3209,10 +3209,10 @@ static int getHeightForLineCount(const RenderBlockFlow& block, int lineCount, bo
                 return box->lineBottom() + (includeBottom ? (block.borderBottom() + block.paddingBottom()) : LayoutUnit());
         }
     } else {
-        RenderBox* normalFlowChildWithoutLines = 0;
+        RenderBox* normalFlowChildWithoutLines = nullptr;
         for (auto obj = block.firstChildBox(); obj; obj = obj->nextSiblingBox()) {
-            if (obj->isRenderBlockFlow() && shouldCheckLines(toRenderBlockFlow(*obj))) {
-                int result = getHeightForLineCount(toRenderBlockFlow(*obj), lineCount, false, count);
+            if (is<RenderBlockFlow>(*obj) && shouldCheckLines(downcast<RenderBlockFlow>(*obj))) {
+                int result = getHeightForLineCount(downcast<RenderBlockFlow>(*obj), lineCount, false, count);
                 if (result != -1)
                     return result + obj->y() + (includeBottom ? (block.borderBottom() + block.paddingBottom()) : LayoutUnit());
             } else if (!obj->isFloatingOrOutOfFlowPositioned())
index 3aafae2..4898a4d 100644 (file)
@@ -471,7 +471,7 @@ private:
     virtual void paintInlineChildren(PaintInfo&, const LayoutPoint&) override;
     virtual void paintFloats(PaintInfo&, const LayoutPoint&, bool preservePhase = false) override;
 
-    virtual void moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, bool fullRemoveInsert) override;
+    virtual void moveAllChildrenIncludingFloatsTo(RenderBlock& toBlock, bool fullRemoveInsert) override;
     virtual void repaintOverhangingFloats(bool paintAllDescendants) override final;
     virtual void clipOutFloatingObjects(RenderBlock&, const PaintInfo*, const LayoutPoint&, const LayoutSize&) override;
 
@@ -621,11 +621,9 @@ protected:
     friend class LineWidth; // Needs to know FloatingObject
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderBlockFlow, isRenderBlockFlow())
-
 inline bool RenderElement::isRenderNamedFlowFragmentContainer() const
 {
-    return isRenderBlockFlow() && toRenderBlockFlow(this)->renderNamedFlowFragment();
+    return is<RenderBlockFlow>(*this) && downcast<RenderBlockFlow>(*this).renderNamedFlowFragment();
 }
 
 inline const SimpleLineLayout::Layout* RenderBlockFlow::simpleLineLayout() const
index 8210615..90e67e5 100644 (file)
@@ -190,16 +190,16 @@ InlineFlowBox* RenderBlockFlow::createLineBoxes(RenderObject* obj, const LineInf
     // See if we have an unconstructed line box for this object that is also
     // the last item on the line.
     unsigned lineDepth = 1;
-    InlineFlowBox* parentBox = 0;
-    InlineFlowBox* result = 0;
+    InlineFlowBox* parentBox = nullptr;
+    InlineFlowBox* result = nullptr;
     bool hasDefaultLineBoxContain = style().lineBoxContain() == RenderStyle::initialLineBoxContain();
     do {
-        ASSERT_WITH_SECURITY_IMPLICATION(obj->isRenderInline() || obj == this);
+        ASSERT_WITH_SECURITY_IMPLICATION(is<RenderInline>(*obj) || obj == this);
 
-        RenderInline* inlineFlow = (obj != this) ? toRenderInline(obj) : 0;
+        RenderInline* inlineFlow = obj != this ? downcast<RenderInline>(obj) : nullptr;
 
         // Get the last box we made for this render object.
-        parentBox = inlineFlow ? inlineFlow->lastLineBox() : toRenderBlockFlow(obj)->lastRootBox();
+        parentBox = inlineFlow ? inlineFlow->lastLineBox() : downcast<RenderBlockFlow>(*obj).lastRootBox();
 
         // If this box or its ancestor is constructed then it is from a previous line, and we need
         // to make a new box for our line.  If this box or its ancestor is unconstructed but it has
index c9e67f9..a4e3222 100644 (file)
@@ -408,8 +408,8 @@ void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle
         if (viewStyleChanged && view().multiColumnFlowThread())
             view().updateStylesForColumnChildren();
         
-        if (rootStyleChanged && rootRenderer && rootRenderer->isRenderBlockFlow() && toRenderBlockFlow(rootRenderer)->multiColumnFlowThread())
-            toRenderBlockFlow(rootRenderer)->updateStylesForColumnChildren();
+        if (rootStyleChanged && is<RenderBlockFlow>(rootRenderer) && downcast<RenderBlockFlow>(*rootRenderer).multiColumnFlowThread())
+            downcast<RenderBlockFlow>(*rootRenderer).updateStylesForColumnChildren();
     }
 
 #if ENABLE(CSS_SHAPES)
index 73f3ee4..63f79c6 100644 (file)
@@ -611,11 +611,11 @@ void RenderBoxModelObject::paintMaskForTextFillBox(ImageBuffer* maskImage, const
         const RootInlineBox& rootBox = box->root();
         box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y()), rootBox.lineTop(), rootBox.lineBottom());
     } else if (isRenderNamedFlowFragmentContainer()) {
-        RenderNamedFlowFragment* region = toRenderBlockFlow(this)->renderNamedFlowFragment();
-        if (region->isValid())
-            region->flowThread()->layer()->paintNamedFlowThreadInsideRegion(maskImageContext, region, maskRect, maskRect.location(), PaintBehaviorForceBlackText, RenderLayer::PaintLayerTemporaryClipRects);
+        RenderNamedFlowFragment& region = *downcast<RenderBlockFlow>(*this).renderNamedFlowFragment();
+        if (region.isValid())
+            region.flowThread()->layer()->paintNamedFlowThreadInsideRegion(maskImageContext, &region, maskRect, maskRect.location(), PaintBehaviorForceBlackText, RenderLayer::PaintLayerTemporaryClipRects);
     } else {
-        LayoutSize localOffset = isBox() ? toRenderBox(this)->locationOffset() : LayoutSize();
+        LayoutSize localOffset = is<RenderBox>(*this) ? downcast<RenderBox>(*this).locationOffset() : LayoutSize();
         paint(info, scrolledPaintRect.location() - localOffset);
     }
 }
index 7606ad9..01455bb 100644 (file)
@@ -942,18 +942,18 @@ void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool
 
         child->clearOverrideSize();
         if (relayoutChildren || (child->isReplaced() && (child->style().width().isPercent() || child->style().height().isPercent()))
-            || (child->style().height().isAuto() && child->isRenderBlockFlow())) {
+            || (child->style().height().isAuto() && is<RenderBlockFlow>(*child))) {
             child->setChildNeedsLayout(MarkOnlyThis);
 
             // Dirty all the positioned objects.
-            if (child->isRenderBlockFlow()) {
-                toRenderBlockFlow(child)->markPositionedObjectsForLayout();
-                toRenderBlockFlow(child)->clearTruncation();
+            if (is<RenderBlockFlow>(*child)) {
+                downcast<RenderBlockFlow>(*child).markPositionedObjectsForLayout();
+                downcast<RenderBlockFlow>(*child).clearTruncation();
             }
         }
         child->layoutIfNeeded();
-        if (child->style().height().isAuto() && child->isRenderBlockFlow())
-            maxLineCount = std::max(maxLineCount, toRenderBlockFlow(child)->lineCount());
+        if (child->style().height().isAuto() && is<RenderBlockFlow>(*child))
+            maxLineCount = std::max(maxLineCount, downcast<RenderBlockFlow>(*child).lineCount());
     }
 
     // Get the number of lines and then alter all block flow children with auto height to use the
@@ -964,15 +964,15 @@ void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool
         return;
 
     for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
-        if (childDoesNotAffectWidthOrFlexing(child) || !child->style().height().isAuto() || !child->isRenderBlockFlow())
+        if (childDoesNotAffectWidthOrFlexing(child) || !child->style().height().isAuto() || !is<RenderBlockFlow>(*child))
             continue;
 
-        RenderBlockFlow* blockChild = toRenderBlockFlow(child);
-        int lineCount = blockChild->lineCount();
+        RenderBlockFlow& blockChild = downcast<RenderBlockFlow>(*child);
+        int lineCount = blockChild.lineCount();
         if (lineCount <= numVisibleLines)
             continue;
 
-        LayoutUnit newHeight = blockChild->heightForLineCount(numVisibleLines);
+        LayoutUnit newHeight = blockChild.heightForLineCount(numVisibleLines);
         if (newHeight == child->height())
             continue;
 
@@ -985,11 +985,11 @@ void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool
             continue;
 
         // Get the last line
-        RootInlineBox* lastLine = blockChild->lineAtIndex(lineCount - 1);
+        RootInlineBox* lastLine = blockChild.lineAtIndex(lineCount - 1);
         if (!lastLine)
             continue;
 
-        RootInlineBox* lastVisibleLine = blockChild->lineAtIndex(numVisibleLines - 1);
+        RootInlineBox* lastVisibleLine = blockChild.lineAtIndex(numVisibleLines - 1);
         if (!lastVisibleLine)
             continue;
 
@@ -1005,7 +1005,7 @@ void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool
         if (anchorBox && anchorBox->renderer().style().isLink())
             totalWidth = anchorBox->logicalWidth() + font.width(constructTextRun(this, font, ellipsisAndSpace, 2, style()));
         else {
-            anchorBox = 0;
+            anchorBox = nullptr;
             totalWidth = font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style()));
         }
 
@@ -1042,12 +1042,12 @@ void RenderDeprecatedFlexibleBox::clearLineClamp()
 
         child->clearOverrideSize();
         if ((child->isReplaced() && (child->style().width().isPercent() || child->style().height().isPercent()))
-            || (child->style().height().isAuto() && child->isRenderBlock())) {
+            || (child->style().height().isAuto() && is<RenderBlockFlow>(*child))) {
             child->setChildNeedsLayout();
 
-            if (child->isRenderBlockFlow()) {
-                toRenderBlockFlow(child)->markPositionedObjectsForLayout();
-                toRenderBlockFlow(child)->clearTruncation();
+            if (is<RenderBlockFlow>(*child)) {
+                downcast<RenderBlockFlow>(*child).markPositionedObjectsForLayout();
+                downcast<RenderBlockFlow>(*child).clearTruncation();
             }
         }
     }
index a860096..8d9a273 100644 (file)
@@ -92,10 +92,10 @@ void RenderFlowThread::styleDidChange(StyleDifference diff, const RenderStyle* o
 
 void RenderFlowThread::removeFlowChildInfo(RenderObject* child)
 {
-    if (child->isRenderBlockFlow())
-        removeLineRegionInfo(toRenderBlockFlow(child));
-    if (child->isBox())
-        removeRenderBoxRegionInfo(toRenderBox(child));
+    if (is<RenderBlockFlow>(*child))
+        removeLineRegionInfo(downcast<RenderBlockFlow>(child));
+    if (is<RenderBox>(*child))
+        removeRenderBoxRegionInfo(downcast<RenderBox>(child));
 }
 
 void RenderFlowThread::removeRegionFromThread(RenderRegion* renderRegion)
index 7189bfb..c7b0c75 100644 (file)
@@ -412,9 +412,9 @@ void RenderLayer::updateLayerPositions(RenderGeometryMap* geometryMap, UpdateLay
                 if (didRepaint && renderer().isRenderNamedFlowFragmentContainer()) {
                     // If we just repainted a region, we must also repaint the flow thread since it is the one
                     // doing the actual painting of the flowed content.
-                    RenderNamedFlowFragment* region = toRenderBlockFlow(&renderer())->renderNamedFlowFragment();
-                    if (region->isValid())
-                        region->flowThread()->layer()->repaintIncludingDescendants();
+                    RenderNamedFlowFragment& region = *downcast<RenderBlockFlow>(renderer()).renderNamedFlowFragment();
+                    if (region.isValid())
+                        region.flowThread()->layer()->repaintIncludingDescendants();
                 }
             }
         }
@@ -1579,12 +1579,12 @@ static void expandClipRectForRegionAndReflection(LayoutRect& clipRect, const Ren
 {
     // If this is a region, then the painting is actually done by its flow thread's layer.
     if (layer.renderer().isRenderNamedFlowFragmentContainer()) {
-        RenderBlockFlow* regionContainer = toRenderBlockFlow(&layer.renderer());
-        RenderNamedFlowFragment* region = regionContainer->renderNamedFlowFragment();
-        RenderLayer* flowThreadLayer = region->flowThread()->layer();
+        RenderBlockFlow& regionContainer = downcast<RenderBlockFlow>(layer.renderer());
+        RenderNamedFlowFragment& region = *regionContainer.renderNamedFlowFragment();
+        RenderLayer* flowThreadLayer = region.flowThread()->layer();
         if (flowThreadLayer && (!layer.reflection() || layer.reflectionLayer() != flowThreadLayer)) {
             LayoutRect flowThreadClipRect = transparencyClipBox(*flowThreadLayer, rootLayer, transparencyBehavior, DescendantsOfTransparencyClipBox, paintBehavior);
-            LayoutSize moveOffset = (regionContainer->contentBoxRect().location() + layer.offsetFromAncestor(flowThreadLayer)) - region->flowThreadPortionRect().location();
+            LayoutSize moveOffset = (regionContainer.contentBoxRect().location() + layer.offsetFromAncestor(flowThreadLayer)) - region.flowThreadPortionRect().location();
             flowThreadClipRect.move(moveOffset);
             
             clipRect.unite(flowThreadClipRect);
@@ -6160,15 +6160,15 @@ void RenderLayer::updateCompositingAndLayerListsIfNeeded()
 void RenderLayer::repaintIncludingDescendants()
 {
     renderer().repaint();
-    for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling())
-        curr->repaintIncludingDescendants();
+    for (RenderLayer* current = firstChild(); current; current = current->nextSibling())
+        current->repaintIncludingDescendants();
 
     // If this is a region, we must also repaint the flow thread's layer since it is the one
     // doing the actual painting of the flowed content, but only if the region is valid.
     if (renderer().isRenderNamedFlowFragmentContainer()) {
-        RenderNamedFlowFragment* region = toRenderBlockFlow(renderer()).renderNamedFlowFragment();
-        if (region->isValid())
-            region->flowThread()->layer()->repaintIncludingDescendants();
+        RenderNamedFlowFragment& region = *downcast<RenderBlockFlow>(renderer()).renderNamedFlowFragment();
+        if (region.isValid())
+            region.flowThread()->layer()->repaintIncludingDescendants();
     }
 }
 
@@ -6730,8 +6730,8 @@ void RenderLayer::paintFlowThreadIfRegionForFragments(const LayerFragments& frag
     if (!renderer().isRenderNamedFlowFragmentContainer())
         return;
     
-    RenderBlockFlow* renderNamedFlowFragmentContainer = toRenderBlockFlow(&renderer());
-    RenderNamedFlowFragment* flowFragment = renderNamedFlowFragmentContainer->renderNamedFlowFragment();
+    RenderBlockFlow& renderNamedFlowFragmentContainer = downcast<RenderBlockFlow>(renderer());
+    RenderNamedFlowFragment* flowFragment = renderNamedFlowFragmentContainer.renderNamedFlowFragment();
     if (!flowFragment->isValid())
         return;
 
@@ -6740,7 +6740,7 @@ void RenderLayer::paintFlowThreadIfRegionForFragments(const LayerFragments& frag
 
     LayoutRect regionClipRect = LayoutRect::infiniteRect();
     if (flowFragment->shouldClipFlowThreadContent()) {
-        regionClipRect = renderNamedFlowFragmentContainer->paddingBoxRect();
+        regionClipRect = renderNamedFlowFragmentContainer.paddingBoxRect();
 
         // When the layer of the flow fragment's container is composited, the flow fragment container receives a
         // GraphicsLayer of its own so the clipping coordinates (caused by overflow:hidden) must be relative to the
@@ -6778,23 +6778,23 @@ RenderLayer* RenderLayer::hitTestFlowThreadIfRegionForFragments(const LayerFragm
     const HitTestingTransformState* unflattenedTransformState, bool depthSortDescendants)
 {
     if (!renderer().isRenderNamedFlowFragmentContainer())
-        return 0;
+        return nullptr;
 
-    RenderNamedFlowFragment* region = toRenderBlockFlow(&renderer())->renderNamedFlowFragment();
-    if (!region->isValid())
-        return 0;
+    RenderNamedFlowFragment& region = *downcast<RenderBlockFlow>(renderer()).renderNamedFlowFragment();
+    if (!region.isValid())
+        return nullptr;
 
-    RenderFlowThread* flowThread = region->flowThread();
-    LayoutPoint portionLocation = region->flowThreadPortionRect().location();
+    RenderFlowThread* flowThread = region.flowThread();
+    LayoutPoint portionLocation = region.flowThreadPortionRect().location();
     if (flowThread->style().isFlippedBlocksWritingMode()) {
         // The portion location coordinate must be translated into physical coordinates.
         if (flowThread->style().isHorizontalWritingMode())
-            portionLocation.setY(flowThread->height() - (portionLocation.y() + region->contentHeight()));
+            portionLocation.setY(flowThread->height() - (portionLocation.y() + region.contentHeight()));
         else
-            portionLocation.setX(flowThread->width() - (portionLocation.x() + region->contentWidth()));
+            portionLocation.setX(flowThread->width() - (portionLocation.x() + region.contentWidth()));
     }
 
-    LayoutRect regionContentBox = toRenderBlockFlow(&renderer())->contentBoxRect();
+    LayoutRect regionContentBox = downcast<RenderBlockFlow>(renderer()).contentBoxRect();
 
     RenderLayer* resultLayer = nullptr;
     for (int i = fragments.size() - 1; i >= 0; --i) {
@@ -6803,7 +6803,7 @@ RenderLayer* RenderLayer::hitTestFlowThreadIfRegionForFragments(const LayerFragm
         if (!fragment.backgroundRect.intersects(hitTestLocation))
             continue;
 
-        LayoutSize hitTestOffset = portionLocation - (fragment.layerBounds.location() + regionContentBox.location()) + region->fragmentContainer().scrolledContentOffset();
+        LayoutSize hitTestOffset = portionLocation - (fragment.layerBounds.location() + regionContentBox.location()) + region.fragmentContainer().scrolledContentOffset();
 
         // Always ignore clipping, since the RenderFlowThread has nothing to do with the bounds of the FrameView.
         HitTestRequest newRequest(request.type() | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowShadowContent);
@@ -6817,10 +6817,10 @@ RenderLayer* RenderLayer::hitTestFlowThreadIfRegionForFragments(const LayerFragm
         hitTestRectInFlowThread.expand(LayoutSize(fabs((double)hitTestOffset.width()), fabs((double)hitTestOffset.height())));
 
         CurrentRenderFlowThreadMaintainer flowThreadMaintainer(flowThread);
-        CurrentRenderRegionMaintainer regionMaintainer(*region);
+        CurrentRenderRegionMaintainer regionMaintainer(region);
 
         HitTestResult tempResult(result.hitTestLocation());
-        RenderLayer* hitLayer = flowThread->layer()->hitTestLayer(flowThread->layer(), 0, newRequest, tempResult, hitTestRectInFlowThread, newHitTestLocation, false, transformState, zOffsetForDescendants);
+        RenderLayer* hitLayer = flowThread->layer()->hitTestLayer(flowThread->layer(), nullptr, newRequest, tempResult, hitTestRectInFlowThread, newHitTestLocation, false, transformState, zOffsetForDescendants);
         if (result.isRectBasedTest())
             result.append(tempResult);
         if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedTransformState)) {
index 459bd94..4c8fe2e 100644 (file)
@@ -1287,7 +1287,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
         // anonymous RenderRegion, but first we need to make sure that the parent itself of the region is going to
         // have a composited layer. We only want to make regions composited when there's an actual layer that we
         // need to move to that region.
-        computeRegionCompositingRequirements(toRenderBlockFlow(layer.renderer()).renderNamedFlowFragment(), overlapMap, childState, layersChanged, anyDescendantHas3DTransform);
+        computeRegionCompositingRequirements(downcast<RenderBlockFlow>(layer.renderer()).renderNamedFlowFragment(), overlapMap, childState, layersChanged, anyDescendantHas3DTransform);
     }
 
     
@@ -1544,7 +1544,7 @@ void RenderLayerCompositor::rebuildCompositingLayerTree(RenderLayer& layer, Vect
     }
 
     if (layer.renderer().isRenderNamedFlowFragmentContainer())
-        rebuildRegionCompositingLayerTree(toRenderBlockFlow(layer.renderer()).renderNamedFlowFragment(), layerChildren, depth + 1);
+        rebuildRegionCompositingLayerTree(downcast<RenderBlockFlow>(layer.renderer()).renderNamedFlowFragment(), layerChildren, depth + 1);
 
     if (Vector<RenderLayer*>* normalFlowList = layer.normalFlowList()) {
         for (size_t i = 0, size = normalFlowList->size(); i < size; ++i)
index 7dfe836..51b17d8 100644 (file)
@@ -183,9 +183,9 @@ void RenderMultiColumnFlowThread::evacuateAndDestroy()
     while ((it = m_spannerMap.begin()) != m_spannerMap.end()) {
         RenderBox* spanner = it->key;
         RenderMultiColumnSpannerPlaceholder* placeholder = it->value;
-        RenderBlockFlow* originalContainer = toRenderBlockFlow(placeholder->parent());
+        RenderBlockFlow& originalContainer = downcast<RenderBlockFlow>(*placeholder->parent());
         multicolContainer->removeChild(*spanner);
-        originalContainer->addChild(spanner, placeholder);
+        originalContainer.addChild(spanner, placeholder);
         placeholder->destroy();
         m_spannerMap.remove(it);
     }
@@ -296,7 +296,7 @@ RenderObject* RenderMultiColumnFlowThread::processPossibleSpannerDescendant(Rend
         // so that they live among the column sets. This simplifies the layout implementation, and
         // basically just relies on regular block layout done by the RenderBlockFlow that
         // establishes the multicol container.
-        RenderBlockFlow* container = toRenderBlockFlow(descendant->parent());
+        RenderBlockFlow* container = downcast<RenderBlockFlow>(descendant->parent());
         RenderMultiColumnSet* setToSplit = nullptr;
         if (nextRendererInFlowThread) {
             setToSplit = findSetRendering(descendant);
@@ -311,7 +311,7 @@ RenderObject* RenderMultiColumnFlowThread::processPossibleSpannerDescendant(Rend
         // content before and after the spanner, so that it becomes separate line boxes. Secondly,
         // this placeholder serves as a break point for column sets, so that, when encountered, we
         // end flowing one column set and move to the next one.
-        RenderMultiColumnSpannerPlaceholder* placeholder = RenderMultiColumnSpannerPlaceholder::createAnonymous(this, toRenderBox(descendant), &container->style());
+        RenderMultiColumnSpannerPlaceholder* placeholder = RenderMultiColumnSpannerPlaceholder::createAnonymous(this, downcast<RenderBox>(descendant), &container->style());
         container->addChild(placeholder, descendant->nextSibling());
         container->removeChild(*descendant);
         
@@ -329,14 +329,14 @@ RenderObject* RenderMultiColumnFlowThread::processPossibleSpannerDescendant(Rend
         nextDescendant = placeholder;
     } else {
         // This is regular multicol content, i.e. not part of a spanner.
-        if (nextRendererInFlowThread && nextRendererInFlowThread->isRenderMultiColumnSpannerPlaceholder()) {
+        if (is<RenderMultiColumnSpannerPlaceholder>(nextRendererInFlowThread)) {
             // Inserted right before a spanner. Is there a set for us there?
-            RenderMultiColumnSpannerPlaceholder* placeholder = toRenderMultiColumnSpannerPlaceholder(nextRendererInFlowThread);
-            if (RenderObject* previous = placeholder->spanner()->previousSibling()) {
-                if (previous->isRenderMultiColumnSet())
+            RenderMultiColumnSpannerPlaceholder& placeholder = downcast<RenderMultiColumnSpannerPlaceholder>(*nextRendererInFlowThread);
+            if (RenderObject* previous = placeholder.spanner()->previousSibling()) {
+                if (is<RenderMultiColumnSet>(*previous))
                     return nextDescendant; // There's already a set there. Nothing to do.
             }
-            insertBeforeMulticolChild = placeholder->spanner();
+            insertBeforeMulticolChild = placeholder.spanner();
         } else if (RenderMultiColumnSet* lastSet = lastMultiColumnSet()) {
             // This child is not an immediate predecessor of a spanner, which means that if this
             // child precedes a spanner at all, there has to be a column set created for us there
@@ -383,13 +383,13 @@ void RenderMultiColumnFlowThread::flowThreadDescendantInserted(RenderObject* des
                 
                 // Insert after the placeholder, but don't let a notification happen.
                 gShiftingSpanner = true;
-                RenderBlockFlow* ancestorBlock = toRenderBlockFlow(spanner->parent());
-                ancestorBlock->moveChildTo(placeholder->parentBox(), spanner, placeholder->nextSibling(), true);
+                RenderBlockFlow& ancestorBlock = downcast<RenderBlockFlow>(*spanner->parent());
+                ancestorBlock.moveChildTo(placeholder->parentBox(), spanner, placeholder->nextSibling(), true);
                 gShiftingSpanner = false;
                 
                 // We have to nuke the placeholder, since the ancestor already lost the mapping to it when
                 // we shifted the placeholder down into this flow thread.
-                ancestorBlock->multiColumnFlowThread()->handleSpannerRemoval(spanner);
+                ancestorBlock.multiColumnFlowThread()->handleSpannerRemoval(spanner);
                 placeholder->destroy();
                 
                 // Now we process the spanner.
index 7f74e72..6c79df3 100644 (file)
@@ -45,7 +45,7 @@ public:
 
     virtual void removeFlowChildInfo(RenderObject*) override;
 
-    RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(parent()); }
+    RenderBlockFlow* multiColumnBlockFlow() const { return downcast<RenderBlockFlow>(parent()); }
 
     RenderMultiColumnSet* firstMultiColumnSet() const;
     RenderMultiColumnSet* lastMultiColumnSet() const;
index 5dcec6c..a3cc6e7 100644 (file)
@@ -137,8 +137,8 @@ void RenderMultiColumnSet::setLogicalBottomInFlowThread(LayoutUnit logicalBottom
 
 LayoutUnit RenderMultiColumnSet::heightAdjustedForSetOffset(LayoutUnit height) const
 {
-    RenderBlockFlow* multicolBlock = toRenderBlockFlow(parent());
-    LayoutUnit contentLogicalTop = logicalTop() - multicolBlock->borderAndPaddingBefore();
+    RenderBlockFlow& multicolBlock = downcast<RenderBlockFlow>(*parent());
+    LayoutUnit contentLogicalTop = logicalTop() - multicolBlock.borderAndPaddingBefore();
 
     height -= contentLogicalTop;
     return std::max(height, LayoutUnit::fromPixel(1)); // Let's avoid zero height, as that would probably cause an infinite amount of columns to be created.
@@ -421,10 +421,10 @@ LayoutUnit RenderMultiColumnSet::columnGap() const
 {
     // FIXME: Eventually we will cache the column gap when the widths of columns start varying, but for now we just
     // go to the parent block to get the gap.
-    RenderBlockFlow* parentBlock = toRenderBlockFlow(parent());
-    if (parentBlock->style().hasNormalColumnGap())
-        return parentBlock->style().fontDescription().computedPixelSize(); // "1em" is recommended as the normal gap setting. Matches <p> margins.
-    return parentBlock->style().columnGap();
+    RenderBlockFlow& parentBlock = downcast<RenderBlockFlow>(*parent());
+    if (parentBlock.style().hasNormalColumnGap())
+        return parentBlock.style().fontDescription().computedPixelSize(); // "1em" is recommended as the normal gap setting. Matches <p> margins.
+    return parentBlock.style().columnGap();
 }
 
 unsigned RenderMultiColumnSet::columnCount() const
index cf0c04e..f930b77 100644 (file)
@@ -49,7 +49,7 @@ public:
 
     virtual bool isRenderMultiColumnSet() const override { return true; }
 
-    RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(parent()); }
+    RenderBlockFlow* multiColumnBlockFlow() const { return downcast<RenderBlockFlow>(parent()); }
     RenderMultiColumnFlowThread* multiColumnFlowThread() const { return static_cast<RenderMultiColumnFlowThread*>(flowThread()); }
 
     RenderMultiColumnSet* nextSiblingMultiColumnSet() const;
index 1664d47..70196e5 100644 (file)
@@ -231,7 +231,7 @@ RenderBlockFlow& RenderNamedFlowFragment::fragmentContainer() const
 {
     ASSERT(parent());
     ASSERT(parent()->isRenderNamedFlowFragmentContainer());
-    return *toRenderBlockFlow(parent());
+    return downcast<RenderBlockFlow>(*parent());
 }
 
 RenderLayer& RenderNamedFlowFragment::fragmentContainerLayer() const
index fa7226c..6ad69f4 100644 (file)
@@ -437,8 +437,8 @@ void RenderObject::adjustComputedFontSizesOnBlocks(float size, float visibleWidt
             depthStack.append(newFixedDepth);
 
         int stackSize = depthStack.size();
-        if (descendent->isRenderBlockFlow() && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
-            toRenderBlockFlow(descendent)->adjustComputedFontSizes(size, visibleWidth);
+        if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
+            downcast<RenderBlockFlow>(*descendent).adjustComputedFontSizes(size, visibleWidth);
         newFixedDepth = 0;
     }
 
@@ -465,8 +465,8 @@ void RenderObject::resetTextAutosizing()
             depthStack.append(newFixedDepth);
 
         int stackSize = depthStack.size();
-        if (descendent->isRenderBlockFlow() && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
-            toRenderBlockFlow(descendent)->resetComputedFontSize();
+        if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
+            downcast<RenderBlockFlow>(*descendent).resetComputedFontSize();
         newFixedDepth = 0;
     }
 }
@@ -1429,11 +1429,11 @@ void RenderObject::showRenderTreeForThis() const
 
 void RenderObject::showLineTreeForThis() const
 {
-    if (!isRenderBlockFlow())
+    if (!is<RenderBlockFlow>(*this))
         return;
     showRenderTreeLegend();
     showRenderObject(false, 1);
-    toRenderBlockFlow(this)->showLineTreeAndMark(nullptr, 2);
+    downcast<RenderBlockFlow>(*this).showLineTreeAndMark(nullptr, 2);
 }
 
 void RenderObject::showRegionsInformation() const
@@ -1586,8 +1586,8 @@ void RenderObject::showRenderSubTreeAndMark(const RenderObject* markedObject, in
 #endif
 
     showRenderObject(markedObject == this, depth);
-    if (isRenderBlockFlow())
-        toRenderBlockFlow(this)->showLineTreeAndMark(nullptr, depth + 1);
+    if (is<RenderBlockFlow>(*this))
+        downcast<RenderBlockFlow>(*this).showLineTreeAndMark(nullptr, depth + 1);
 
     for (const RenderObject* child = firstChildSlow(); child; child = child->nextSibling())
         child->showRenderSubTreeAndMark(markedObject, depth + 1);
index c7afe5f..d02559e 100644 (file)
@@ -1102,8 +1102,8 @@ void RenderText::setText(const String& text, bool force)
     setNeedsLayoutAndPrefWidthsRecalc();
     m_knownToHaveNoOverflowAndNoFallbackFonts = false;
 
-    if (parent()->isRenderBlockFlow())
-        toRenderBlockFlow(parent())->invalidateLineLayoutPath();
+    if (is<RenderBlockFlow>(*parent()))
+        downcast<RenderBlockFlow>(*parent()).invalidateLineLayoutPath();
     
     if (AXObjectCache* cache = document().existingAXObjectCache())
         cache->textChanged(this);
@@ -1149,16 +1149,16 @@ void RenderText::positionLineBox(InlineTextBox& textBox)
 
 void RenderText::ensureLineBoxes()
 {
-    if (!parent()->isRenderBlockFlow())
+    if (!is<RenderBlockFlow>(*parent()))
         return;
-    toRenderBlockFlow(parent())->ensureLineBoxes();
+    downcast<RenderBlockFlow>(*parent()).ensureLineBoxes();
 }
 
 const SimpleLineLayout::Layout* RenderText::simpleLineLayout() const
 {
-    if (!parent()->isRenderBlockFlow())
+    if (!is<RenderBlockFlow>(*parent()))
         return nullptr;
-    return toRenderBlockFlow(parent())->simpleLineLayout();
+    return downcast<RenderBlockFlow>(*parent()).simpleLineLayout();
 }
 
 float RenderText::width(unsigned from, unsigned len, float xPos, bool firstLine, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
index 39b744e..0897ea3 100644 (file)
@@ -542,7 +542,7 @@ void write(TextStream& ts, const RenderObject& o, int indent, RenderAsTextBehavi
         auto& text = downcast<RenderText>(o);
         if (auto layout = text.simpleLineLayout()) {
             ASSERT(!text.firstTextBox());
-            auto resolver = runResolver(toRenderBlockFlow(*text.parent()), *layout);
+            auto resolver = runResolver(downcast<RenderBlockFlow>(*text.parent()), *layout);
             for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
                 auto run = *it;
                 writeIndent(ts, indent + 1);
index dc84ba1..931001e 100644 (file)
@@ -630,8 +630,8 @@ LayoutUnit RootInlineBox::selectionTopAdjustedForPrecedingBlock() const
 
     LayoutSize offsetToBlockBefore;
     if (RenderBlock* block = rootBox.blockFlow().blockBeforeWithinSelectionRoot(offsetToBlockBefore)) {
-        if (block->isRenderBlockFlow()) {
-            if (RootInlineBox* lastLine = toRenderBlockFlow(block)->lastRootBox()) {
+        if (is<RenderBlockFlow>(*block)) {
+            if (RootInlineBox* lastLine = downcast<RenderBlockFlow>(*block).lastRootBox()) {
                 RenderObject::SelectionState lastLineSelectionState = lastLine->selectionState();
                 if (lastLineSelectionState != RenderObject::SelectionInside && lastLineSelectionState != RenderObject::SelectionStart)
                     return top;
@@ -678,7 +678,7 @@ int RootInlineBox::blockDirectionPointInLine() const
 
 RenderBlockFlow& RootInlineBox::blockFlow() const
 {
-    return toRenderBlockFlow(renderer());
+    return downcast<RenderBlockFlow>(renderer());
 }
 
 static bool isEditableLeaf(InlineBox* leaf)
index 60abfb2..6a7c3b1 100644 (file)
@@ -140,7 +140,7 @@ void collectFlowOverflow(RenderBlockFlow& flow, const Layout& layout)
 
 IntRect computeTextBoundingBox(const RenderText& textRenderer, const Layout& layout)
 {
-    auto resolver = lineResolver(toRenderBlockFlow(*textRenderer.parent()), layout);
+    auto resolver = lineResolver(downcast<RenderBlockFlow>(*textRenderer.parent()), layout);
     auto it = resolver.begin();
     auto end = resolver.end();
     if (it == end)
@@ -167,7 +167,7 @@ IntRect computeTextBoundingBox(const RenderText& textRenderer, const Layout& lay
 
 IntPoint computeTextFirstRunLocation(const RenderText& textRenderer, const Layout& layout)
 {
-    auto resolver = runResolver(toRenderBlockFlow(*textRenderer.parent()), layout);
+    auto resolver = runResolver(downcast<RenderBlockFlow>(*textRenderer.parent()), layout);
     auto begin = resolver.begin();
     if (begin == resolver.end())
         return IntPoint();
@@ -177,7 +177,7 @@ IntPoint computeTextFirstRunLocation(const RenderText& textRenderer, const Layou
 Vector<IntRect> collectTextAbsoluteRects(const RenderText& textRenderer, const Layout& layout, const LayoutPoint& accumulatedOffset)
 {
     Vector<IntRect> rects;
-    auto resolver = runResolver(toRenderBlockFlow(*textRenderer.parent()), layout);
+    auto resolver = runResolver(downcast<RenderBlockFlow>(*textRenderer.parent()), layout);
     for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
         const auto& run = *it;
         auto rect = run.rect();
@@ -189,7 +189,7 @@ Vector<IntRect> collectTextAbsoluteRects(const RenderText& textRenderer, const L
 Vector<FloatQuad> collectTextAbsoluteQuads(const RenderText& textRenderer, const Layout& layout, bool* wasFixed)
 {
     Vector<FloatQuad> quads;
-    auto resolver = runResolver(toRenderBlockFlow(*textRenderer.parent()), layout);
+    auto resolver = runResolver(downcast<RenderBlockFlow>(*textRenderer.parent()), layout);
     for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
         const auto& run = *it;
         auto rect = run.rect();
index e468416..cfd6c12 100644 (file)
@@ -50,12 +50,12 @@ struct SVGTextQuery::Data {
 static inline InlineFlowBox* flowBoxForRenderer(RenderObject* renderer)
 {
     if (!renderer)
-        return 0;
+        return nullptr;
 
-    if (renderer->isRenderBlockFlow()) {
+    if (is<RenderBlockFlow>(*renderer)) {
         // If we're given a block element, it has to be a RenderSVGText.
-        ASSERT(renderer->isSVGText());
-        RenderBlockFlow& renderBlock = toRenderBlockFlow(*renderer);
+        ASSERT(is<RenderSVGText>(*renderer));
+        RenderBlockFlow& renderBlock = downcast<RenderBlockFlow>(*renderer);
 
         // RenderSVGText only ever contains a single line box.
         auto flowBox = renderBlock.firstRootBox();
@@ -63,9 +63,9 @@ static inline InlineFlowBox* flowBoxForRenderer(RenderObject* renderer)
         return flowBox;
     }
 
-    if (renderer->isRenderInline()) {
+    if (is<RenderInline>(*renderer)) {
         // We're given a RenderSVGInline or objects that derive from it (RenderSVGTSpan / RenderSVGTextPath)
-        RenderInline& renderInline = toRenderInline(*renderer);
+        RenderInline& renderInline = downcast<RenderInline>(*renderer);
 
         // RenderSVGInline only ever contains a single line box.
         InlineFlowBox* flowBox = renderInline.firstLineBox();
@@ -74,7 +74,7 @@ static inline InlineFlowBox* flowBoxForRenderer(RenderObject* renderer)
     }
 
     ASSERT_NOT_REACHED();
-    return 0;
+    return nullptr;
 }
 
 SVGTextQuery::SVGTextQuery(RenderObject* renderer)