Use is<>() / downcast<>() for RenderInline
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Oct 2014 00:29:51 +0000 (00:29 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Oct 2014 00:29:51 +0000 (00:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137704

Reviewed by Darin Adler.

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

No new tests, no behavior change.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::firstChildInContinuation):
* editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply):
* inspector/InspectorOverlay.cpp:
(WebCore::buildRendererHighlight):
* page/FrameView.cpp:
(WebCore::FrameView::paintContents):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::removeLineBoxFromRenderObject):
(WebCore::InlineFlowBox::extractLineBoxFromRenderObject):
(WebCore::InlineFlowBox::attachLineBoxToRenderObject):
(WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
(WebCore::InlineFlowBox::nodeAtPoint):
(WebCore::InlineFlowBox::paint):
* rendering/InlineIterator.h:
(WebCore::bidiFirstSkippingEmptyInlines):
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::willBeDestroyed):
(WebCore::RenderBlock::paintObject):
(WebCore::RenderBlock::inlineElementContinuation):
(WebCore::RenderBlock::addFocusRingRects):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::willBeDestroyed):
(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths):
* rendering/RenderBlockFlow.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::constructBidiRunsForSegment):
(WebCore::RenderBlockFlow::layoutLineBoxes):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::offsetFromContainer):
(WebCore::RenderBox::computeRectForRepaint):
(WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
(WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
(WebCore::RenderBox::computePositionedLogicalWidthUsing):
(WebCore::RenderBox::computePositionedLogicalWidthReplaced):
(WebCore::RenderBox::layoutOverflowRectForPropagation):
* rendering/RenderBoxModelObject.cpp:
(WebCore::accumulateInFlowPositionOffsets):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::willBeRemovedFromTree):
* rendering/RenderElement.h:
(WebCore::RenderElement::dirtyLinesFromChangedChild):
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::addRegionsOverflowFromChild):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
(WebCore::RenderInline::updateAlwaysCreateLineBoxes):
(WebCore::RenderInline::clippedOverflowRectForRepaint):
* rendering/RenderInline.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPosition):
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLineBoxList.cpp:
(WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):
* rendering/RenderLineBoxList.h:
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::insertedIntoTree):
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::overflowRectForFlowThreadPortion):
(WebCore::RenderRegion::visualOverflowRectForBox):
(WebCore::RenderRegion::visualOverflowRectForBoxForPropagation):
* rendering/RenderRegion.h:
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::willBeDestroyed):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::removeAllFromParent):
(WebCore::RenderTextLineBoxes::dirtyRange):
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::inlineLogicalWidth):
(WebCore::BreakingContext::handleEmptyInline):
* rendering/line/LineInlineHeaders.h:
(WebCore::requiresLineBox):
(WebCore::setStaticPositions):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paint):

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

31 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/editing/SimplifyMarkupCommand.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineIterator.h
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/RenderBlock.cpp
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/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLineBoxList.cpp
Source/WebCore/rendering/RenderLineBoxList.h
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderRegion.cpp
Source/WebCore/rendering/RenderRegion.h
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderTextLineBoxes.cpp
Source/WebCore/rendering/line/BreakingContextInlineHeaders.h
Source/WebCore/rendering/line/LineInlineHeaders.h
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

index 26f2f4a..81730db 100644 (file)
@@ -1,3 +1,96 @@
+2014-10-14  Chris Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for RenderInline
+        https://bugs.webkit.org/show_bug.cgi?id=137704
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for RenderInline and clean up the surrounding
+        code.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::firstChildInContinuation):
+        * editing/SimplifyMarkupCommand.cpp:
+        (WebCore::SimplifyMarkupCommand::doApply):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::buildRendererHighlight):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::paintContents):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::removeLineBoxFromRenderObject):
+        (WebCore::InlineFlowBox::extractLineBoxFromRenderObject):
+        (WebCore::InlineFlowBox::attachLineBoxToRenderObject):
+        (WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
+        (WebCore::InlineFlowBox::nodeAtPoint):
+        (WebCore::InlineFlowBox::paint):
+        * rendering/InlineIterator.h:
+        (WebCore::bidiFirstSkippingEmptyInlines):
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::LayoutState):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::willBeDestroyed):
+        (WebCore::RenderBlock::paintObject):
+        (WebCore::RenderBlock::inlineElementContinuation):
+        (WebCore::RenderBlock::addFocusRingRects):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::willBeDestroyed):
+        (WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths):
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::constructBidiRunsForSegment):
+        (WebCore::RenderBlockFlow::layoutLineBoxes):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::offsetFromContainer):
+        (WebCore::RenderBox::computeRectForRepaint):
+        (WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
+        (WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
+        (WebCore::RenderBox::computePositionedLogicalWidthUsing):
+        (WebCore::RenderBox::computePositionedLogicalWidthReplaced):
+        (WebCore::RenderBox::layoutOverflowRectForPropagation):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::accumulateInFlowPositionOffsets):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::willBeRemovedFromTree):
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::dirtyLinesFromChangedChild):
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::addRegionsOverflowFromChild):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::willBeDestroyed):
+        (WebCore::RenderInline::updateAlwaysCreateLineBoxes):
+        (WebCore::RenderInline::clippedOverflowRectForRepaint):
+        * rendering/RenderInline.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPosition):
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLineBoxList.cpp:
+        (WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):
+        * rendering/RenderLineBoxList.h:
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::insertedIntoTree):
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::overflowRectForFlowThreadPortion):
+        (WebCore::RenderRegion::visualOverflowRectForBox):
+        (WebCore::RenderRegion::visualOverflowRectForBoxForPropagation):
+        * rendering/RenderRegion.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::willBeDestroyed):
+        * rendering/RenderTextLineBoxes.cpp:
+        (WebCore::RenderTextLineBoxes::removeAllFromParent):
+        (WebCore::RenderTextLineBoxes::dirtyRange):
+        * rendering/line/BreakingContextInlineHeaders.h:
+        (WebCore::inlineLogicalWidth):
+        (WebCore::BreakingContext::handleEmptyInline):
+        * rendering/line/LineInlineHeaders.h:
+        (WebCore::requiresLineBox):
+        (WebCore::setStaticPositions):
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paint):
+
 2014-10-14  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Unreviewed build fix after r174710.
index 4106c3c..a998ca2 100644 (file)
@@ -170,11 +170,11 @@ static inline RenderObject* firstChildInContinuation(RenderInline& renderer)
     auto continuation = renderer.continuation();
 
     while (continuation) {
-        if (continuation->isRenderBlock())
+        if (is<RenderBlock>(*continuation))
             return continuation;
         if (RenderObject* child = continuation->firstChild())
             return child;
-        continuation = toRenderInline(continuation)->continuation();
+        continuation = downcast<RenderInline>(*continuation).continuation();
     }
 
     return nullptr;
index c7c9a68..13cda36 100644 (file)
@@ -61,7 +61,7 @@ void SimplifyMarkupCommand::doApply()
         if (!startingStyle)
             continue;
         Node* currentNode = startingNode;
-        Node* topNodeWithStartingStyle = 0;
+        Node* topNodeWithStartingStyle = nullptr;
         while (currentNode != rootNode) {
             if (currentNode->parentNode() != rootNode && isRemovableBlock(currentNode))
                 nodesToRemove.append(currentNode);
@@ -70,11 +70,11 @@ void SimplifyMarkupCommand::doApply()
             if (!currentNode)
                 break;
 
-            if (!currentNode->renderer() || !currentNode->renderer()->isRenderInline() || toRenderInline(currentNode->renderer())->alwaysCreateLineBoxes())
+            if (!is<RenderInline>(currentNode->renderer()) || downcast<RenderInline>(*currentNode->renderer()).alwaysCreateLineBoxes())
                 continue;
             
             if (currentNode->firstChild() != currentNode->lastChild()) {
-                topNodeWithStartingStyle = 0;
+                topNodeWithStartingStyle = nullptr;
                 break;
             }
             
index 2db7f1a..9233e6c 100644 (file)
@@ -97,43 +97,43 @@ static void buildRendererHighlight(RenderObject* renderer, RenderRegion* region,
         renderer->absoluteQuads(highlight->quads);
         for (size_t i = 0; i < highlight->quads.size(); ++i)
             contentsQuadToCoordinateSystem(mainView, containingView, highlight->quads[i], coordinateSystem);
-    } else if (renderer->isBox() || renderer->isRenderInline()) {
+    } else if (is<RenderBox>(*renderer) || is<RenderInline>(*renderer)) {
         LayoutRect contentBox;
         LayoutRect paddingBox;
         LayoutRect borderBox;
         LayoutRect marginBox;
 
-        if (renderer->isBox()) {
-            RenderBox* renderBox = toRenderBox(renderer);
+        if (is<RenderBox>(*renderer)) {
+            auto& renderBox = downcast<RenderBox>(*renderer);
 
-            LayoutBoxExtent margins(renderBox->marginTop(), renderBox->marginRight(), renderBox->marginBottom(), renderBox->marginLeft());
+            LayoutBoxExtent margins(renderBox.marginTop(), renderBox.marginRight(), renderBox.marginBottom(), renderBox.marginLeft());
 
-            if (!renderBox->isOutOfFlowPositioned() && region) {
+            if (!renderBox.isOutOfFlowPositioned() && region) {
                 RenderBox::LogicalExtentComputedValues computedValues;
-                renderBox->computeLogicalWidthInRegion(computedValues, region);
-                margins.mutableLogicalLeft(renderBox->style().writingMode()) = computedValues.m_margins.m_start;
-                margins.mutableLogicalRight(renderBox->style().writingMode()) = computedValues.m_margins.m_end;
+                renderBox.computeLogicalWidthInRegion(computedValues, region);
+                margins.mutableLogicalLeft(renderBox.style().writingMode()) = computedValues.m_margins.m_start;
+                margins.mutableLogicalRight(renderBox.style().writingMode()) = computedValues.m_margins.m_end;
             }
 
-            paddingBox = renderBox->clientBoxRectInRegion(region);
-            contentBox = LayoutRect(paddingBox.x() + renderBox->paddingLeft(), paddingBox.y() + renderBox->paddingTop(),
-                paddingBox.width() - renderBox->paddingLeft() - renderBox->paddingRight(), paddingBox.height() - renderBox->paddingTop() - renderBox->paddingBottom());
-            borderBox = LayoutRect(paddingBox.x() - renderBox->borderLeft(), paddingBox.y() - renderBox->borderTop(),
-                paddingBox.width() + renderBox->borderLeft() + renderBox->borderRight(), paddingBox.height() + renderBox->borderTop() + renderBox->borderBottom());
+            paddingBox = renderBox.clientBoxRectInRegion(region);
+            contentBox = LayoutRect(paddingBox.x() + renderBox.paddingLeft(), paddingBox.y() + renderBox.paddingTop(),
+                paddingBox.width() - renderBox.paddingLeft() - renderBox.paddingRight(), paddingBox.height() - renderBox.paddingTop() - renderBox.paddingBottom());
+            borderBox = LayoutRect(paddingBox.x() - renderBox.borderLeft(), paddingBox.y() - renderBox.borderTop(),
+                paddingBox.width() + renderBox.borderLeft() + renderBox.borderRight(), paddingBox.height() + renderBox.borderTop() + renderBox.borderBottom());
             marginBox = LayoutRect(borderBox.x() - margins.left(), borderBox.y() - margins.top(),
                 borderBox.width() + margins.left() + margins.right(), borderBox.height() + margins.top() + margins.bottom());
         } else {
-            RenderInline* renderInline = toRenderInline(renderer);
+            auto& renderInline = downcast<RenderInline>(*renderer);
 
             // RenderInline's bounding box includes paddings and borders, excludes margins.
-            borderBox = renderInline->linesBoundingBox();
-            paddingBox = LayoutRect(borderBox.x() + renderInline->borderLeft(), borderBox.y() + renderInline->borderTop(),
-                borderBox.width() - renderInline->borderLeft() - renderInline->borderRight(), borderBox.height() - renderInline->borderTop() - renderInline->borderBottom());
-            contentBox = LayoutRect(paddingBox.x() + renderInline->paddingLeft(), paddingBox.y() + renderInline->paddingTop(),
-                paddingBox.width() - renderInline->paddingLeft() - renderInline->paddingRight(), paddingBox.height() - renderInline->paddingTop() - renderInline->paddingBottom());
+            borderBox = renderInline.linesBoundingBox();
+            paddingBox = LayoutRect(borderBox.x() + renderInline.borderLeft(), borderBox.y() + renderInline.borderTop(),
+                borderBox.width() - renderInline.borderLeft() - renderInline.borderRight(), borderBox.height() - renderInline.borderTop() - renderInline.borderBottom());
+            contentBox = LayoutRect(paddingBox.x() + renderInline.paddingLeft(), paddingBox.y() + renderInline.paddingTop(),
+                paddingBox.width() - renderInline.paddingLeft() - renderInline.paddingRight(), paddingBox.height() - renderInline.paddingTop() - renderInline.paddingBottom());
             // Ignore marginTop and marginBottom for inlines.
-            marginBox = LayoutRect(borderBox.x() - renderInline->marginLeft(), borderBox.y(),
-                borderBox.width() + renderInline->horizontalMarginExtent(), borderBox.height());
+            marginBox = LayoutRect(borderBox.x() - renderInline.marginLeft(), borderBox.y(),
+                borderBox.width() + renderInline.horizontalMarginExtent(), borderBox.height());
         }
 
         FloatQuad absContentQuad;
index 2d0c968..7e64560 100644 (file)
@@ -3795,7 +3795,7 @@ void FrameView::paintContents(GraphicsContext* context, const IntRect& dirtyRect
     FontCachePurgePreventer fontCachePurgePreventer;
 
     // m_nodeToDraw is used to draw only one element (and its descendants)
-    RenderObject* eltRenderer = m_nodeToDraw ? m_nodeToDraw->renderer() : 0;
+    RenderObject* renderer = m_nodeToDraw ? m_nodeToDraw->renderer() : nullptr;
     RenderLayer* rootLayer = renderView->layer();
 
 #ifndef NDEBUG
@@ -3804,12 +3804,12 @@ void FrameView::paintContents(GraphicsContext* context, const IntRect& dirtyRect
 
     // To work around http://webkit.org/b/135106, ensure that the paint root isn't an inline with culled line boxes.
     // FIXME: This can cause additional content to be included in the snapshot, so remove this once that bug is fixed.
-    while (eltRenderer && eltRenderer->isRenderInline() && !toRenderInline(eltRenderer)->firstLineBox())
-        eltRenderer = eltRenderer->parent();
+    while (is<RenderInline>(renderer) && !downcast<RenderInline>(*renderer).firstLineBox())
+        renderer = renderer->parent();
 
-    rootLayer->paint(context, dirtyRect, LayoutSize(), m_paintBehavior, eltRenderer);
+    rootLayer->paint(context, dirtyRect, LayoutSize(), m_paintBehavior, renderer);
     if (rootLayer->containsDirtyOverlayScrollbars())
-        rootLayer->paintOverlayScrollbars(context, dirtyRect, m_paintBehavior, eltRenderer);
+        rootLayer->paintOverlayScrollbars(context, dirtyRect, m_paintBehavior, renderer);
 
     didPaintContents(context, dirtyRect, paintingState);
 }
index b92c45a..d77155c 100644 (file)
@@ -219,7 +219,7 @@ void InlineFlowBox::deleteLine()
 
 void InlineFlowBox::removeLineBoxFromRenderObject()
 {
-    toRenderInline(renderer()).lineBoxes().removeLineBox(this);
+    downcast<RenderInline>(renderer()).lineBoxes().removeLineBox(this);
 }
 
 void InlineFlowBox::extractLine()
@@ -232,7 +232,7 @@ void InlineFlowBox::extractLine()
 
 void InlineFlowBox::extractLineBoxFromRenderObject()
 {
-    toRenderInline(renderer()).lineBoxes().extractLineBox(this);
+    downcast<RenderInline>(renderer()).lineBoxes().extractLineBox(this);
 }
 
 void InlineFlowBox::attachLine()
@@ -245,7 +245,7 @@ void InlineFlowBox::attachLine()
 
 void InlineFlowBox::attachLineBoxToRenderObject()
 {
-    toRenderInline(renderer()).lineBoxes().attachLineBox(this);
+    downcast<RenderInline>(renderer()).lineBoxes().attachLineBox(this);
 }
 
 void InlineFlowBox::adjustPosition(float dx, float dy)
@@ -300,7 +300,7 @@ void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically
 
     // The root inline box never has borders/margins/padding.
     if (parent()) {
-        const auto& inlineFlow = toRenderInline(renderer());
+        const auto& inlineFlow = downcast<RenderInline>(renderer());
 
         bool ltr = renderer().style().isLeftToRightDirection();
 
@@ -1007,29 +1007,29 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
 
     // Check children first.
     // We need to account for culled inline parents of the hit-tested nodes, so that they may also get included in area-based hit-tests.
-    RenderElement* culledParent = 0;
-    for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) {
-        if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintingLayer()) {
-            RenderElement* newParent = 0;
+    RenderElement* culledParent = nullptr;
+    for (InlineBox* child = lastChild(); child; child = child->prevOnLine()) {
+        if (is<RenderText>(child->renderer()) || !child->boxModelObject()->hasSelfPaintingLayer()) {
+            RenderElement* newParent = nullptr;
             // Culled parents are only relevant for area-based hit-tests, so ignore it in point-based ones.
             if (locationInContainer.isRectBasedTest()) {
-                newParent = curr->renderer().parent();
+                newParent = child->renderer().parent();
                 if (newParent == &renderer())
-                    newParent = 0;
+                    newParent = nullptr;
             }
             // Check the culled parent after all its children have been checked, to do this we wait until
             // we are about to test an element with a different parent.
             if (newParent != culledParent) {
                 if (!newParent || !newParent->isDescendantOf(culledParent)) {
                     while (culledParent && culledParent != &renderer() && culledParent != newParent) {
-                        if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitTestCulledInline(request, result, locationInContainer, accumulatedOffset))
+                        if (is<RenderInline>(*culledParent) && downcast<RenderInline>(*culledParent).hitTestCulledInline(request, result, locationInContainer, accumulatedOffset))
                             return true;
                         culledParent = culledParent->parent();
                     }
                 }
                 culledParent = newParent;
             }
-            if (curr->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom)) {
+            if (child->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom)) {
                 renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
                 return true;
             }
@@ -1037,7 +1037,7 @@ bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
     }
     // Check any culled ancestor of the final children tested.
     while (culledParent && culledParent != &renderer()) {
-        if (culledParent->isRenderInline() && toRenderInline(culledParent)->hitTestCulledInline(request, result, locationInContainer, accumulatedOffset))
+        if (is<RenderInline>(*culledParent) && downcast<RenderInline>(*culledParent).hitTestCulledInline(request, result, locationInContainer, accumulatedOffset))
             return true;
         culledParent = culledParent->parent();
     }
@@ -1103,9 +1103,9 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
             // Add ourselves to the paint info struct's list of inlines that need to paint their
             // outlines.
             if (renderer().style().visibility() == VISIBLE && renderer().hasOutline() && !isRootInlineBox()) {
-                RenderInline& inlineFlow = toRenderInline(renderer());
+                RenderInline& inlineFlow = downcast<RenderInline>(renderer());
 
-                RenderBlock* cb = 0;
+                RenderBlock* containingBlock = nullptr;
                 bool containingBlockPaintsContinuationOutline = inlineFlow.continuation() || inlineFlow.isInlineElementContinuation();
                 if (containingBlockPaintsContinuationOutline) {           
                     // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690. We currently don't reconnect inline continuations
@@ -1115,8 +1115,8 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
                     if (!enclosingAnonymousBlock->isAnonymousBlock())
                         containingBlockPaintsContinuationOutline = false;
                     else {
-                        cb = enclosingAnonymousBlock->containingBlock();
-                        for (auto box = &renderer(); box != cb; box = &box->parent()->enclosingBoxModelObject()) {
+                        containingBlock = enclosingAnonymousBlock->containingBlock();
+                        for (auto box = &renderer(); box != containingBlock; box = &box->parent()->enclosingBoxModelObject()) {
                             if (box->hasSelfPaintingLayer()) {
                                 containingBlockPaintsContinuationOutline = false;
                                 break;
@@ -1128,7 +1128,7 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
                 if (containingBlockPaintsContinuationOutline) {
                     // Add ourselves to the containing block of the entire continuation so that it can
                     // paint us atomically.
-                    cb->addContinuationWithOutline(toRenderInline(renderer().element()->renderer()));
+                    containingBlock->addContinuationWithOutline(downcast<RenderInline>(renderer().element()->renderer()));
                 } else if (!inlineFlow.isInlineElementContinuation())
                     paintInfo.outlineObjects->add(&inlineFlow);
             }
index 8b60415..7a76ab9 100644 (file)
@@ -288,31 +288,31 @@ static inline RenderObject* bidiNextIncludingEmptyInlines(RenderElement& root, R
     return bidiNextShared(root, current, observer, IncludeEmptyInlines, endOfInlinePtr);
 }
 
-static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderElement& root, InlineBidiResolver* resolver = 0)
+static inline RenderObject* bidiFirstSkippingEmptyInlines(RenderElement& root, InlineBidiResolver* resolver = nullptr)
 {
-    RenderObject* o = root.firstChild();
-    if (!o)
+    RenderObject* renderer = root.firstChild();
+    if (!renderer)
         return nullptr;
 
-    if (o->isRenderInline()) {
-        notifyObserverEnteredObject(resolver, o);
-        if (!isEmptyInline(toRenderInline(*o)))
-            o = bidiNextSkippingEmptyInlines(root, o, resolver);
+    if (is<RenderInline>(*renderer)) {
+        notifyObserverEnteredObject(resolver, renderer);
+        if (!isEmptyInline(downcast<RenderInline>(*renderer)))
+            renderer = bidiNextSkippingEmptyInlines(root, renderer, resolver);
         else {
             // Never skip empty inlines.
             if (resolver)
                 resolver->commitExplicitEmbedding();
-            return o; 
+            return renderer;
         }
     }
 
     // FIXME: Unify this with the bidiNext call above.
-    if (o && !isIteratorTarget(o))
-        o = bidiNextSkippingEmptyInlines(root, o, resolver);
+    if (renderer && !isIteratorTarget(renderer))
+        renderer = bidiNextSkippingEmptyInlines(root, renderer, resolver);
 
     if (resolver)
         resolver->commitExplicitEmbedding();
-    return o;
+    return renderer;
 }
 
 // FIXME: This method needs to be renamed when bidiNext finds a good name.
index bbe1706..e60b4b9 100644 (file)
@@ -53,8 +53,8 @@ LayoutState::LayoutState(std::unique_ptr<LayoutState> next, RenderBox* renderer,
 
     if (renderer->isOutOfFlowPositioned() && !fixed) {
         if (RenderElement* container = renderer->container()) {
-            if (container->isInFlowPositioned() && container->isRenderInline())
-                m_paintOffset += toRenderInline(container)->offsetForInFlowPositionedInline(renderer);
+            if (container->isInFlowPositioned() && is<RenderInline>(*container))
+                m_paintOffset += downcast<RenderInline>(*container).offsetForInFlowPositionedInline(renderer);
         }
     }
 
index 8241287..f066140 100644 (file)
@@ -253,7 +253,7 @@ void RenderBlock::willBeDestroyed()
     
     if (!documentBeingDestroyed()) {
         if (parent())
-            parent()->dirtyLinesFromChangedChild(this);
+            parent()->dirtyLinesFromChangedChild(*this);
     }
 
     removeFromUpdateScrollInfoAfterLayoutTransaction();
@@ -1630,11 +1630,11 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
     if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutlines)) {
         RenderInline* inlineCont = inlineElementContinuation();
         if (inlineCont && inlineCont->hasOutline() && inlineCont->style().visibility() == VISIBLE) {
-            RenderInline* inlineRenderer = toRenderInline(inlineCont->element()->renderer());
-            RenderBlock* cb = containingBlock();
+            RenderInline* inlineRenderer = downcast<RenderInline>(inlineCont->element()->renderer());
+            RenderBlock* containingBlock = this->containingBlock();
 
             bool inlineEnclosedInSelfPaintingLayer = false;
-            for (RenderBoxModelObject* box = inlineRenderer; box != cb; box = &box->parent()->enclosingBoxModelObject()) {
+            for (RenderBoxModelObject* box = inlineRenderer; box != containingBlock; box = &box->parent()->enclosingBoxModelObject()) {
                 if (box->hasSelfPaintingLayer()) {
                     inlineEnclosedInSelfPaintingLayer = true;
                     break;
@@ -1645,7 +1645,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
             // anonymous block (i.e. have our own layer), paint them straightaway instead. This is because a block depends on renderers in its continuation table being
             // in the same layer. 
             if (!inlineEnclosedInSelfPaintingLayer && !hasLayer())
-                cb->addContinuationWithOutline(inlineRenderer);
+                containingBlock->addContinuationWithOutline(inlineRenderer);
             else if (!inlineRenderer->firstLineBox() || (!inlineEnclosedInSelfPaintingLayer && hasLayer()))
                 inlineRenderer->paintOutline(paintInfo, paintOffset - locationOffset() + inlineRenderer->containingBlock()->location());
         }
@@ -1664,7 +1664,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
 RenderInline* RenderBlock::inlineElementContinuation() const
 { 
     RenderBoxModelObject* continuation = this->continuation();
-    return continuation && continuation->isRenderInline() ? toRenderInline(continuation) : 0;
+    return is<RenderInline>(continuation) ? downcast<RenderInline>(continuation) : nullptr;
 }
 
 RenderBlock* RenderBlock::blockElementContinuation() const
@@ -3400,7 +3400,7 @@ void RenderBlock::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& a
         // FIXME: This is wrong. The principal renderer may not be the continuation preceding this block.
         // FIXME: This is wrong for block-flows that are horizontal.
         // https://bugs.webkit.org/show_bug.cgi?id=46781
-        bool prevInlineHasLineBox = toRenderInline(inlineElementContinuation()->element()->renderer())->firstLineBox();
+        bool prevInlineHasLineBox = downcast<RenderInline>(*inlineElementContinuation()->element()->renderer()).firstLineBox();
         float topMargin = prevInlineHasLineBox ? collapsedMarginBefore() : LayoutUnit();
         float bottomMargin = nextInlineHasLineBox ? collapsedMarginAfter() : LayoutUnit();
         LayoutRect rect(additionalOffset.x(), additionalOffset.y() - topMargin, width(), height() + topMargin + bottomMargin);
index f0eeb01..548d55d 100644 (file)
@@ -179,7 +179,7 @@ void RenderBlockFlow::willBeDestroyed()
                 }
             }
         } else if (parent())
-            parent()->dirtyLinesFromChangedChild(this);
+            parent()->dirtyLinesFromChangedChild(*this);
     }
 
     m_lineBoxes.deleteLineBoxes();
@@ -4032,10 +4032,10 @@ void RenderBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical
                     continue;
                 }
                 // Case (1) and (2). Inline replaced and inline flow elements.
-                if (child->isRenderInline()) {
+                if (is<RenderInline>(*child)) {
                     // Add in padding/border/margin from the appropriate side of
                     // the element.
-                    float bpm = getBorderPaddingMargin(*toRenderInline(child), childIterator.endOfInline);
+                    float bpm = getBorderPaddingMargin(downcast<RenderInline>(*child), childIterator.endOfInline);
                     childMin += bpm;
                     childMax += bpm;
 
@@ -4057,7 +4057,7 @@ void RenderBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical
                 }
             }
 
-            if (!child->isRenderInline() && !child->isText()) {
+            if (!is<RenderInline>(*child) && !is<RenderText>(*child)) {
                 // Case (2). Inline replaced elements and floats.
                 // Go ahead and terminate the current line as far as
                 // minwidth is concerned.
index 4898a4d..6edccc2 100644 (file)
@@ -79,7 +79,7 @@ protected:
     virtual LayoutUnit collapsedMarginBefore() const override final { return maxPositiveMarginBefore() - maxNegativeMarginBefore(); }
     virtual LayoutUnit collapsedMarginAfter() const override final { return maxPositiveMarginAfter() - maxNegativeMarginAfter(); }
 
-    virtual void dirtyLinesFromChangedChild(RenderObject* child) override final { lineBoxes().dirtyLinesFromChangedChild(this, child); }
+    virtual void dirtyLinesFromChangedChild(RenderObject& child) override final { lineBoxes().dirtyLinesFromChangedChild(*this, child); }
     virtual void updateLogicalHeight() override;
 
     virtual void paintColumnRules(PaintInfo&, const LayoutPoint&) override;
index 90e67e5..492079a 100644 (file)
@@ -925,7 +925,7 @@ static inline void constructBidiRunsForSegment(InlineBidiResolver& topResolver,
         // tree to see which parent inline is the isolate. We could change enterIsolate
         // to take a RenderObject and do this logic there, but that would be a layering
         // violation for BidiResolver (which knows nothing about RenderObject).
-        RenderInline* isolatedInline = toRenderInline(highestContainingIsolateWithinRoot(startObject, currentRoot));
+        RenderInline* isolatedInline = downcast<RenderInline>(highestContainingIsolateWithinRoot(startObject, currentRoot));
         ASSERT(isolatedInline);
 
         InlineBidiResolver isolatedResolver;
@@ -1487,9 +1487,9 @@ void RenderBlockFlow::layoutLineBoxes(bool relayoutChildren, LayoutUnit& repaint
                     else
                         box.layoutIfNeeded();
                 }
-            } else if (o.isTextOrLineBreak() || (o.isRenderInline() && !walker.atEndOfInline())) {
-                if (o.isRenderInline())
-                    toRenderInline(o).updateAlwaysCreateLineBoxes(layoutState.isFullLayout());
+            } else if (o.isTextOrLineBreak() || (is<RenderInline>(o) && !walker.atEndOfInline())) {
+                if (is<RenderInline>(o))
+                    downcast<RenderInline>(o).updateAlwaysCreateLineBoxes(layoutState.isFullLayout());
                 if (layoutState.isFullLayout() || o.selfNeedsLayout())
                     dirtyLineBoxesForRenderer(o, layoutState.isFullLayout());
                 o.clearNeedsLayout();
index 05ccd3a..5775d4c 100644 (file)
@@ -2007,10 +2007,10 @@ void RenderBox::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState
     RenderBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState);
 }
 
-LayoutSize RenderBox::offsetFromContainer(RenderObject* o, const LayoutPoint&, bool* offsetDependsOnPoint) const
+LayoutSize RenderBox::offsetFromContainer(RenderObject* renderer, const LayoutPoint&, bool* offsetDependsOnPoint) const
 {
     // A region "has" boxes inside it without being their container. 
-    ASSERT(o == container() || o->isRenderRegion());
+    ASSERT(renderer == container() || is<RenderRegion>(*renderer));
 
     LayoutSize offset;    
     if (isInFlowPositioned())
@@ -2019,14 +2019,14 @@ LayoutSize RenderBox::offsetFromContainer(RenderObject* o, const LayoutPoint&, b
     if (!isInline() || isReplaced())
         offset += topLeftLocationOffset();
 
-    if (o->isBox())
-        offset -= toRenderBox(o)->scrolledContentOffset();
+    if (is<RenderBox>(*renderer))
+        offset -= downcast<RenderBox>(*renderer).scrolledContentOffset();
 
-    if (style().position() == AbsolutePosition && o->isInFlowPositioned() && o->isRenderInline())
-        offset += toRenderInline(o)->offsetForInFlowPositionedInline(this);
+    if (style().position() == AbsolutePosition && renderer->isInFlowPositioned() && is<RenderInline>(*renderer))
+        offset += downcast<RenderInline>(*renderer).offsetForInFlowPositionedInline(this);
 
     if (offsetDependsOnPoint)
-        *offsetDependsOnPoint |= o->isRenderFlowThread();
+        *offsetDependsOnPoint |= is<RenderFlowThread>(*renderer);
 
     return offset;
 }
@@ -2165,8 +2165,8 @@ void RenderBox::computeRectForRepaint(const RenderLayerModelObject* repaintConta
     }
 
     bool containerSkipped;
-    auto o = container(repaintContainer, &containerSkipped);
-    if (!o)
+    auto* renderer = container(repaintContainer, &containerSkipped);
+    if (!renderer)
         return;
     
     EPosition position = styleToUse.position();
@@ -2178,10 +2178,10 @@ void RenderBox::computeRectForRepaint(const RenderLayerModelObject* repaintConta
     // us to add the height twice.
     // The same logic applies for elements flowed directly into the flow thread. Their topLeft member
     // will already contain the portion rect of the region.
-    if (o->isOutOfFlowRenderFlowThread() && position != AbsolutePosition && containingBlock() != flowThreadContainingBlock()) {
+    if (renderer->isOutOfFlowRenderFlowThread() && position != AbsolutePosition && containingBlock() != flowThreadContainingBlock()) {
         RenderRegion* firstRegion = nullptr;
         RenderRegion* lastRegion = nullptr;
-        if (toRenderFlowThread(o)->getRegionRangeForBox(this, firstRegion, lastRegion))
+        if (downcast<RenderFlowThread>(*renderer).getRegionRangeForBox(this, firstRegion, lastRegion))
             rect.moveBy(firstRegion->flowThreadPortionRect().location());
     }
 
@@ -2201,8 +2201,8 @@ void RenderBox::computeRectForRepaint(const RenderLayerModelObject* repaintConta
     } else if (position == FixedPosition)
         fixed = true;
 
-    if (position == AbsolutePosition && o->isInFlowPositioned() && o->isRenderInline())
-        topLeft += toRenderInline(o)->offsetForInFlowPositionedInline(this);
+    if (position == AbsolutePosition && renderer->isInFlowPositioned() && is<RenderInline>(*renderer))
+        topLeft += downcast<RenderInline>(*renderer).offsetForInFlowPositionedInline(this);
     else if (styleToUse.hasInFlowPosition() && layer()) {
         // Apply the relative position offset when invalidating a rectangle.  The layer
         // is translated, but the render box isn't, so we need to do this to get the
@@ -2214,10 +2214,10 @@ void RenderBox::computeRectForRepaint(const RenderLayerModelObject* repaintConta
     // FIXME: We ignore the lightweight clipping rect that controls use, since if |o| is in mid-layout,
     // its controlClipRect will be wrong. For overflow clip we use the values cached by the layer.
     rect.setLocation(topLeft);
-    if (o->hasOverflowClip()) {
-        RenderBox* containerBox = toRenderBox(o);
-        if (shouldApplyContainersClipAndOffset(repaintContainer, containerBox)) {
-            containerBox->applyCachedClipAndScrollOffsetForRepaint(rect);
+    if (renderer->hasOverflowClip()) {
+        RenderBox& containerBox = downcast<RenderBox>(*renderer);
+        if (shouldApplyContainersClipAndOffset(repaintContainer, &containerBox)) {
+            containerBox.applyCachedClipAndScrollOffsetForRepaint(rect);
             if (rect.isEmpty())
                 return;
         }
@@ -2225,12 +2225,12 @@ void RenderBox::computeRectForRepaint(const RenderLayerModelObject* repaintConta
 
     if (containerSkipped) {
         // If the repaintContainer is below o, then we need to map the rect into repaintContainer's coordinates.
-        LayoutSize containerOffset = repaintContainer->offsetFromAncestorContainer(o);
+        LayoutSize containerOffset = repaintContainer->offsetFromAncestorContainer(renderer);
         rect.move(-containerOffset);
         return;
     }
 
-    o->computeRectForRepaint(repaintContainer, rect, fixed);
+    renderer->computeRectForRepaint(repaintContainer, rect, fixed);
 }
 
 void RenderBox::repaintDuringLayoutIfMoved(const LayoutRect& oldRect)
@@ -3107,11 +3107,11 @@ LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
         return (boxInfo) ? std::max<LayoutUnit>(0, cb.clientLogicalWidth() - (cb.logicalWidth() - boxInfo->logicalWidth())) : cb.clientLogicalWidth();
     }
 
-    ASSERT(containingBlock->isRenderInline() && containingBlock->isInFlowPositioned());
+    ASSERT(containingBlock->isInFlowPositioned());
 
-    const RenderInline* flow = toRenderInline(containingBlock);
-    InlineFlowBox* first = flow->firstLineBox();
-    InlineFlowBox* last = flow->lastLineBox();
+    const auto& flow = downcast<RenderInline>(*containingBlock);
+    InlineFlowBox* first = flow.firstLineBox();
+    InlineFlowBox* last = flow.lastLineBox();
 
     // If the containing block is empty, return a width of 0.
     if (!first || !last)
@@ -3152,9 +3152,9 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM
         return result;
     }
         
-    ASSERT(is<RenderInline>(*containingBlock) && containingBlock->isInFlowPositioned());
+    ASSERT(containingBlock->isInFlowPositioned());
 
-    const RenderInline& flow = downcast<RenderInline>(*containingBlock);
+    const auto& flow = downcast<RenderInline>(*containingBlock);
     InlineFlowBox* first = flow.firstLineBox();
     InlineFlowBox* last = flow.lastLineBox();
 
@@ -3533,10 +3533,10 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
     // positioned, inline because right now, it is using the logical left position
     // of the first line box when really it should use the last line box.  When
     // this is fixed elsewhere, this block should be removed.
-    if (containerBlock->isRenderInline() && !containerBlock->style().isLeftToRightDirection()) {
-        const RenderInline* flow = toRenderInline(containerBlock);
-        InlineFlowBox* firstLine = flow->firstLineBox();
-        InlineFlowBox* lastLine = flow->lastLineBox();
+    if (is<RenderInline>(*containerBlock) && !containerBlock->style().isLeftToRightDirection()) {
+        const auto& flow = downcast<RenderInline>(*containerBlock);
+        InlineFlowBox* firstLine = flow.firstLineBox();
+        InlineFlowBox* lastLine = flow.lastLineBox();
         if (firstLine && lastLine && firstLine != lastLine) {
             computedValues.m_position = logicalLeftValue + marginLogicalLeftValue + lastLine->borderLogicalLeft() + (lastLine->logicalLeft() - firstLine->logicalLeft());
             return;
@@ -3973,10 +3973,10 @@ void RenderBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
     // positioned, inline containing block because right now, it is using the logical left position
     // of the first line box when really it should use the last line box.  When
     // this is fixed elsewhere, this block should be removed.
-    if (containerBlock->isRenderInline() && !containerBlock->style().isLeftToRightDirection()) {
-        const RenderInline* flow = toRenderInline(containerBlock);
-        InlineFlowBox* firstLine = flow->firstLineBox();
-        InlineFlowBox* lastLine = flow->lastLineBox();
+    if (is<RenderInline>(*containerBlock) && !containerBlock->style().isLeftToRightDirection()) {
+        const auto& flow = downcast<RenderInline>(*containerBlock);
+        InlineFlowBox* firstLine = flow.firstLineBox();
+        InlineFlowBox* lastLine = flow.lastLineBox();
         if (firstLine && lastLine && firstLine != lastLine) {
             computedValues.m_position = logicalLeftValue + marginLogicalLeftAlias + lastLine->borderLogicalLeft() + (lastLine->logicalLeft() - firstLine->logicalLeft());
             return;
@@ -4624,7 +4624,7 @@ LayoutRect RenderBox::overflowRectForPaintRejection(RenderNamedFlowFragment* nam
         RenderRegion* startRegion = nullptr;
         RenderRegion* endRegion = nullptr;
         if (flowThread->getRegionRangeForBox(this, startRegion, endRegion))
-            overflowRect.unite(namedFlowFragment->visualOverflowRectForBox(this));
+            overflowRect.unite(namedFlowFragment->visualOverflowRectForBox(*this));
     }
     
     if (!m_overflow || !usesCompositedScrolling())
index 63f79c6..509e986 100644 (file)
@@ -213,13 +213,9 @@ static LayoutSize accumulateInFlowPositionOffsets(const RenderObject* child)
     if (!child->isAnonymousBlock() || !child->isInFlowPositioned())
         return LayoutSize();
     LayoutSize offset;
-    RenderElement* p = downcast<RenderBlock>(*child).inlineElementContinuation();
-    while (is<RenderInline>(p)) {
-        if (p->isInFlowPositioned()) {
-            RenderInline& renderInline = downcast<RenderInline>(*p);
-            offset += renderInline.offsetForInFlowPosition();
-        }
-        p = p->parent();
+    for (RenderElement* parent = downcast<RenderBlock>(*child).inlineElementContinuation(); is<RenderInline>(parent); parent = parent->parent()) {
+        if (parent->isInFlowPositioned())
+            offset += downcast<RenderInline>(*parent).offsetForInFlowPosition();
     }
     return offset;
 }
index f46d106..e6aa3ca 100644 (file)
@@ -996,7 +996,7 @@ void RenderElement::willBeRemovedFromTree()
         view().frameView().removeSlowRepaintObject(this);
 
     if (isOutOfFlowPositioned() && parent()->childrenInline())
-        parent()->dirtyLinesFromChangedChild(this);
+        parent()->dirtyLinesFromChangedChild(*this);
 
     if (auto* containerFlowThread = parent()->renderNamedFlowThreadWrapper())
         containerFlowThread->removeFlowChild(*this);
index d9ca569..e236ddd 100644 (file)
@@ -85,7 +85,7 @@ public:
 
     virtual RenderElement* hoverAncestor() const;
 
-    virtual void dirtyLinesFromChangedChild(RenderObject*) { }
+    virtual void dirtyLinesFromChangedChild(RenderObject&) { }
 
     bool ancestorLineBoxDirty() const { return m_ancestorLineBoxDirty; }
     void setAncestorLineBoxDirty(bool f = true);
index 9615096..eb8c770 100644 (file)
@@ -1446,7 +1446,7 @@ void RenderFlowThread::addRegionsOverflowFromChild(const RenderBox* box, const R
                 break;
             continue;
         }
-        LayoutRect childVisualOverflowRect = region->visualOverflowRectForBoxForPropagation(child);
+        LayoutRect childVisualOverflowRect = region->visualOverflowRectForBoxForPropagation(*child);
         childVisualOverflowRect.move(delta);
         region->addVisualOverflowForBox(box, childVisualOverflowRect);
 
index 9c7e45b..465ba90 100644 (file)
@@ -107,7 +107,7 @@ void RenderInline::willBeDestroyed()
                     box->removeFromParent();
             }
         } else if (parent()) 
-            parent()->dirtyLinesFromChangedChild(this);
+            parent()->dirtyLinesFromChangedChild(*this);
     }
 
     m_lineBoxes.deleteLineBoxes();
@@ -217,7 +217,7 @@ void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout)
         return;
 
     RenderStyle* parentStyle = &parent()->style();
-    RenderInline* parentRenderInline = parent()->isRenderInline() ? toRenderInline(parent()) : 0;
+    RenderInline* parentRenderInline = is<RenderInline>(*parent()) ? downcast<RenderInline>(parent()) : nullptr;
     bool checkFonts = document().inNoQuirksMode();
     RenderFlowThread* flowThread = flowThreadContainingBlock();
     bool alwaysCreateLineBoxes = (parentRenderInline && parentRenderInline->alwaysCreateLineBoxes())
@@ -1107,27 +1107,27 @@ LayoutRect RenderInline::clippedOverflowRectForRepaint(const RenderLayerModelObj
 
     // We need to add in the in-flow position offsets of any inlines (including us) up to our
     // containing block.
-    RenderBlock* cb = containingBlock();
-    for (const RenderObject* inlineFlow = this; inlineFlow && inlineFlow->isRenderInline() && inlineFlow != cb;
+    RenderBlock* containingBlock = this->containingBlock();
+    for (const RenderElement* inlineFlow = this; is<RenderInline>(inlineFlow) && inlineFlow != containingBlock;
          inlineFlow = inlineFlow->parent()) {
          if (inlineFlow == repaintContainer) {
             hitRepaintContainer = true;
             break;
         }
         if (inlineFlow->style().hasInFlowPosition() && inlineFlow->hasLayer())
-            repaintRect.move(toRenderInline(inlineFlow)->layer()->offsetForInFlowPosition());
+            repaintRect.move(downcast<RenderInline>(*inlineFlow).layer()->offsetForInFlowPosition());
     }
 
     LayoutUnit outlineSize = style().outlineSize();
     repaintRect.inflate(outlineSize);
 
-    if (hitRepaintContainer || !cb)
+    if (hitRepaintContainer || !containingBlock)
         return repaintRect;
 
-    if (cb->hasOverflowClip())
-        cb->applyCachedClipAndScrollOffsetForRepaint(repaintRect);
+    if (containingBlock->hasOverflowClip())
+        containingBlock->applyCachedClipAndScrollOffsetForRepaint(repaintRect);
 
-    cb->computeRectForRepaint(repaintContainer, repaintRect);
+    containingBlock->computeRectForRepaint(repaintContainer, repaintRect);
 
     if (outlineSize) {
         for (auto& child : childrenOfType<RenderElement>(*this))
index ce8e5f2..1346de0 100644 (file)
@@ -156,7 +156,7 @@ private:
 
     virtual std::unique_ptr<InlineFlowBox> createInlineFlowBox(); // Subclassed by RenderSVGInline
 
-    virtual void dirtyLinesFromChangedChild(RenderObject* child) override final { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
+    virtual void dirtyLinesFromChangedChild(RenderObject& child) override final { m_lineBoxes.dirtyLinesFromChangedChild(*this, child); }
 
     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
@@ -180,8 +180,6 @@ private:
     RenderLineBoxList m_lineBoxes;   // All of the line boxes created for this inline flow.  For example, <i>Hello<br>world.</i> will have two <i> line boxes.
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderInline, isRenderInline())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderInline, isRenderInline())
index 44f242f..8e97d26 100644 (file)
@@ -1198,8 +1198,8 @@ bool RenderLayer::updateLayerPosition()
 {
     LayoutPoint localPoint;
     LayoutSize inlineBoundingBoxOffset; // We don't put this into the RenderLayer x/y for inlines, so we need to subtract it out when done.
-    if (renderer().isInline() && renderer().isRenderInline()) {
-        RenderInline& inlineFlow = toRenderInline(renderer());
+    if (renderer().isInline() && is<RenderInline>(renderer())) {
+        auto& inlineFlow = downcast<RenderInline>(renderer());
         IntRect lineBox = inlineFlow.linesBoundingBox();
         setSize(lineBox.size());
         inlineBoundingBoxOffset = toLayoutSize(lineBox.location());
@@ -1238,8 +1238,8 @@ bool RenderLayer::updateLayerPosition()
             localPoint -= offset;
         }
         
-        if (renderer().isOutOfFlowPositioned() && positionedParent->renderer().isInFlowPositioned() && positionedParent->renderer().isRenderInline()) {
-            LayoutSize offset = toRenderInline(positionedParent->renderer()).offsetForInFlowPositionedInline(&toRenderBox(renderer()));
+        if (renderer().isOutOfFlowPositioned() && positionedParent->renderer().isInFlowPositioned() && is<RenderInline>(positionedParent->renderer())) {
+            LayoutSize offset = downcast<RenderInline>(positionedParent->renderer()).offsetForInFlowPositionedInline(&toRenderBox(renderer()));
             localPoint += offset;
         }
     } else if (parent()) {
@@ -5408,7 +5408,7 @@ void RenderLayer::calculateRects(const ClipRectsContext& clipRectsContext, const
     if (isSelfPaintingLayer() && flowThread && !renderer().isInFlowRenderFlowThread()) {
         ASSERT(namedFlowFragment->isValid());
         const RenderBoxModelObject& boxModelObject = downcast<RenderBoxModelObject>(renderer());
-        LayoutRect layerBoundsWithVisualOverflow = namedFlowFragment->visualOverflowRectForBox(&boxModelObject);
+        LayoutRect layerBoundsWithVisualOverflow = namedFlowFragment->visualOverflowRectForBox(boxModelObject);
 
         // Layers are in physical coordinates so the origin must be moved to the physical top-left of the flowthread.
         if (&boxModelObject == flowThread && flowThread->style().isFlippedBlocksWritingMode()) {
@@ -5457,7 +5457,7 @@ void RenderLayer::calculateRects(const ClipRectsContext& clipRectsContext, const
         if (renderBox()->hasVisualOverflow()) {
             // FIXME: Does not do the right thing with CSS regions yet, since we don't yet factor in the
             // individual region boxes as overflow.
-            LayoutRect layerBoundsWithVisualOverflow = namedFlowFragment ? namedFlowFragment->visualOverflowRectForBox(renderBox()) : renderBox()->visualOverflowRect();
+            LayoutRect layerBoundsWithVisualOverflow = namedFlowFragment ? namedFlowFragment->visualOverflowRectForBox(*renderBox()) : renderBox()->visualOverflowRect();
             renderBox()->flipForWritingMode(layerBoundsWithVisualOverflow); // Layers are in physical coordinates, so the overflow has to be flipped.
             layerBoundsWithVisualOverflow.move(offsetFromRootLocal);
             if (this != clipRectsContext.rootLayer || clipRectsContext.respectOverflowClip == RespectOverflowClip)
@@ -5593,7 +5593,7 @@ bool RenderLayer::intersectsDamageRect(const LayoutRect& layerBounds, const Layo
     // to the flow thread, not the last region (in which it will end up because of bottom:0px)
     if (namedFlowFragment && renderer().flowThreadContainingBlock()) {
         LayoutRect b = layerBounds;
-        b.moveBy(namedFlowFragment->visualOverflowRectForBox(downcast<RenderBoxModelObject>(&renderer())).location());
+        b.moveBy(namedFlowFragment->visualOverflowRectForBox(downcast<RenderBoxModelObject>(renderer())).location());
         b.inflate(renderer().view().maximalOutlineSize());
         if (b.intersects(damageRect))
             return true;
@@ -5620,10 +5620,10 @@ LayoutRect RenderLayer::localBoundingBox(CalculateLayerBoundsFlags flags) const
     // as part of our bounding box.  We do this because we are the responsible layer for both hit testing and painting those
     // floats.
     LayoutRect result;
-    if (renderer().isInline() && renderer().isRenderInline())
-        result = toRenderInline(renderer()).linesVisualOverflowBoundingBox();
+    if (renderer().isInline() && is<RenderInline>(renderer()))
+        result = downcast<RenderInline>(renderer()).linesVisualOverflowBoundingBox();
     else if (is<RenderTableRow>(renderer())) {
-        RenderTableRow& tableRow = downcast<RenderTableRow>(renderer());
+        auto& tableRow = downcast<RenderTableRow>(renderer());
         // Our bounding box is just the union of all of our cells' border/overflow rects.
         for (RenderTableCell* cell = tableRow.firstCell(); cell; cell = cell->nextCell()) {
             LayoutRect bbox = cell->borderBoxRect();
index 09276bb..c86fe8f 100644 (file)
@@ -312,22 +312,22 @@ bool RenderLineBoxList::hitTest(RenderBoxModelObject* renderer, const HitTestReq
     return false;
 }
 
-void RenderLineBoxList::dirtyLinesFromChangedChild(RenderBoxModelObject* container, RenderObject* child)
+void RenderLineBoxList::dirtyLinesFromChangedChild(RenderBoxModelObject& container, RenderObject& child)
 {
-    ASSERT(container->isRenderInline() || container->isRenderBlockFlow());
-    if (!container->parent() || (container->isRenderBlockFlow() && container->selfNeedsLayout()))
+    ASSERT(is<RenderInline>(container) || is<RenderBlockFlow>(container));
+    if (!container.parent() || (is<RenderBlockFlow>(container) && container.selfNeedsLayout()))
         return;
 
-    RenderInline* inlineContainer = container->isRenderInline() ? toRenderInline(container) : 0;
+    RenderInline* inlineContainer = is<RenderInline>(container) ? &downcast<RenderInline>(container) : nullptr;
     InlineBox* firstBox = inlineContainer ? inlineContainer->firstLineBoxIncludingCulling() : firstLineBox();
 
     // If we have no first line box, then just bail early.
     if (!firstBox) {
         // For an empty inline, go ahead and propagate the check up to our parent, unless the parent
         // is already dirty.
-        if (container->isInline() && !container->ancestorLineBoxDirty()) {
-            container->parent()->dirtyLinesFromChangedChild(container);
-            container->setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree.
+        if (container.isInline() && !container.ancestorLineBoxDirty()) {
+            container.parent()->dirtyLinesFromChangedChild(container);
+            container.setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree.
         }
         return;
     }
@@ -337,7 +337,7 @@ void RenderLineBoxList::dirtyLinesFromChangedChild(RenderBoxModelObject* contain
     // parent's first line box.
     RootInlineBox* box = nullptr;
     RenderObject* current;
-    for (current = child->previousSibling(); current; current = current->previousSibling()) {
+    for (current = child.previousSibling(); current; current = current->previousSibling()) {
         if (current->isFloatingOrOutOfFlowPositioned())
             continue;
 
@@ -367,7 +367,7 @@ void RenderLineBoxList::dirtyLinesFromChangedChild(RenderBoxModelObject* contain
             // This isn't good enough, since we won't locate the root line box that encloses the removed
             // <br>. We have to just over-invalidate a bit and go up to our parent.
             if (!inlineContainer->ancestorLineBoxDirty()) {
-                inlineContainer->parent()->dirtyLinesFromChangedChild(inlineContainer);
+                inlineContainer->parent()->dirtyLinesFromChangedChild(*inlineContainer);
                 inlineContainer->setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree.
             }
             return;
@@ -394,9 +394,9 @@ void RenderLineBoxList::dirtyLinesFromChangedChild(RenderBoxModelObject* contain
         // If |child| has been inserted before the first element in the linebox, but after collapsed leading
         // space, the search for |child|'s linebox will go past the leading space to the previous linebox and select that
         // one as |box|. If we hit that situation here, dirty the |box| actually containing the child too. 
-        bool insertedAfterLeadingSpace = box->lineBreakObj() == child->previousSibling();
-        if (adjacentBox && (adjacentBox->lineBreakObj() == child || child->isBR() || (current && current->isBR())
-            || insertedAfterLeadingSpace || isIsolated(container->style().unicodeBidi())))
+        bool insertedAfterLeadingSpace = box->lineBreakObj() == child.previousSibling();
+        if (adjacentBox && (adjacentBox->lineBreakObj() == &child || child.isBR() || (current && current->isBR())
+            || insertedAfterLeadingSpace || isIsolated(container.style().unicodeBidi())))
             adjacentBox->markDirty();
     }
 }
index 2c2fa48..7aa35a2 100644 (file)
@@ -64,7 +64,7 @@ public:
     void removeLineBox(InlineFlowBox*);
     
     void dirtyLineBoxes();
-    void dirtyLinesFromChangedChild(RenderBoxModelObject* parent, RenderObject* child);
+    void dirtyLinesFromChangedChild(RenderBoxModelObject& parent, RenderObject& child);
 
     void paint(RenderBoxModelObject*, PaintInfo&, const LayoutPoint&) const;
     bool hitTest(RenderBoxModelObject*, const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) const;
index b211862..6ea5620 100644 (file)
@@ -284,7 +284,7 @@ void RenderNamedFlowThread::regionChangedWritingMode(RenderRegion* region)
 
 LayoutRect RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment(const RenderBox& box, RenderNamedFlowFragment& fragment) const
 {
-    LayoutRect visualOverflowRect = fragment.visualOverflowRectForBox(&box);
+    LayoutRect visualOverflowRect = fragment.visualOverflowRectForBox(box);
     LayoutUnit initialLogicalX = style().isHorizontalWritingMode() ? visualOverflowRect.x() : visualOverflowRect.y();
 
     // The visual overflow rect returned by visualOverflowRectForBox is already flipped but the
index 387c1c9..b27d910 100644 (file)
@@ -2047,7 +2047,7 @@ void RenderObject::insertedIntoTree()
     // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion.
 
     if (!isFloating() && parent()->childrenInline())
-        parent()->dirtyLinesFromChangedChild(this);
+        parent()->dirtyLinesFromChangedChild(*this);
     
     // We have to unset the current layout RenderFlowThread here, since insertedIntoTree() can happen in
     // the middle of layout but for objects inside a nested flow thread that is still being populated. This
index cf53a30..f9de8ce 100644 (file)
@@ -156,7 +156,7 @@ LayoutRect RenderRegion::overflowRectForFlowThreadPortion(const LayoutRect& flow
     if (shouldClipFlowThreadContent())
         return flowThreadPortionRect;
 
-    LayoutRect flowThreadOverflow = overflowType == VisualOverflow ? visualOverflowRectForBox(m_flowThread) : layoutOverflowRectForBox(m_flowThread);
+    LayoutRect flowThreadOverflow = overflowType == VisualOverflow ? visualOverflowRectForBox(*m_flowThread) : layoutOverflowRectForBox(m_flowThread);
 
     // We are interested about the outline size only when computing the visual overflow.
     LayoutUnit outlineSize = overflowType == VisualOverflow ? LayoutUnit(maximalOutlineSize(PaintPhaseOutline)) : LayoutUnit();
@@ -523,16 +523,16 @@ LayoutRect RenderRegion::layoutOverflowRectForBox(const RenderBox* box)
     return overflow->layoutOverflowRect();
 }
 
-LayoutRect RenderRegion::visualOverflowRectForBox(const RenderBoxModelObject* box)
+LayoutRect RenderRegion::visualOverflowRectForBox(const RenderBoxModelObject& box)
 {
-    if (box->isRenderInline()) {
-        const RenderInline* inlineBox = toRenderInline(box);
-        return inlineBox->linesVisualOverflowBoundingBoxInRegion(this);
+    if (is<RenderInline>(box)) {
+        const RenderInline& inlineBox = downcast<RenderInline>(box);
+        return inlineBox.linesVisualOverflowBoundingBoxInRegion(this);
     }
 
-    if (box->isBox()) {
+    if (is<RenderBox>(box)) {
         RefPtr<RenderOverflow> overflow;
-        ensureOverflowForBox(toRenderBox(box), overflow, true);
+        ensureOverflowForBox(&downcast<RenderBox>(box), overflow, true);
 
         ASSERT(overflow);
         return overflow->visualOverflowRect();
@@ -563,7 +563,7 @@ LayoutRect RenderRegion::layoutOverflowRectForBoxForPropagation(const RenderBox*
     return rect;
 }
 
-LayoutRect RenderRegion::visualOverflowRectForBoxForPropagation(const RenderBoxModelObject* box)
+LayoutRect RenderRegion::visualOverflowRectForBoxForPropagation(const RenderBoxModelObject& box)
 {
     LayoutRect rect = visualOverflowRectForBox(box);
     flowThread()->flipForWritingModeLocalCoordinates(rect);
index 7ed513e..29d79d5 100644 (file)
@@ -113,9 +113,9 @@ public:
     void addLayoutOverflowForBox(const RenderBox*, const LayoutRect&);
     void addVisualOverflowForBox(const RenderBox*, const LayoutRect&);
     LayoutRect layoutOverflowRectForBox(const RenderBox*);
-    LayoutRect visualOverflowRectForBox(const RenderBoxModelObject*);
+    LayoutRect visualOverflowRectForBox(const RenderBoxModelObject&);
     LayoutRect layoutOverflowRectForBoxForPropagation(const RenderBox*);
-    LayoutRect visualOverflowRectForBoxForPropagation(const RenderBoxModelObject*);
+    LayoutRect visualOverflowRectForBoxForPropagation(const RenderBoxModelObject&);
 
     LayoutRect rectFlowPortionForBox(const RenderBox*, const LayoutRect&) const;
     
index 97235b7..b27df2c 100644 (file)
@@ -74,7 +74,7 @@ RenderReplaced::~RenderReplaced()
 void RenderReplaced::willBeDestroyed()
 {
     if (!documentBeingDestroyed() && parent())
-        parent()->dirtyLinesFromChangedChild(this);
+        parent()->dirtyLinesFromChangedChild(*this);
 
     RenderBox::willBeDestroyed();
 }
index 1418750..920d751 100644 (file)
@@ -109,7 +109,7 @@ void RenderTextLineBoxes::removeAllFromParent(RenderText& renderer)
 {
     if (!m_first) {
         if (renderer.parent())
-            renderer.parent()->dirtyLinesFromChangedChild(&renderer);
+            renderer.parent()->dirtyLinesFromChangedChild(renderer);
         return;
     }
     for (auto box = m_first; box; box = box->nextTextBox())
@@ -683,7 +683,7 @@ bool RenderTextLineBoxes::dirtyRange(RenderText& renderer, unsigned start, unsig
     
     // If the text node is empty, dirty the line where new text will be inserted.
     if (!m_first && renderer.parent()) {
-        renderer.parent()->dirtyLinesFromChangedChild(&renderer);
+        renderer.parent()->dirtyLinesFromChangedChild(renderer);
         dirtiedLines = true;
     }
     return dirtiedLines;
index eaf8698..9aeffb4 100644 (file)
@@ -286,8 +286,8 @@ inline LayoutUnit inlineLogicalWidth(RenderObject* child, bool checkStartEdge =
     unsigned lineDepth = 1;
     LayoutUnit extraWidth = 0;
     RenderElement* parent = child->parent();
-    while (parent->isRenderInline() && lineDepth++ < cMaxLineDepth) {
-        const RenderInline& parentAsRenderInline = toRenderInline(*parent);
+    while (is<RenderInline>(*parent) && lineDepth++ < cMaxLineDepth) {
+        const auto& parentAsRenderInline = downcast<RenderInline>(*parent);
         if (!isEmptyInline(parentAsRenderInline)) {
             checkStartEdge = checkStartEdge && shouldAddBorderPaddingMargin(previousInFlowSibling(child));
             if (checkStartEdge)
@@ -373,7 +373,7 @@ inline bool shouldSkipWhitespaceAfterStartObject(RenderBlockFlow& block, RenderO
 
 inline void BreakingContext::handleEmptyInline()
 {
-    RenderInline& flowBox = toRenderInline(*m_current.renderer());
+    RenderInline& flowBox = downcast<RenderInline>(*m_current.renderer());
 
     // This should only end up being called on empty inlines
     ASSERT(isEmptyInline(flowBox));
index 0b0c44e..9058b3d 100644 (file)
@@ -105,8 +105,8 @@ inline bool requiresLineBox(const InlineIterator& it, const LineInfo& lineInfo =
         return true;
 
     bool rendererIsEmptyInline = false;
-    if (it.renderer()->isRenderInline()) {
-        const RenderInline& inlineRenderer = toRenderInline(*it.renderer());
+    if (is<RenderInline>(*it.renderer())) {
+        const auto& inlineRenderer = downcast<RenderInline>(*it.renderer());
         if (!alwaysRequiresLineBox(inlineRenderer) && !requiresLineBoxForContent(inlineRenderer, lineInfo))
             return false;
         rendererIsEmptyInline = isEmptyInline(inlineRenderer);
@@ -126,12 +126,12 @@ inline void setStaticPositions(RenderBlockFlow& block, RenderBox& child)
     // will work for the common cases
     RenderElement* containerBlock = child.container();
     LayoutUnit blockHeight = block.logicalHeight();
-    if (containerBlock->isRenderInline()) {
+    if (is<RenderInline>(*containerBlock)) {
         // A relative positioned inline encloses us. In this case, we also have to determine our
         // position as though we were an inline. Set |staticInlinePosition| and |staticBlockPosition| on the relative positioned
         // inline so that we can obtain the value later.
-        toRenderInline(containerBlock)->layer()->setStaticInlinePosition(block.startAlignedOffsetForLine(blockHeight, false));
-        toRenderInline(containerBlock)->layer()->setStaticBlockPosition(blockHeight);
+        downcast<RenderInline>(*containerBlock).layer()->setStaticInlinePosition(block.startAlignedOffsetForLine(blockHeight, false));
+        downcast<RenderInline>(*containerBlock).layer()->setStaticBlockPosition(blockHeight);
     }
     block.updateStaticInlinePositionForChild(child, blockHeight);
     child.layer()->setStaticBlockPosition(blockHeight);
index 0b3d7db..30d0eb5 100644 (file)
@@ -338,8 +338,8 @@ void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
     }
 
     // Finally, paint the outline if any.
-    if (renderer().style().hasOutline() && parentRenderer.isRenderInline())
-        toRenderInline(parentRenderer).paintOutline(paintInfo, paintOffset);
+    if (renderer().style().hasOutline() && is<RenderInline>(parentRenderer))
+        downcast<RenderInline>(parentRenderer).paintOutline(paintInfo, paintOffset);
 
     ASSERT(!m_paintingResource);
 }