Title: [174746] trunk/Source/WebCore
Revision
174746
Author
cdu...@apple.com
Date
2014-10-15 17:05:37 -0700 (Wed, 15 Oct 2014)

Log Message

Use is<>() / downcast<>() for InlineBox subclasses
https://bugs.webkit.org/show_bug.cgi?id=137749

Reviewed by Darin Adler.

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

No new tests, no behavior change.

* dom/Position.cpp:
(WebCore::Position::upstream):
(WebCore::Position::downstream):
* editing/VisibleUnits.cpp:
(WebCore::wordBreakIteratorForMinOffsetBoundary):
(WebCore::wordBreakIteratorForMaxOffsetBoundary):
(WebCore::visualWordPosition):
(WebCore::startPositionForLine):
(WebCore::endPositionForLine):
* rendering/InlineBox.cpp:
(WebCore::InlineBox::root):
(WebCore::InlineBox::nextLeafChild):
(WebCore::InlineBox::prevLeafChild):
(WebCore::InlineBox::nextLeafChildIgnoringLineBreak):
* rendering/InlineBox.h:
* rendering/InlineElementBox.h:
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::getFlowSpacingLogicalWidth):
(WebCore::InlineFlowBox::addToLine):
(WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
(WebCore::InlineFlowBox::placeBoxRangeInInlineDirection):
(WebCore::InlineFlowBox::requiresIdeographicBaseline):
(WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
(WebCore::InlineFlowBox::computeLogicalBoxHeights):
(WebCore::InlineFlowBox::placeBoxesInBlockDirection):
(WebCore::InlineFlowBox::computeMaxLogicalTop):
(WebCore::InlineFlowBox::flipLinesInBlockDirection):
(WebCore::InlineFlowBox::computeOverflow):
(WebCore::InlineFlowBox::firstLeafChild):
(WebCore::InlineFlowBox::lastLeafChild):
(WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
(WebCore::InlineFlowBox::computeUnderAnnotationAdjustment):
* rendering/InlineFlowBox.h:
* rendering/InlineTextBox.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::positionForBox):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::firstRootBox):
(WebCore::RenderBlockFlow::lastRootBox):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::createLineBoxes):
(WebCore::RenderBlockFlow::constructLine):
(WebCore::setLogicalWidthForTextRun):
(WebCore::computeExpansionForJustifiedText):
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
(WebCore::RenderBlockFlow::computeBlockDirectionPositionsForLine):
(WebCore::RenderBlockFlow::createLineBoxesFromBidiRuns):
* rendering/RenderText.cpp:
(WebCore::RenderText::localCaretRect):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::isHyphenated):
(WebCore::RootInlineBox::ascentAndDescentForBox):
* rendering/RootInlineBox.h:
(WebCore::RootInlineBox::nextRootBox):
(WebCore::RootInlineBox::prevRootBox):
* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::localCaretRect):
(WebCore::RenderSVGInlineText::positionForPoint):
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::positionForPoint):
* rendering/svg/SVGInlineFlowBox.cpp:
(WebCore::SVGInlineFlowBox::paintSelectionBackground):
(WebCore::SVGInlineFlowBox::paint):
(WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):
* rendering/svg/SVGInlineFlowBox.h:
* rendering/svg/SVGInlineTextBox.h:
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::writeRenderSVGTextBox):
(WebCore::writeSVGInlineTextBoxes):
* rendering/svg/SVGRootInlineBox.cpp:
(WebCore::SVGRootInlineBox::paint):
(WebCore::SVGRootInlineBox::layoutCharactersInTextBoxes):
(WebCore::SVGRootInlineBox::layoutChildBoxes):
(WebCore::reverseInlineBoxRangeAndValueListsIfNeeded):
* rendering/svg/SVGRootInlineBox.h:
* rendering/svg/SVGTextQuery.cpp:
(WebCore::SVGTextQuery::collectTextBoxesInFlowBox):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174745 => 174746)


--- trunk/Source/WebCore/ChangeLog	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/ChangeLog	2014-10-16 00:05:37 UTC (rev 174746)
@@ -1,3 +1,93 @@
+2014-10-15  Chris Dumez  <cdu...@apple.com>
+
+        Use is<>() / downcast<>() for InlineBox subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137749
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for InlineBox subclasses and clean up the
+        surrounding code.
+
+        No new tests, no behavior change.
+
+        * dom/Position.cpp:
+        (WebCore::Position::upstream):
+        (WebCore::Position::downstream):
+        * editing/VisibleUnits.cpp:
+        (WebCore::wordBreakIteratorForMinOffsetBoundary):
+        (WebCore::wordBreakIteratorForMaxOffsetBoundary):
+        (WebCore::visualWordPosition):
+        (WebCore::startPositionForLine):
+        (WebCore::endPositionForLine):
+        * rendering/InlineBox.cpp:
+        (WebCore::InlineBox::root):
+        (WebCore::InlineBox::nextLeafChild):
+        (WebCore::InlineBox::prevLeafChild):
+        (WebCore::InlineBox::nextLeafChildIgnoringLineBreak):
+        * rendering/InlineBox.h:
+        * rendering/InlineElementBox.h:
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::getFlowSpacingLogicalWidth):
+        (WebCore::InlineFlowBox::addToLine):
+        (WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
+        (WebCore::InlineFlowBox::placeBoxRangeInInlineDirection):
+        (WebCore::InlineFlowBox::requiresIdeographicBaseline):
+        (WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
+        (WebCore::InlineFlowBox::computeLogicalBoxHeights):
+        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
+        (WebCore::InlineFlowBox::computeMaxLogicalTop):
+        (WebCore::InlineFlowBox::flipLinesInBlockDirection):
+        (WebCore::InlineFlowBox::computeOverflow):
+        (WebCore::InlineFlowBox::firstLeafChild):
+        (WebCore::InlineFlowBox::lastLeafChild):
+        (WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
+        (WebCore::InlineFlowBox::computeUnderAnnotationAdjustment):
+        * rendering/InlineFlowBox.h:
+        * rendering/InlineTextBox.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::positionForBox):
+        * rendering/RenderBlockFlow.h:
+        (WebCore::RenderBlockFlow::firstRootBox):
+        (WebCore::RenderBlockFlow::lastRootBox):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::createLineBoxes):
+        (WebCore::RenderBlockFlow::constructLine):
+        (WebCore::setLogicalWidthForTextRun):
+        (WebCore::computeExpansionForJustifiedText):
+        (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+        (WebCore::RenderBlockFlow::computeBlockDirectionPositionsForLine):
+        (WebCore::RenderBlockFlow::createLineBoxesFromBidiRuns):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::localCaretRect):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::isHyphenated):
+        (WebCore::RootInlineBox::ascentAndDescentForBox):
+        * rendering/RootInlineBox.h:
+        (WebCore::RootInlineBox::nextRootBox):
+        (WebCore::RootInlineBox::prevRootBox):
+        * rendering/svg/RenderSVGInlineText.cpp:
+        (WebCore::RenderSVGInlineText::localCaretRect):
+        (WebCore::RenderSVGInlineText::positionForPoint):
+        * rendering/svg/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::positionForPoint):
+        * rendering/svg/SVGInlineFlowBox.cpp:
+        (WebCore::SVGInlineFlowBox::paintSelectionBackground):
+        (WebCore::SVGInlineFlowBox::paint):
+        (WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):
+        * rendering/svg/SVGInlineFlowBox.h:
+        * rendering/svg/SVGInlineTextBox.h:
+        * rendering/svg/SVGRenderTreeAsText.cpp:
+        (WebCore::writeRenderSVGTextBox):
+        (WebCore::writeSVGInlineTextBoxes):
+        * rendering/svg/SVGRootInlineBox.cpp:
+        (WebCore::SVGRootInlineBox::paint):
+        (WebCore::SVGRootInlineBox::layoutCharactersInTextBoxes):
+        (WebCore::SVGRootInlineBox::layoutChildBoxes):
+        (WebCore::reverseInlineBoxRangeAndValueListsIfNeeded):
+        * rendering/svg/SVGRootInlineBox.h:
+        * rendering/svg/SVGTextQuery.cpp:
+        (WebCore::SVGTextQuery::collectTextBoxesInFlowBox):
+
 2014-10-15  Roger Fong  <roger_f...@apple.com>
 
         glReadPixels on NVIDIA cards returns the wrong values for the alpha channel when alpha is off.

Modified: trunk/Source/WebCore/dom/Position.cpp (174745 => 174746)


--- trunk/Source/WebCore/dom/Position.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/dom/Position.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -661,7 +661,7 @@
                     otherBox = otherBox->nextLeafChild();
                     if (!otherBox)
                         break;
-                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() > textOffset))
+                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && downcast<InlineTextBox>(*otherBox).start() > textOffset))
                         continuesOnNextLine = false;
                 }
 
@@ -670,7 +670,7 @@
                     otherBox = otherBox->prevLeafChild();
                     if (!otherBox)
                         break;
-                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() > textOffset))
+                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && downcast<InlineTextBox>(*otherBox).start() > textOffset))
                         continuesOnNextLine = false;
                 }
 
@@ -789,7 +789,7 @@
                     otherBox = otherBox->nextLeafChild();
                     if (!otherBox)
                         break;
-                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() >= textOffset))
+                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && downcast<InlineTextBox>(*otherBox).start() >= textOffset))
                         continuesOnNextLine = false;
                 }
 
@@ -798,7 +798,7 @@
                     otherBox = otherBox->prevLeafChild();
                     if (!otherBox)
                         break;
-                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() >= textOffset))
+                    if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && downcast<InlineTextBox>(*otherBox).start() >= textOffset))
                         continuesOnNextLine = false;
                 }
 

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (174745 => 174746)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -292,10 +292,10 @@
 
     string.clear();
 
-    if (previousBox && previousBox->isInlineTextBox()) {
-        const InlineTextBox* previousTextBox = toInlineTextBox(previousBox);
-        previousBoxLength = previousTextBox->len();
-        append(string, StringView(previousTextBox->renderer().text()).substring(previousTextBox->start(), previousBoxLength));
+    if (is<InlineTextBox>(previousBox)) {
+        const auto& previousTextBox = downcast<InlineTextBox>(*previousBox);
+        previousBoxLength = previousTextBox.len();
+        append(string, StringView(previousTextBox.renderer().text()).substring(previousTextBox.start(), previousBoxLength));
     }
     append(string, StringView(textBox->renderer().text()).substring(textBox->start(), textBox->len()));
 
@@ -312,9 +312,9 @@
 
     string.clear();
     append(string, StringView(textBox->renderer().text()).substring(textBox->start(), textBox->len()));
-    if (nextBox && nextBox->isInlineTextBox()) {
-        const InlineTextBox* nextTextBox = toInlineTextBox(nextBox);
-        append(string, StringView(nextTextBox->renderer().text()).substring(nextTextBox->start(), nextTextBox->len()));
+    if (is<InlineTextBox>(nextBox)) {
+        const auto& nextTextBox = downcast<InlineTextBox>(*nextBox);
+        append(string, StringView(nextTextBox.renderer().text()).substring(nextTextBox.start(), nextTextBox.len()));
     }
 
     return wordBreakIterator(StringView(string.data(), string.size()));
@@ -364,23 +364,23 @@
     
         if (!box)
             break;
-        if (!box->isInlineTextBox()) {
+        if (!is<InlineTextBox>(*box)) {
             current = adjacentCharacterPosition;
             continue;
         }
 
-        InlineTextBox* textBox = toInlineTextBox(box);
+        InlineTextBox& textBox = downcast<InlineTextBox>(*box);
         int previousBoxLength = 0;
         bool previousBoxInDifferentBlock = false;
         bool nextBoxInDifferentBlock = false;
         bool movingIntoNewBox = previouslyVisitedBox != box;
 
         if (offsetInBox == box->caretMinOffset())
-            iter = wordBreakIteratorForMinOffsetBoundary(visiblePosition, textBox, previousBoxLength, previousBoxInDifferentBlock, string, leafBoxes);
+            iter = wordBreakIteratorForMinOffsetBoundary(visiblePosition, &textBox, previousBoxLength, previousBoxInDifferentBlock, string, leafBoxes);
         else if (offsetInBox == box->caretMaxOffset())
-            iter = wordBreakIteratorForMaxOffsetBoundary(visiblePosition, textBox, nextBoxInDifferentBlock, string, leafBoxes);
+            iter = wordBreakIteratorForMaxOffsetBoundary(visiblePosition, &textBox, nextBoxInDifferentBlock, string, leafBoxes);
         else if (movingIntoNewBox) {
-            iter = wordBreakIterator(StringView(textBox->renderer().text()).substring(textBox->start(), textBox->len()));
+            iter = wordBreakIterator(StringView(textBox.renderer().text()).substring(textBox.start(), textBox.len()));
             previouslyVisitedBox = box;
         }
 
@@ -388,17 +388,17 @@
             break;
 
         textBreakFirst(iter);
-        int offsetInIterator = offsetInBox - textBox->start() + previousBoxLength;
+        int offsetInIterator = offsetInBox - textBox.start() + previousBoxLength;
 
         bool isWordBreak;
         bool boxHasSameDirectionalityAsBlock = box->direction() == blockDirection;
         bool movingBackward = (direction == MoveLeft && box->direction() == LTR) || (direction == MoveRight && box->direction() == RTL);
         if ((skipsSpaceWhenMovingRight && boxHasSameDirectionalityAsBlock)
             || (!skipsSpaceWhenMovingRight && movingBackward)) {
-            bool logicalStartInRenderer = offsetInBox == static_cast<int>(textBox->start()) && previousBoxInDifferentBlock;
+            bool logicalStartInRenderer = offsetInBox == static_cast<int>(textBox.start()) && previousBoxInDifferentBlock;
             isWordBreak = isLogicalStartOfWord(iter, offsetInIterator, logicalStartInRenderer);
         } else {
-            bool logicalEndInRenderer = offsetInBox == static_cast<int>(textBox->start() + textBox->len()) && nextBoxInDifferentBlock;
+            bool logicalEndInRenderer = offsetInBox == static_cast<int>(textBox.start() + textBox.len()) && nextBoxInDifferentBlock;
             isWordBreak = islogicalEndOfWord(iter, offsetInIterator, logicalEndInRenderer);
         }      
 
@@ -767,7 +767,7 @@
         }
     }
 
-    return is<Text>(*startNode) ? Position(downcast<Text>(startNode), toInlineTextBox(startBox)->start())
+    return is<Text>(*startNode) ? Position(downcast<Text>(startNode), downcast<InlineTextBox>(*startBox).start())
         : positionBeforeNode(startNode);
 }
 
@@ -836,13 +836,13 @@
     }
 
     Position pos;
-    if (endNode->hasTagName(brTag))
+    if (is<HTMLBRElement>(*endNode))
         pos = positionBeforeNode(endNode);
-    else if (endBox->isInlineTextBox() && is<Text>(*endNode)) {
-        InlineTextBox* endTextBox = toInlineTextBox(endBox);
-        int endOffset = endTextBox->start();
-        if (!endTextBox->isLineBreak())
-            endOffset += endTextBox->len();
+    else if (is<InlineTextBox>(*endBox) && is<Text>(*endNode)) {
+        auto& endTextBox = downcast<InlineTextBox>(*endBox);
+        int endOffset = endTextBox.start();
+        if (!endTextBox.isLineBreak())
+            endOffset += endTextBox.len();
         pos = Position(downcast<Text>(endNode), endOffset);
     } else
         pos = positionAfterNode(endNode);

Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/InlineBox.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -184,16 +184,14 @@
 { 
     if (parent())
         return parent()->root();
-    ASSERT_WITH_SECURITY_IMPLICATION(isRootInlineBox());
-    return toRootInlineBox(*this);
+    return downcast<RootInlineBox>(*this);
 }
 
 RootInlineBox& InlineBox::root()
 { 
     if (parent())
         return parent()->root();
-    ASSERT_WITH_SECURITY_IMPLICATION(isRootInlineBox());
-    return toRootInlineBox(*this);
+    return downcast<RootInlineBox>(*this);
 }
 
 bool InlineBox::nextOnLineExists() const
@@ -222,9 +220,9 @@
 
 InlineBox* InlineBox::nextLeafChild() const
 {
-    InlineBox* leaf = 0;
+    InlineBox* leaf = nullptr;
     for (InlineBox* box = nextOnLine(); box && !leaf; box = box->nextOnLine())
-        leaf = box->isLeaf() ? box : toInlineFlowBox(box)->firstLeafChild();
+        leaf = box->isLeaf() ? box : downcast<InlineFlowBox>(*box).firstLeafChild();
     if (!leaf && parent())
         leaf = parent()->nextLeafChild();
     return leaf;
@@ -232,9 +230,9 @@
     
 InlineBox* InlineBox::prevLeafChild() const
 {
-    InlineBox* leaf = 0;
+    InlineBox* leaf = nullptr;
     for (InlineBox* box = prevOnLine(); box && !leaf; box = box->prevOnLine())
-        leaf = box->isLeaf() ? box : toInlineFlowBox(box)->lastLeafChild();
+        leaf = box->isLeaf() ? box : downcast<InlineFlowBox>(*box).lastLeafChild();
     if (!leaf && parent())
         leaf = parent()->prevLeafChild();
     return leaf;
@@ -244,7 +242,7 @@
 {
     InlineBox* leaf = nextLeafChild();
     if (leaf && leaf->isLineBreak())
-        return 0;
+        return nullptr;
     return leaf;
 }
 

Modified: trunk/Source/WebCore/rendering/InlineBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/InlineBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -24,6 +24,7 @@
 #include "RenderBoxModelObject.h"
 #include "RenderText.h"
 #include "TextDirection.h"
+#include <wtf/TypeCasts.h>
 
 namespace WebCore {
 
@@ -421,9 +422,6 @@
 #endif
 };
 
-#define INLINE_BOX_OBJECT_TYPE_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, InlineBox, object, object->predicate, object.predicate)
-
 #if ASSERT_WITH_SECURITY_IMPLICATION_DISABLED
 
 inline InlineBox::~InlineBox()
@@ -438,6 +436,11 @@
 
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_INLINE_BOX(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+    static bool isType(const WebCore::InlineBox& box) { return box.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #ifndef NDEBUG
 // Outside the WebCore namespace for ease of invocation from gdb.
 void showNodeTree(const WebCore::InlineBox*);

Modified: trunk/Source/WebCore/rendering/InlineElementBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/InlineElementBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/InlineElementBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -55,8 +55,8 @@
     virtual bool isInlineElementBox() const override final { return true; }
 };
 
-INLINE_BOX_OBJECT_TYPE_CASTS(InlineElementBox, isInlineElementBox())
+} // namespace WebCore
 
-}
+SPECIALIZE_TYPE_TRAITS_INLINE_BOX(InlineElementBox, isInlineElementBox())
 
 #endif // InlineElementBox_h

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -30,6 +30,7 @@
 #include "RenderBlock.h"
 #include "RenderInline.h"
 #include "RenderLayer.h"
+#include "RenderLineBreak.h"
 #include "RenderListMarker.h"
 #include "RenderRubyBase.h"
 #include "RenderRubyRun.h"
@@ -70,12 +71,12 @@
 
 LayoutUnit InlineFlowBox::getFlowSpacingLogicalWidth()
 {
-    LayoutUnit totWidth = marginBorderPaddingLogicalLeft() + marginBorderPaddingLogicalRight();
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->isInlineFlowBox())
-            totWidth += toInlineFlowBox(curr)->getFlowSpacingLogicalWidth();
+    LayoutUnit totalWidth = marginBorderPaddingLogicalLeft() + marginBorderPaddingLogicalRight();
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (is<InlineFlowBox>(*child))
+            totalWidth += downcast<InlineFlowBox>(*child).getFlowSpacingLogicalWidth();
     }
-    return totWidth;
+    return totalWidth;
 }
 
 static void setHasTextDescendantsOnAncestors(InlineFlowBox* box)
@@ -108,8 +109,8 @@
         if (child->renderer().parent() == &renderer())
             m_hasTextChildren = true;
         setHasTextDescendantsOnAncestors(this);
-    } else if (child->isInlineFlowBox()) {
-        if (toInlineFlowBox(child)->hasTextDescendants())
+    } else if (is<InlineFlowBox>(*child)) {
+        if (downcast<InlineFlowBox>(*child).hasTextDescendants())
             setHasTextDescendantsOnAncestors(this);
     }
 
@@ -134,10 +135,9 @@
                 // Other than making a zillion tests have to regenerate results, there's no reason to ditch the optimization here.
                 shouldClearDescendantsHaveSameLineHeightAndBaseline = child->renderer().isBR();
             } else {
-                ASSERT(isInlineFlowBox());
-                InlineFlowBox* childFlowBox = toInlineFlowBox(child);
+                auto& childFlowBox = downcast<InlineFlowBox>(*child);
                 // Check the child's bit, and then also check for differences in font, line-height, vertical-align
-                if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline()
+                if (!childFlowBox.descendantsHaveSameLineHeightAndBaseline()
                     || !parentStyle.font().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle.font().fontMetrics())
                     || parentStyle.lineHeight() != childStyle.lineHeight()
                     || (parentStyle.verticalAlign() != BASELINE && !isRootInlineBox()) || childStyle.verticalAlign() != BASELINE
@@ -165,7 +165,7 @@
             || childStyle.hasBorderImageOutsets()))
             child->clearKnownToHaveNoOverflow();
         
-        if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlowBox(child)->knownToHaveNoOverflow())
+        if (knownToHaveNoOverflow() && is<InlineFlowBox>(*child) && !downcast<InlineFlowBox>(*child).knownToHaveNoOverflow())
             clearKnownToHaveNoOverflow();
     }
 
@@ -347,11 +347,9 @@
     setEdges(includeLeftEdge, includeRightEdge);
 
     // Recur into our children.
-    for (InlineBox* currChild = firstChild(); currChild; currChild = currChild->nextOnLine()) {
-        if (currChild->isInlineFlowBox()) {
-            InlineFlowBox* currFlow = toInlineFlowBox(currChild);
-            currFlow->determineSpacingForFlowBoxes(lastLine, isLogicallyLastRunWrapped, logicallyLastRunRenderer);
-        }
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (is<InlineFlowBox>(*child))
+            downcast<InlineFlowBox>(*child).determineSpacingForFlowBoxes(lastLine, isLogicallyLastRunWrapped, logicallyLastRunRenderer);
     }
 }
 
@@ -375,52 +373,52 @@
 
 float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing)
 {
-    for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->nextOnLine()) {
-        if (curr->renderer().isText()) {
-            InlineTextBox* text = toInlineTextBox(curr);
-            RenderText& rt = text->renderer();
-            if (rt.textLength()) {
-                if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->start())))
-                    logicalLeft += text->lineStyle().font().wordSpacing();
-                needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()));
+    for (InlineBox* child = firstChild; child && child != lastChild; child = child->nextOnLine()) {
+        if (is<RenderText>(child->renderer())) {
+            auto& textBox = downcast<InlineTextBox>(*child);
+            RenderText& renderText = textBox.renderer();
+            if (renderText.textLength()) {
+                if (needsWordSpacing && isSpaceOrNewline(renderText.characterAt(textBox.start())))
+                    logicalLeft += textBox.lineStyle().font().wordSpacing();
+                needsWordSpacing = !isSpaceOrNewline(renderText.characterAt(textBox.end()));
             }
-            text->setLogicalLeft(logicalLeft);
+            textBox.setLogicalLeft(logicalLeft);
             if (knownToHaveNoOverflow())
                 minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
-            logicalLeft += text->logicalWidth();
+            logicalLeft += textBox.logicalWidth();
             if (knownToHaveNoOverflow())
                 maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
         } else {
-            if (curr->renderer().isOutOfFlowPositioned()) {
-                if (curr->renderer().parent()->style().isLeftToRightDirection())
-                    curr->setLogicalLeft(logicalLeft);
+            if (child->renderer().isOutOfFlowPositioned()) {
+                if (child->renderer().parent()->style().isLeftToRightDirection())
+                    child->setLogicalLeft(logicalLeft);
                 else
                     // Our offset that we cache needs to be from the edge of the right border box and
                     // not the left border box.  We have to subtract |x| from the width of the block
                     // (which can be obtained from the root line box).
-                    curr->setLogicalLeft(root().blockFlow().logicalWidth() - logicalLeft);
+                    child->setLogicalLeft(root().blockFlow().logicalWidth() - logicalLeft);
                 continue; // The positioned object has no effect on the width.
             }
-            if (curr->renderer().isRenderInline()) {
-                InlineFlowBox* flow = toInlineFlowBox(curr);
-                logicalLeft += flow->marginLogicalLeft();
+            if (is<RenderInline>(child->renderer())) {
+                auto& flow = downcast<InlineFlowBox>(*child);
+                logicalLeft += flow.marginLogicalLeft();
                 if (knownToHaveNoOverflow())
                     minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
-                logicalLeft = flow->placeBoxesInInlineDirection(logicalLeft, needsWordSpacing);
+                logicalLeft = flow.placeBoxesInInlineDirection(logicalLeft, needsWordSpacing);
                 if (knownToHaveNoOverflow())
                     maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
-                logicalLeft += flow->marginLogicalRight();
-            } else if (!curr->renderer().isListMarker() || toRenderListMarker(curr->renderer()).isInside()) {
+                logicalLeft += flow.marginLogicalRight();
+            } else if (!child->renderer().isListMarker() || toRenderListMarker(child->renderer()).isInside()) {
                 // The box can have a different writing-mode than the overall line, so this is a bit complicated.
                 // Just get all the physical margin and overflow values by hand based off |isVertical|.
-                LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop();
-                LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelObject()->marginRight() : curr->boxModelObject()->marginBottom();
+                LayoutUnit logicalLeftMargin = isHorizontal() ? child->boxModelObject()->marginLeft() : child->boxModelObject()->marginTop();
+                LayoutUnit logicalRightMargin = isHorizontal() ? child->boxModelObject()->marginRight() : child->boxModelObject()->marginBottom();
                 
                 logicalLeft += logicalLeftMargin;
-                curr->setLogicalLeft(logicalLeft);
+                child->setLogicalLeft(logicalLeft);
                 if (knownToHaveNoOverflow())
                     minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
-                logicalLeft += curr->logicalWidth();
+                logicalLeft += child->logicalWidth();
                 if (knownToHaveNoOverflow())
                     maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
                 logicalLeft += logicalRightMargin;
@@ -442,26 +440,26 @@
         || lineStyle.font().primaryFont()->hasVerticalGlyphs())
         return true;
 
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
         
-        if (curr->isInlineFlowBox()) {
-            if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMap))
+        if (is<InlineFlowBox>(*child)) {
+            if (downcast<InlineFlowBox>(*child).requiresIdeographicBaseline(textBoxDataMap))
                 return true;
         } else {
-            if (curr->lineStyle().font().primaryFont()->hasVerticalGlyphs())
+            if (child->lineStyle().font().primaryFont()->hasVerticalGlyphs())
                 return true;
             
-            const Vector<const SimpleFontData*>* usedFonts = 0;
-            if (curr->isInlineTextBox()) {
-                GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDataMap.find(toInlineTextBox(curr));
-                usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first;
+            const Vector<const SimpleFontData*>* usedFonts = nullptr;
+            if (is<InlineTextBox>(*child)) {
+                GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDataMap.find(downcast<InlineTextBox>(child));
+                usedFonts = it == textBoxDataMap.end() ? nullptr : &it->value.first;
             }
 
             if (usedFonts) {
-                for (size_t i = 0; i < usedFonts->size(); ++i) {
-                    if (usedFonts->at(i)->hasVerticalGlyphs())
+                for (const SimpleFontData* fontData : *usedFonts) {
+                    if (fontData->hasVerticalGlyphs())
                         return true;
                 }
             }
@@ -480,15 +478,15 @@
 
 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, int maxPositionTop, int maxPositionBottom)
 {
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
         // The computed lineheight needs to be extended for the
         // positioned elements
-        if (curr->renderer().isOutOfFlowPositioned())
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
 
-        if ((curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) && verticalAlignApplies(curr->renderer())) {
-            int lineHeight = curr->lineHeight();
-            if (curr->verticalAlign() == TOP) {
+        if ((child->verticalAlign() == TOP || child->verticalAlign() == BOTTOM) && verticalAlignApplies(child->renderer())) {
+            int lineHeight = child->lineHeight();
+            if (child->verticalAlign() == TOP) {
                 if (maxAscent + maxDescent < lineHeight)
                     maxDescent = lineHeight - maxAscent;
             }
@@ -501,8 +499,8 @@
                 break;
         }
 
-        if (curr->isInlineFlowBox())
-            toInlineFlowBox(curr)->adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom);
+        if (is<InlineFlowBox>(*child))
+            downcast<InlineFlowBox>(*child).adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom);
     }
 }
 
@@ -550,11 +548,11 @@
     if (!checkChildren)
         return;
 
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
         
-        InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox(curr) : 0;
+        InlineFlowBox* inlineFlowBox = is<InlineFlowBox>(*child) ? downcast<InlineFlowBox>(child) : nullptr;
         
         bool affectsAscent = false;
         bool affectsDescent = false;
@@ -562,17 +560,17 @@
         // The verticalPositionForBox function returns the distance between the child box's baseline
         // and the root box's baseline.  The value is negative if the child box's baseline is above the
         // root box's baseline, and it is positive if the child box's baseline is below the root box's baseline.
-        curr->setLogicalTop(rootBox.verticalPositionForBox(curr, verticalPositionCache));
+        child->setLogicalTop(rootBox.verticalPositionForBox(child, verticalPositionCache));
         
         int ascent = 0;
         int descent = 0;
-        rootBox.ascentAndDescentForBox(*curr, textBoxDataMap, ascent, descent, affectsAscent, affectsDescent);
+        rootBox.ascentAndDescentForBox(*child, textBoxDataMap, ascent, descent, affectsAscent, affectsDescent);
 
         LayoutUnit boxHeight = ascent + descent;
-        if (curr->verticalAlign() == TOP && verticalAlignApplies(curr->renderer())) {
+        if (child->verticalAlign() == TOP && verticalAlignApplies(child->renderer())) {
             if (maxPositionTop < boxHeight)
                 maxPositionTop = boxHeight;
-        } else if (curr->verticalAlign() == BOTTOM && verticalAlignApplies(curr->renderer())) {
+        } else if (child->verticalAlign() == BOTTOM && verticalAlignApplies(child->renderer())) {
             if (maxPositionBottom < boxHeight)
                 maxPositionBottom = boxHeight;
         } else if (!inlineFlowBox || strictMode || inlineFlowBox->hasTextChildren() || (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlowBox->hasTextDescendants())
@@ -583,8 +581,8 @@
             // means is that ascent and descent (including leading), can end up being negative.  The setMaxAscent and
             // setMaxDescent booleans are used to ensure that we're willing to initially set maxAscent/Descent to negative
             // values.
-            ascent -= curr->logicalTop();
-            descent += curr->logicalTop();
+            ascent -= child->logicalTop();
+            descent += child->logicalTop();
             if (affectsAscent && (maxAscent < ascent || !setMaxAscent)) {
                 maxAscent = ascent;
                 setMaxAscent = true;
@@ -621,78 +619,78 @@
             adjustmentForChildrenWithSameLineHeightAndBaseline += renderer().borderAndPaddingBefore();
     }
 
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
 
         if (descendantsHaveSameLineHeightAndBaseline()) {
-            curr->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLineHeightAndBaseline);
+            child->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLineHeightAndBaseline);
             continue;
         }
 
-        InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox(curr) : 0;
+        InlineFlowBox* inlineFlowBox = is<InlineFlowBox>(*child) ? downcast<InlineFlowBox>(child) : nullptr;
         bool childAffectsTopBottomPos = true;
 
-        if (curr->verticalAlign() == TOP && verticalAlignApplies(curr->renderer()))
-            curr->setLogicalTop(top);
-        else if (curr->verticalAlign() == BOTTOM && verticalAlignApplies(curr->renderer()))
-            curr->setLogicalTop(top + maxHeight - curr->lineHeight());
+        if (child->verticalAlign() == TOP && verticalAlignApplies(child->renderer()))
+            child->setLogicalTop(top);
+        else if (child->verticalAlign() == BOTTOM && verticalAlignApplies(child->renderer()))
+            child->setLogicalTop(top + maxHeight - child->lineHeight());
         else {
             if (!strictMode && inlineFlowBox && !inlineFlowBox->hasTextChildren() && !inlineFlowBox->renderer().hasInlineDirectionBordersOrPadding()
                 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlowBox->hasTextDescendants()))
                 childAffectsTopBottomPos = false;
-            LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineType);
-            curr->setLogicalTop(curr->logicalTop() + top + posAdjust);
+            LayoutUnit posAdjust = maxAscent - child->baselinePosition(baselineType);
+            child->setLogicalTop(child->logicalTop() + top + posAdjust);
         }
         
-        LayoutUnit newLogicalTop = curr->logicalTop();
+        LayoutUnit newLogicalTop = child->logicalTop();
         LayoutUnit newLogicalTopIncludingMargins = newLogicalTop;
-        LayoutUnit boxHeight = curr->logicalHeight();
+        LayoutUnit boxHeight = child->logicalHeight();
         LayoutUnit boxHeightIncludingMargins = boxHeight;
 
-        const RenderStyle& childLineStyle = curr->lineStyle();
-        if (curr->behavesLikeText() || curr->isInlineFlowBox()) {
+        const RenderStyle& childLineStyle = child->lineStyle();
+        if (child->behavesLikeText() || is<InlineFlowBox>(*child)) {
             const FontMetrics& fontMetrics = childLineStyle.fontMetrics();
-            newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
-            if (curr->isInlineFlowBox()) {
-                RenderBoxModelObject& boxObject = downcast<RenderBoxModelObject>(curr->renderer());
+            newLogicalTop += child->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
+            if (is<InlineFlowBox>(*child)) {
+                RenderBoxModelObject& boxObject = downcast<InlineFlowBox>(*child).renderer();
                 newLogicalTop -= childLineStyle.isHorizontalWritingMode()
                     ? boxObject.borderTop() + boxObject.paddingTop()
                     : boxObject.borderRight() + boxObject.paddingRight();
             }
             newLogicalTopIncludingMargins = newLogicalTop;
-        } else if (!curr->renderer().isBR()) {
-            const RenderBox& box = toRenderBox(curr->renderer());
+        } else if (!child->renderer().isBR()) {
+            const auto& box = downcast<RenderBox>(child->renderer());
             newLogicalTopIncludingMargins = newLogicalTop;
-            LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() : box.marginRight();
-            LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom() : box.marginLeft();
+            LayoutUnit overSideMargin = child->isHorizontal() ? box.marginTop() : box.marginRight();
+            LayoutUnit underSideMargin = child->isHorizontal() ? box.marginBottom() : box.marginLeft();
             newLogicalTop += overSideMargin;
             boxHeightIncludingMargins += overSideMargin + underSideMargin;
         }
 
-        curr->setLogicalTop(newLogicalTop);
+        child->setLogicalTop(newLogicalTop);
 
         if (childAffectsTopBottomPos) {
-            if (curr->renderer().isRubyRun()) {
+            if (is<RenderRubyRun>(child->renderer())) {
                 // Treat the leading on the first and last lines of ruby runs as not being part of the overall lineTop/lineBottom.
                 // Really this is a workaround hack for the fact that ruby should have been done as line layout and not done using
                 // inline-block.
-                if (renderer().style().isFlippedLinesWritingMode() == (curr->renderer().style().rubyPosition() == RubyPositionAfter))
+                if (renderer().style().isFlippedLinesWritingMode() == (child->renderer().style().rubyPosition() == RubyPositionAfter))
                     hasAnnotationsBefore = true;
                 else
                     hasAnnotationsAfter = true;
 
-                RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+                auto& rubyRun = downcast<RenderRubyRun>(child->renderer());
                 if (RenderRubyBase* rubyBase = rubyRun.rubyBase()) {
-                    LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit());
+                    LayoutUnit bottomRubyBaseLeading = (child->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit());
                     LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit());
                     newLogicalTop += !renderer().style().isFlippedLinesWritingMode() ? topRubyBaseLeading : bottomRubyBaseLeading;
                     boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading);
                 }
             }
-            if (curr->isInlineTextBox()) {
+            if (is<InlineTextBox>(*child)) {
                 bool emphasisMarkIsOver;
-                if (toInlineTextBox(curr)->emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsOver)) {
+                if (downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsOver)) {
                     if (emphasisMarkIsOver != childLineStyle.isFlippedLinesWritingMode())
                         hasAnnotationsBefore = true;
                     else
@@ -740,17 +738,17 @@
 
 void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const
 {
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
 
         if (descendantsHaveSameLineHeightAndBaseline())
             continue;
 
-        maxLogicalTop = std::max<float>(maxLogicalTop, curr->y());
+        maxLogicalTop = std::max<float>(maxLogicalTop, child->y());
         float localMaxLogicalTop = 0;
-        if (curr->isInlineFlowBox())
-            toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop);
+        if (is<InlineFlowBox>(*child))
+            downcast<InlineFlowBox>(*child).computeMaxLogicalTop(localMaxLogicalTop);
         maxLogicalTop = std::max<float>(maxLogicalTop, localMaxLogicalTop);
     }
 }
@@ -760,14 +758,14 @@
     // Flip the box on the line such that the top is now relative to the lineBottom instead of the lineTop.
     setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight());
     
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders aren't affected here.
         
-        if (curr->isInlineFlowBox())
-            toInlineFlowBox(curr)->flipLinesInBlockDirection(lineTop, lineBottom);
+        if (is<InlineFlowBox>(*child))
+            downcast<InlineFlowBox>(*child).flipLinesInBlockDirection(lineTop, lineBottom);
         else
-            curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - curr->logicalHeight());
+            child->setLogicalTop(lineBottom - (child->logicalTop() - lineTop) - child->logicalHeight());
     }
 }
 
@@ -938,27 +936,27 @@
     addBoxShadowVisualOverflow(logicalVisualOverflow);
     addBorderOutsetVisualOverflow(logicalVisualOverflow);
 
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
 
-        if (curr->renderer().isLineBreak())
+        if (is<RenderLineBreak>(child->renderer()))
             continue;
-        if (curr->renderer().isText()) {
-            InlineTextBox* text = toInlineTextBox(curr);
-            LayoutRect textBoxOverflow(enclosingLayoutRect(text->logicalFrameRect()));
-            addTextBoxVisualOverflow(*text, textBoxDataMap, textBoxOverflow);
+        if (is<RenderText>(child->renderer())) {
+            auto& textBox = downcast<InlineTextBox>(*child);
+            LayoutRect textBoxOverflow(enclosingLayoutRect(textBox.logicalFrameRect()));
+            addTextBoxVisualOverflow(textBox, textBoxDataMap, textBoxOverflow);
             logicalVisualOverflow.unite(textBoxOverflow);
-        } else if (curr->renderer().isRenderInline()) {
-            InlineFlowBox* flow = toInlineFlowBox(curr);
-            flow->computeOverflow(lineTop, lineBottom, textBoxDataMap);
-            if (!flow->renderer().hasSelfPaintingLayer())
-                logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(lineTop, lineBottom));
-            LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lineTop, lineBottom);
-            childLayoutOverflow.move(flow->renderer().relativePositionLogicalOffset());
+        } else if (is<RenderInline>(child->renderer())) {
+            auto& flow = downcast<InlineFlowBox>(*child);
+            flow.computeOverflow(lineTop, lineBottom, textBoxDataMap);
+            if (!flow.renderer().hasSelfPaintingLayer())
+                logicalVisualOverflow.unite(flow.logicalVisualOverflowRect(lineTop, lineBottom));
+            LayoutRect childLayoutOverflow = flow.logicalLayoutOverflowRect(lineTop, lineBottom);
+            childLayoutOverflow.move(flow.renderer().relativePositionLogicalOffset());
             logicalLayoutOverflow.unite(childLayoutOverflow);
         } else
-            addReplacedChildOverflow(curr, logicalLayoutOverflow, logicalVisualOverflow);
+            addReplacedChildOverflow(child, logicalLayoutOverflow, logicalVisualOverflow);
     }
     
     setOverflowFromLogicalRects(logicalLayoutOverflow, logicalVisualOverflow, lineTop, lineBottom);
@@ -1424,17 +1422,17 @@
 
 InlineBox* InlineFlowBox::firstLeafChild() const
 {
-    InlineBox* leaf = 0;
+    InlineBox* leaf = nullptr;
     for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnLine())
-        leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild();
+        leaf = child->isLeaf() ? child : downcast<InlineFlowBox>(*child).firstLeafChild();
     return leaf;
 }
 
 InlineBox* InlineFlowBox::lastLeafChild() const
 {
-    InlineBox* leaf = 0;
+    InlineBox* leaf = nullptr;
     for (InlineBox* child = lastChild(); child && !leaf; child = child->prevOnLine())
-        leaf = child->isLeaf() ? child : toInlineFlowBox(child)->lastLeafChild();
+        leaf = child->isLeaf() ? child : downcast<InlineFlowBox>(*child).lastLeafChild();
     return leaf;
 }
 
@@ -1491,15 +1489,15 @@
 LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosition) const
 {
     LayoutUnit result = 0;
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
         
-        if (curr->isInlineFlowBox())
-            result = std::max(result, toInlineFlowBox(curr)->computeOverAnnotationAdjustment(allowedPosition));
+        if (is<InlineFlowBox>(*child))
+            result = std::max(result, downcast<InlineFlowBox>(*child).computeOverAnnotationAdjustment(allowedPosition));
         
-        if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && curr->renderer().style().rubyPosition() == RubyPositionBefore) {
-            RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+        if (child->renderer().isReplaced() && is<RenderRubyRun>(child->renderer()) && child->renderer().style().rubyPosition() == RubyPositionBefore) {
+            auto& rubyRun = downcast<RenderRubyRun>(child->renderer());
             RenderRubyText* rubyText = rubyRun.rubyText();
             if (!rubyText)
                 continue;
@@ -1508,26 +1506,26 @@
                 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
                 if (topOfFirstRubyTextLine >= 0)
                     continue;
-                topOfFirstRubyTextLine += curr->logicalTop();
+                topOfFirstRubyTextLine += child->logicalTop();
                 result = std::max(result, allowedPosition - topOfFirstRubyTextLine);
             } else {
                 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + (rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logicalHeight());
-                if (bottomOfLastRubyTextLine <= curr->logicalHeight())
+                if (bottomOfLastRubyTextLine <= child->logicalHeight())
                     continue;
-                bottomOfLastRubyTextLine += curr->logicalTop();
+                bottomOfLastRubyTextLine += child->logicalTop();
                 result = std::max(result, bottomOfLastRubyTextLine - allowedPosition);
             }
         }
 
-        if (curr->isInlineTextBox()) {
-            const RenderStyle& childLineStyle = curr->lineStyle();
+        if (is<InlineTextBox>(*child)) {
+            const RenderStyle& childLineStyle = child->lineStyle();
             bool emphasisMarkIsAbove;
-            if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove) && emphasisMarkIsAbove) {
+            if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove) && emphasisMarkIsAbove) {
                 if (!childLineStyle.isFlippedLinesWritingMode()) {
-                    int topOfEmphasisMark = curr->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
+                    int topOfEmphasisMark = child->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
                     result = std::max(result, allowedPosition - topOfEmphasisMark);
                 } else {
-                    int bottomOfEmphasisMark = curr->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
+                    int bottomOfEmphasisMark = child->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
                     result = std::max(result, bottomOfEmphasisMark - allowedPosition);
                 }
             }
@@ -1539,15 +1537,15 @@
 LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPosition) const
 {
     LayoutUnit result = 0;
-    for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
-        if (curr->renderer().isOutOfFlowPositioned())
+    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
+        if (child->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
 
-        if (curr->isInlineFlowBox())
-            result = std::max(result, toInlineFlowBox(curr)->computeUnderAnnotationAdjustment(allowedPosition));
+        if (is<InlineFlowBox>(*child))
+            result = std::max(result, downcast<InlineFlowBox>(*child).computeUnderAnnotationAdjustment(allowedPosition));
 
-        if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && curr->renderer().style().rubyPosition() == RubyPositionAfter) {
-            RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+        if (child->renderer().isReplaced() && is<RenderRubyRun>(child->renderer()) && child->renderer().style().rubyPosition() == RubyPositionAfter) {
+            auto& rubyRun = downcast<RenderRubyRun>(child->renderer());
             RenderRubyText* rubyText = rubyRun.rubyText();
             if (!rubyText)
                 continue;
@@ -1556,27 +1554,27 @@
                 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
                 if (topOfFirstRubyTextLine >= 0)
                     continue;
-                topOfFirstRubyTextLine += curr->logicalTop();
+                topOfFirstRubyTextLine += child->logicalTop();
                 result = std::max(result, allowedPosition - topOfFirstRubyTextLine);
             } else {
                 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + (rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logicalHeight());
-                if (bottomOfLastRubyTextLine <= curr->logicalHeight())
+                if (bottomOfLastRubyTextLine <= child->logicalHeight())
                     continue;
-                bottomOfLastRubyTextLine += curr->logicalTop();
+                bottomOfLastRubyTextLine += child->logicalTop();
                 result = std::max(result, bottomOfLastRubyTextLine - allowedPosition);
             }
         }
 
-        if (curr->isInlineTextBox()) {
-            const RenderStyle& childLineStyle = curr->lineStyle();
+        if (is<InlineTextBox>(*child)) {
+            const RenderStyle& childLineStyle = child->lineStyle();
             bool emphasisMarkIsAbove;
-            toInlineTextBox(curr)->emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove);
+            downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove);
             if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && !emphasisMarkIsAbove) {
                 if (!childLineStyle.isFlippedLinesWritingMode()) {
-                    LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
+                    LayoutUnit bottomOfEmphasisMark = child->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
                     result = std::max(result, bottomOfEmphasisMark - allowedPosition);
                 } else {
-                    LayoutUnit topOfEmphasisMark = curr->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
+                    LayoutUnit topOfEmphasisMark = child->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
                     result = std::max(result, allowedPosition - topOfEmphasisMark);
                 }
             }

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/InlineFlowBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -344,8 +344,6 @@
 #endif
 };
 
-INLINE_BOX_OBJECT_TYPE_CASTS(InlineFlowBox, isInlineFlowBox())
-
 #ifdef NDEBUG
 
 inline void InlineFlowBox::checkConsistency() const
@@ -364,6 +362,8 @@
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INLINE_BOX(InlineFlowBox, isInlineFlowBox())
+
 #ifndef NDEBUG
 // Outside the WebCore namespace for ease of invocation from gdb.
 void showTree(const WebCore::InlineFlowBox*);

Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/InlineTextBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -179,8 +179,8 @@
     unsigned short m_truncation;
 };
 
-INLINE_BOX_OBJECT_TYPE_CASTS(InlineTextBox, isInlineTextBox())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INLINE_BOX(InlineTextBox, isInlineTextBox())
+
 #endif // InlineTextBox_h

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -3270,11 +3270,11 @@
     if (!box->renderer().nonPseudoNode())
         return createLegacyEditingPosition(nonPseudoElement(), start ? caretMinOffset() : caretMaxOffset());
 
-    if (!box->isInlineTextBox())
+    if (!is<InlineTextBox>(*box))
         return createLegacyEditingPosition(box->renderer().nonPseudoNode(), start ? box->renderer().caretMinOffset() : box->renderer().caretMaxOffset());
 
-    InlineTextBox* textBox = toInlineTextBox(box);
-    return createLegacyEditingPosition(box->renderer().nonPseudoNode(), start ? textBox->start() : textBox->start() + textBox->len());
+    auto& textBox = downcast<InlineTextBox>(*box);
+    return createLegacyEditingPosition(textBox.renderer().nonPseudoNode(), start ? textBox.start() : textBox.start() + textBox.len());
 }
 
 VisiblePosition RenderBlockFlow::positionForPointWithInlineChildren(const LayoutPoint& pointInLogicalContents, const RenderRegion* region)

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -338,8 +338,8 @@
     RenderLineBoxList& lineBoxes() { return m_lineBoxes; }
     const RenderLineBoxList& lineBoxes() const { return m_lineBoxes; }
 
-    RootInlineBox* firstRootBox() const { return toRootInlineBox(m_lineBoxes.firstLineBox()); }
-    RootInlineBox* lastRootBox() const { return toRootInlineBox(m_lineBoxes.lastLineBox()); }
+    RootInlineBox* firstRootBox() const { return downcast<RootInlineBox>(m_lineBoxes.firstLineBox()); }
+    RootInlineBox* lastRootBox() const { return downcast<RootInlineBox>(m_lineBoxes.lastLineBox()); }
 
     virtual bool hasLines() const override final;
     virtual void invalidateLineLayoutPath() override final;

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -213,8 +213,7 @@
             // We need to make a new box for this render object.  Once
             // made, we need to place it at the end of the current line.
             InlineBox* newBox = createInlineBoxForRenderer(obj, obj == this);
-            ASSERT_WITH_SECURITY_IMPLICATION(newBox->isInlineFlowBox());
-            parentBox = toInlineFlowBox(newBox);
+            parentBox = downcast<InlineFlowBox>(newBox);
             parentBox->setIsFirstLine(lineInfo.isFirstLine());
             parentBox->setIsHorizontal(isHorizontalWritingMode());
             if (!hasDefaultLineBoxContain)
@@ -314,13 +313,13 @@
         bool visuallyOrdered = r->renderer().style().rtlOrdering() == VisualOrder;
         box->setBidiLevel(r->level());
 
-        if (box->isInlineTextBox()) {
-            InlineTextBox* text = toInlineTextBox(box);
-            text->setStart(r->m_start);
-            text->setLen(r->m_stop - r->m_start);
-            text->setDirOverride(r->dirOverride(visuallyOrdered));
+        if (is<InlineTextBox>(*box)) {
+            auto& textBox = downcast<InlineTextBox>(*box);
+            textBox.setStart(r->m_start);
+            textBox.setLen(r->m_stop - r->m_start);
+            textBox.setDirOverride(r->dirOverride(visuallyOrdered));
             if (r->m_hasHyphen)
-                text->setHasHyphen(true);
+                textBox.setHasHyphen(true);
         }
     }
 
@@ -478,7 +477,7 @@
     }
     
     LayoutUnit hyphenWidth = 0;
-    if (toInlineTextBox(run->box())->hasHyphen())
+    if (downcast<InlineTextBox>(*run->box()).hasHyphen())
         hyphenWidth = measureHyphenWidth(renderer, font, &fallbackFonts);
 
     float measuredWidth = 0;
@@ -528,7 +527,7 @@
     run->box()->setLogicalWidth(measuredWidth + hyphenWidth);
     if (!fallbackFonts.isEmpty()) {
         ASSERT(run->box()->behavesLikeText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->box()), std::make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(downcast<InlineTextBox>(run->box()), std::make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         ASSERT(it->value.first.isEmpty());
         copyToVector(fallbackFonts, it->value.first);
         run->box()->parent()->clearDescendantsHaveSameLineHeightAndBaseline();
@@ -536,11 +535,11 @@
 
     // Include text decoration visual overflow as part of the glyph overflow.
     if (renderer->style().textDecorationsInEffect() != TextDecorationNone)
-        glyphOverflow.extendTo(visualOverflowForDecorations(run->box()->lineStyle(), toInlineTextBox(run->box())));
+        glyphOverflow.extendTo(visualOverflowForDecorations(run->box()->lineStyle(), downcast<InlineTextBox>(run->box())));
 
     if (!glyphOverflow.isEmpty()) {
         ASSERT(run->box()->behavesLikeText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->box()), std::make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(downcast<InlineTextBox>(run->box()), std::make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         it->value.second = glyphOverflow;
         run->box()->clearKnownToHaveNoOverflow();
     }
@@ -586,25 +585,25 @@
         return;
 
     size_t i = 0;
-    for (BidiRun* r = firstRun; r; r = r->next()) {
-        if (!r->box() || r == trailingSpaceRun)
+    for (BidiRun* run = firstRun; run; run = run->next()) {
+        if (!run->box() || run == trailingSpaceRun)
             continue;
         
-        if (r->renderer().isText()) {
+        if (is<RenderText>(run->renderer())) {
             unsigned opportunitiesInRun = expansionOpportunities[i++];
             
             ASSERT(opportunitiesInRun <= expansionOpportunityCount);
             
             // Only justify text if whitespace is collapsed.
-            if (r->renderer().style().collapseWhiteSpace()) {
-                InlineTextBox* textBox = toInlineTextBox(r->box());
+            if (run->renderer().style().collapseWhiteSpace()) {
+                InlineTextBox& textBox = downcast<InlineTextBox>(*run->box());
                 float expansion = (availableLogicalWidth - totalLogicalWidth) * opportunitiesInRun / expansionOpportunityCount;
-                textBox->setExpansion(expansion);
+                textBox.setExpansion(expansion);
                 totalLogicalWidth += expansion;
             }
             expansionOpportunityCount -= opportunitiesInRun;
-        } else if (r->renderer().isRubyRun())
-            updateRubyForJustifiedText(toRenderRubyRun(r->renderer()), *r, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, i);
+        } else if (is<RenderRubyRun>(run->renderer()))
+            updateRubyForJustifiedText(downcast<RenderRubyRun>(run->renderer()), *run, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, i);
 
         if (!expansionOpportunityCount)
             break;
@@ -709,39 +708,40 @@
     Vector<unsigned, 16> expansionOpportunities;
     RenderObject* previousObject = nullptr;
 
-    BidiRun* r = firstRun;
-    for (; r; r = r->next()) {
-        if (!r->box() || r->renderer().isOutOfFlowPositioned() || r->box()->isLineBreak())
+    BidiRun* run = firstRun;
+    for (; run; run = run->next()) {
+        if (!run->box() || run->renderer().isOutOfFlowPositioned() || run->box()->isLineBreak()) {
             continue; // Positioned objects are only participating to figure out their
                       // correct static x position.  They have no effect on the width.
                       // Similarly, line break boxes have no effect on the width.
-        if (is<RenderText>(r->renderer())) {
-            RenderText& renderText = downcast<RenderText>(r->renderer());
-            if (textAlign == JUSTIFY && r != trailingSpaceRun) {
+        }
+        if (is<RenderText>(run->renderer())) {
+            auto& renderText = downcast<RenderText>(run->renderer());
+            if (textAlign == JUSTIFY && run != trailingSpaceRun) {
                 if (!isAfterExpansion)
-                    toInlineTextBox(r->box())->setCanHaveLeadingExpansion(true);
-                unsigned opportunitiesInRun = Font::expansionOpportunityCount(renderText.stringView(r->m_start, r->m_stop), r->box()->direction(), isAfterExpansion);
+                    downcast<InlineTextBox>(*run->box()).setCanHaveLeadingExpansion(true);
+                unsigned opportunitiesInRun = Font::expansionOpportunityCount(renderText.stringView(run->m_start, run->m_stop), run->box()->direction(), isAfterExpansion);
                 expansionOpportunities.append(opportunitiesInRun);
                 expansionOpportunityCount += opportunitiesInRun;
             }
 
             if (int length = renderText.textLength()) {
-                if (!r->m_start && needsWordSpacing && isSpaceOrNewline(renderText.characterAt(r->m_start)))
+                if (!run->m_start && needsWordSpacing && isSpaceOrNewline(renderText.characterAt(run->m_start)))
                     totalLogicalWidth += lineStyle(*renderText.parent(), lineInfo).font().wordSpacing();
-                needsWordSpacing = !isSpaceOrNewline(renderText.characterAt(r->m_stop - 1)) && r->m_stop == length;
+                needsWordSpacing = !isSpaceOrNewline(renderText.characterAt(run->m_stop - 1)) && run->m_stop == length;
             }
 
-            setLogicalWidthForTextRun(lineBox, r, &renderText, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
+            setLogicalWidthForTextRun(lineBox, run, &renderText, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
         } else {
             bool encounteredJustifiedRuby = false;
-            if (r->renderer().isRubyRun() && textAlign == JUSTIFY && r != trailingSpaceRun && toRenderRubyRun(r->renderer()).rubyBase()) {
-                auto* rubyBase = toRenderRubyRun(r->renderer()).rubyBase();
-                if (rubyBase->firstRootBox() && !rubyBase->firstRootBox()->nextRootBox() && r->renderer().style().collapseWhiteSpace()) {
+            if (is<RenderRubyRun>(run->renderer()) && textAlign == JUSTIFY && run != trailingSpaceRun && toRenderRubyRun(run->renderer()).rubyBase()) {
+                auto* rubyBase = downcast<RenderRubyRun>(run->renderer()).rubyBase();
+                if (rubyBase->firstRootBox() && !rubyBase->firstRootBox()->nextRootBox() && run->renderer().style().collapseWhiteSpace()) {
                     for (auto* leafChild = rubyBase->firstRootBox()->firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
-                        if (!leafChild->isInlineTextBox())
+                        if (!is<InlineTextBox>(*leafChild))
                             continue;
                         if (!isAfterExpansion)
-                            toInlineTextBox(leafChild)->setCanHaveLeadingExpansion(true);
+                            downcast<InlineTextBox>(*leafChild).setCanHaveLeadingExpansion(true);
                         encounteredJustifiedRuby = true;
                         auto& renderText = downcast<RenderText>(leafChild->renderer());
                         unsigned opportunitiesInRun = Font::expansionOpportunityCount(renderText.stringView(), leafChild->direction(), isAfterExpansion);
@@ -754,17 +754,17 @@
             if (!encounteredJustifiedRuby)
                 isAfterExpansion = false;
 
-            if (!r->renderer().isRenderInline()) {
-                RenderBox& renderBox = toRenderBox(r->renderer());
-                if (renderBox.isRubyRun())
-                    setMarginsForRubyRun(r, toRenderRubyRun(renderBox), previousObject, lineInfo);
-                r->box()->setLogicalWidth(logicalWidthForChild(renderBox));
+            if (!is<RenderInline>(run->renderer())) {
+                auto& renderBox = downcast<RenderBox>(run->renderer());
+                if (is<RenderRubyRun>(renderBox))
+                    setMarginsForRubyRun(run, downcast<RenderRubyRun>(renderBox), previousObject, lineInfo);
+                run->box()->setLogicalWidth(logicalWidthForChild(renderBox));
                 totalLogicalWidth += marginStartForChild(renderBox) + marginEndForChild(renderBox);
             }
         }
 
-        totalLogicalWidth += r->box()->logicalWidth();
-        previousObject = &r->renderer();
+        totalLogicalWidth += run->box()->logicalWidth();
+        previousObject = &run->renderer();
     }
 
     if (isAfterExpansion && !expansionOpportunities.isEmpty()) {
@@ -776,7 +776,7 @@
 
     computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth);
 
-    return r;
+    return run;
 }
 
 void RenderBlockFlow::computeBlockDirectionPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap,
@@ -785,26 +785,26 @@
     setLogicalHeight(lineBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, verticalPositionCache));
 
     // Now make sure we place replaced render objects correctly.
-    for (BidiRun* r = firstRun; r; r = r->next()) {
-        ASSERT(r->box());
-        if (!r->box())
+    for (BidiRun* run = firstRun; run; run = run->next()) {
+        ASSERT(run->box());
+        if (!run->box())
             continue; // Skip runs with no line boxes.
 
-        InlineBox& box = *r->box();
+        InlineBox& box = *run->box();
 
         // Align positioned boxes with the top of the line box.  This is
         // a reasonable approximation of an appropriate y position.
-        if (r->renderer().isOutOfFlowPositioned())
+        if (run->renderer().isOutOfFlowPositioned())
             box.setLogicalTop(logicalHeight());
 
         // Position is used to properly position both replaced elements and
         // to update the static normal flow x/y of positioned elements.
-        if (is<RenderText>(r->renderer()))
-            downcast<RenderText>(r->renderer()).positionLineBox(toInlineTextBox(box));
-        else if (is<RenderBox>(r->renderer()))
-            downcast<RenderBox>(r->renderer()).positionLineBox(toInlineElementBox(box));
-        else if (is<RenderLineBreak>(r->renderer()))
-            downcast<RenderLineBreak>(r->renderer()).replaceInlineBoxWrapper(toInlineElementBox(box));
+        if (is<RenderText>(run->renderer()))
+            downcast<RenderText>(run->renderer()).positionLineBox(downcast<InlineTextBox>(box));
+        else if (is<RenderBox>(run->renderer()))
+            downcast<RenderBox>(run->renderer()).positionLineBox(downcast<InlineElementBox>(box));
+        else if (is<RenderLineBreak>(run->renderer()))
+            downcast<RenderLineBreak>(run->renderer()).replaceInlineBoxWrapper(downcast<InlineElementBox>(box));
     }
     // Positioned objects and zero-length text nodes destroy their boxes in
     // position(), which unnecessarily dirties the line.
@@ -984,7 +984,7 @@
     lineBox->setBidiLevel(bidiLevel);
     lineBox->setEndsWithBreak(lineInfo.previousLineBrokeCleanly());
     
-    bool isSVGRootInlineBox = lineBox->isSVGRootInlineBox();
+    bool isSVGRootInlineBox = is<SVGRootInlineBox>(*lineBox);
     
     GlyphOverflowAndFallbackFontsMap textBoxDataMap;
     
@@ -1002,7 +1002,7 @@
     // text selection in RTL boxes would not work as expected.
     if (isSVGRootInlineBox) {
         ASSERT_WITH_SECURITY_IMPLICATION(isSVGText());
-        toSVGRootInlineBox(lineBox)->computePerCharacterLayoutInformation();
+        downcast<SVGRootInlineBox>(*lineBox).computePerCharacterLayoutInformation();
     }
     
     // Compute our overflow now.

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -431,9 +431,9 @@
     if (!inlineBox)
         return LayoutRect();
 
-    InlineTextBox* box = toInlineTextBox(inlineBox);
-    float left = box->positionForOffset(caretOffset);
-    return box->root().computeCaretRect(left, caretWidth, extraWidthToEndOfLine);
+    auto& box = downcast<InlineTextBox>(*inlineBox);
+    float left = box.positionForOffset(caretOffset);
+    return box.root().computeCaretRect(left, caretWidth, extraWidthToEndOfLine);
 }
 
 ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len, float xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const

Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/RootInlineBox.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -95,12 +95,9 @@
 bool RootInlineBox::isHyphenated() const
 {
     for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) {
-        if (box->isInlineTextBox()) {
-            if (toInlineTextBox(box)->hasHyphen())
-                return true;
-        }
+        if (is<InlineTextBox>(*box) && downcast<InlineTextBox>(*box).hasHyphen())
+            return true;
     }
-
     return false;
 }
 
@@ -830,10 +827,10 @@
 
     Vector<const SimpleFontData*>* usedFonts = nullptr;
     GlyphOverflow* glyphOverflow = nullptr;
-    if (box.isInlineTextBox()) {
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toInlineTextBox(&box));
-        usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first;
-        glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second;
+    if (is<InlineTextBox>(box)) {
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(&downcast<InlineTextBox>(box));
+        usedFonts = it == textBoxDataMap.end() ? nullptr : &it->value.first;
+        glyphOverflow = it == textBoxDataMap.end() ? nullptr : &it->value.second;
     }
         
     bool includeLeading = includeLeadingForBox(box);
@@ -1017,7 +1014,7 @@
     if (box.renderer().isReplaced() || (box.renderer().isTextOrLineBreak() && !box.behavesLikeText()))
         return false;
     
-    if (!box.behavesLikeText() && box.isInlineFlowBox() && !toInlineFlowBox(&box)->hasTextChildren())
+    if (!box.behavesLikeText() && is<InlineFlowBox>(box) && !downcast<InlineFlowBox>(box).hasTextChildren())
         return false;
 
     // For now map "glyphs" to "font" in vertical text mode until the bounds returned by glyphs aren't garbage.
@@ -1030,7 +1027,7 @@
     if (box.renderer().isReplaced() || (box.renderer().isTextOrLineBreak() && !box.behavesLikeText()))
         return false;
     
-    if (!box.behavesLikeText() && box.isInlineFlowBox() && !toInlineFlowBox(&box)->hasTextChildren())
+    if (!box.behavesLikeText() && is<InlineFlowBox>(box) && !downcast<InlineFlowBox>(box).hasTextChildren())
         return false;
 
     // FIXME: We can't fit to glyphs yet for vertical text, since the bounds returned are garbage.
@@ -1043,7 +1040,7 @@
     if (box.renderer().isReplaced() || (box.renderer().isTextOrLineBreak() && !box.behavesLikeText()))
         return false;
     
-    if (!box.behavesLikeText() && box.isInlineFlowBox() && !toInlineFlowBox(&box)->hasTextChildren())
+    if (!box.behavesLikeText() && is<InlineFlowBox>(box) && !downcast<InlineFlowBox>(box).hasTextChildren())
         return false;
 
     LineBoxContain lineBoxContain = renderer().style().lineBoxContain();

Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/RootInlineBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -224,18 +224,18 @@
     std::unique_ptr<Vector<RenderBox*>> m_floats;
 };
 
-INLINE_BOX_OBJECT_TYPE_CASTS(RootInlineBox, isRootInlineBox())
-
 inline RootInlineBox* RootInlineBox::nextRootBox() const
 {
-    return toRootInlineBox(m_nextLineBox);
+    return downcast<RootInlineBox>(m_nextLineBox);
 }
 
 inline RootInlineBox* RootInlineBox::prevRootBox() const
 {
-    return toRootInlineBox(m_prevLineBox);
+    return downcast<RootInlineBox>(m_prevLineBox);
 }
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INLINE_BOX(RootInlineBox, isRootInlineBox())
+
 #endif // RootInlineBox_h

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -118,22 +118,22 @@
 
 LayoutRect RenderSVGInlineText::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit*)
 {
-    if (!box || !box->isInlineTextBox())
+    if (!is<InlineTextBox>(box))
         return LayoutRect();
 
-    InlineTextBox* textBox = toInlineTextBox(box);
-    if (static_cast<unsigned>(caretOffset) < textBox->start() || static_cast<unsigned>(caretOffset) > textBox->start() + textBox->len())
+    auto& textBox = downcast<InlineTextBox>(*box);
+    if (static_cast<unsigned>(caretOffset) < textBox.start() || static_cast<unsigned>(caretOffset) > textBox.start() + textBox.len())
         return LayoutRect();
 
     // Use the edge of the selection rect to determine the caret rect.
-    if (static_cast<unsigned>(caretOffset) < textBox->start() + textBox->len()) {
-        LayoutRect rect = textBox->localSelectionRect(caretOffset, caretOffset + 1);
-        LayoutUnit x = box->isLeftToRightDirection() ? rect.x() : rect.maxX();
+    if (static_cast<unsigned>(caretOffset) < textBox.start() + textBox.len()) {
+        LayoutRect rect = textBox.localSelectionRect(caretOffset, caretOffset + 1);
+        LayoutUnit x = textBox.isLeftToRightDirection() ? rect.x() : rect.maxX();
         return LayoutRect(x, rect.y(), caretWidth, rect.height());
     }
 
-    LayoutRect rect = textBox->localSelectionRect(caretOffset - 1, caretOffset);
-    LayoutUnit x = box->isLeftToRightDirection() ? rect.maxX() : rect.x();
+    LayoutRect rect = textBox.localSelectionRect(caretOffset - 1, caretOffset);
+    LayoutUnit x = textBox.isLeftToRightDirection() ? rect.maxX() : rect.x();
     return LayoutRect(x, rect.y(), caretWidth, rect.height());
 }
 
@@ -182,16 +182,16 @@
 
     float closestDistance = std::numeric_limits<float>::max();
     float closestDistancePosition = 0;
-    const SVGTextFragment* closestDistanceFragment = 0;
-    SVGInlineTextBox* closestDistanceBox = 0;
+    const SVGTextFragment* closestDistanceFragment = nullptr;
+    SVGInlineTextBox* closestDistanceBox = nullptr;
 
     AffineTransform fragmentTransform;
     for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
-        if (!box->isSVGInlineTextBox())
+        if (!is<SVGInlineTextBox>(*box))
             continue;
 
-        SVGInlineTextBox* textBox = toSVGInlineTextBox(box);
-        Vector<SVGTextFragment>& fragments = textBox->textFragments();
+        auto& textBox = downcast<SVGInlineTextBox>(*box);
+        Vector<SVGTextFragment>& fragments = textBox.textFragments();
 
         unsigned textFragmentsSize = fragments.size();
         for (unsigned i = 0; i < textFragmentsSize; ++i) {
@@ -206,7 +206,7 @@
 
             if (distance < closestDistance) {
                 closestDistance = distance;
-                closestDistanceBox = textBox;
+                closestDistanceBox = &textBox;
                 closestDistanceFragment = &fragment;
                 closestDistancePosition = fragmentRect.x();
             }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -472,11 +472,10 @@
     if (!rootBox)
         return createVisiblePosition(0, DOWNSTREAM);
 
-    ASSERT_WITH_SECURITY_IMPLICATION(rootBox->isSVGRootInlineBox());
     ASSERT(!rootBox->nextRootBox());
     ASSERT(childrenInline());
 
-    InlineBox* closestBox = toSVGRootInlineBox(rootBox)->closestLeafChildForPosition(pointInContents);
+    InlineBox* closestBox = downcast<SVGRootInlineBox>(*rootBox).closestLeafChildForPosition(pointInContents);
     if (!closestBox)
         return createVisiblePosition(0, DOWNSTREAM);
 

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -38,10 +38,10 @@
 
     PaintInfo childPaintInfo(paintInfo);
     for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
-        if (child->isSVGInlineTextBox())
-            toSVGInlineTextBox(child)->paintSelectionBackground(childPaintInfo);
-        else if (child->isSVGInlineFlowBox())
-            toSVGInlineFlowBox(child)->paintSelectionBackground(childPaintInfo);
+        if (is<SVGInlineTextBox>(*child))
+            downcast<SVGInlineTextBox>(*child).paintSelectionBackground(childPaintInfo);
+        else if (is<SVGInlineFlowBox>(*child))
+            downcast<SVGInlineFlowBox>(*child).paintSelectionBackground(childPaintInfo);
     }
 }
 
@@ -53,8 +53,8 @@
     SVGRenderingContext renderingContext(renderer(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
     if (renderingContext.isRenderingPrepared()) {
         for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
-            if (child->isSVGInlineTextBox())
-                computeTextMatchMarkerRectForRenderer(&(toSVGInlineTextBox(child)->renderer()));
+            if (is<SVGInlineTextBox>(*child))
+                computeTextMatchMarkerRectForRenderer(&downcast<SVGInlineTextBox>(*child).renderer());
 
             child->paint(paintInfo, paintOffset, 0, 0);
         }
@@ -95,13 +95,13 @@
 
         FloatRect markerRect;
         for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
-            if (!box->isSVGInlineTextBox())
+            if (!is<SVGInlineTextBox>(*box))
                 continue;
 
-            SVGInlineTextBox* textBox = toSVGInlineTextBox(box);
+            auto& textBox = downcast<SVGInlineTextBox>(*box);
 
-            int markerStartPosition = std::max<int>(marker->startOffset() - textBox->start(), 0);
-            int markerEndPosition = std::min<int>(marker->endOffset() - textBox->start(), textBox->len());
+            int markerStartPosition = std::max<int>(marker->startOffset() - textBox.start(), 0);
+            int markerEndPosition = std::min<int>(marker->endOffset() - textBox.start(), textBox.len());
 
             if (markerStartPosition >= markerEndPosition)
                 continue;
@@ -109,17 +109,17 @@
             int fragmentStartPosition = 0;
             int fragmentEndPosition = 0;
 
-            const Vector<SVGTextFragment>& fragments = textBox->textFragments();
+            const Vector<SVGTextFragment>& fragments = textBox.textFragments();
             unsigned textFragmentsSize = fragments.size();
             for (unsigned i = 0; i < textFragmentsSize; ++i) {
                 const SVGTextFragment& fragment = fragments.at(i);
 
                 fragmentStartPosition = markerStartPosition;
                 fragmentEndPosition = markerEndPosition;
-                if (!textBox->mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition))
+                if (!textBox.mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition))
                     continue;
 
-                FloatRect fragmentRect = textBox->selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style);
+                FloatRect fragmentRect = textBox.selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style);
                 fragment.buildFragmentTransform(fragmentTransform);
                 if (!fragmentTransform.isIdentity())
                     fragmentRect = fragmentTransform.mapRect(fragmentRect);

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -52,8 +52,8 @@
     float m_logicalHeight;
 };
 
-INLINE_BOX_OBJECT_TYPE_CASTS(SVGInlineFlowBox, isSVGInlineFlowBox())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INLINE_BOX(SVGInlineFlowBox, isSVGInlineFlowBox())
+
 #endif // SVGInlineFlowBox_h

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -92,8 +92,8 @@
     Vector<SVGTextFragment> m_textFragments;
 };
 
-INLINE_BOX_OBJECT_TYPE_CASTS(SVGInlineTextBox, isSVGInlineTextBox())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INLINE_BOX(SVGInlineTextBox, isSVGInlineTextBox())
+
 #endif // SVGInlineTextBox_h

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -364,7 +364,7 @@
 
 static void writeRenderSVGTextBox(TextStream& ts, const RenderSVGText& text)
 {
-    SVGRootInlineBox* box = toSVGRootInlineBox(text.firstRootBox());
+    auto* box = downcast<SVGRootInlineBox>(text.firstRootBox());
     if (!box)
         return;
 
@@ -434,10 +434,10 @@
 static inline void writeSVGInlineTextBoxes(TextStream& ts, const RenderText& text, int indent)
 {
     for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) {
-        if (!box->isSVGInlineTextBox())
+        if (!is<SVGInlineTextBox>(*box))
             continue;
 
-        writeSVGInlineTextBox(ts, toSVGInlineTextBox(box), indent);
+        writeSVGInlineTextBox(ts, downcast<SVGInlineTextBox>(box), indent);
     }
 }
 

Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -56,18 +56,18 @@
     PaintInfo childPaintInfo(paintInfo);
     if (hasSelection) {
         for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
-            if (child->isSVGInlineTextBox())
-                toSVGInlineTextBox(child)->paintSelectionBackground(childPaintInfo);
-            else if (child->isSVGInlineFlowBox())
-                toSVGInlineFlowBox(child)->paintSelectionBackground(childPaintInfo);
+            if (is<SVGInlineTextBox>(*child))
+                downcast<SVGInlineTextBox>(*child).paintSelectionBackground(childPaintInfo);
+            else if (is<SVGInlineFlowBox>(*child))
+                downcast<SVGInlineFlowBox>(*child).paintSelectionBackground(childPaintInfo);
         }
     }
 
     SVGRenderingContext renderingContext(renderSVGText(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
     if (renderingContext.isRenderingPrepared()) {
         for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
-            if (child->isSVGInlineTextBox())
-                SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer(&toSVGInlineTextBox(child)->renderer());
+            if (is<SVGInlineTextBox>(*child))
+                SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer(&downcast<SVGInlineTextBox>(*child).renderer());
 
             child->paint(paintInfo, paintOffset, 0, 0);
         }
@@ -103,31 +103,27 @@
 void SVGRootInlineBox::layoutCharactersInTextBoxes(InlineFlowBox* start, SVGTextLayoutEngine& characterLayout)
 {
     for (InlineBox* child = start->firstChild(); child; child = child->nextOnLine()) {
-        if (child->isSVGInlineTextBox()) {
-            ASSERT(child->renderer().isSVGInlineText());
-
-            SVGInlineTextBox* textBox = toSVGInlineTextBox(child);
-            characterLayout.layoutInlineTextBox(textBox);
+        if (is<SVGInlineTextBox>(*child)) {
+            ASSERT(is<RenderSVGInlineText>(child->renderer()));
+            characterLayout.layoutInlineTextBox(downcast<SVGInlineTextBox>(child));
         } else {
             // Skip generated content.
             Node* node = child->renderer().node();
             if (!node)
                 continue;
 
-            ASSERT_WITH_SECURITY_IMPLICATION(child->isInlineFlowBox());
-
-            SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child);
+            auto& flowBox = downcast<SVGInlineFlowBox>(*child);
             bool isTextPath = node->hasTagName(SVGNames::textPathTag);
             if (isTextPath) {
                 // Build text chunks for all <textPath> children, using the line layout algorithm.
                 // This is needeed as text-anchor is just an additional startOffset for text paths.
                 SVGTextLayoutEngine lineLayout(characterLayout.layoutAttributes());
-                layoutCharactersInTextBoxes(flowBox, lineLayout);
+                layoutCharactersInTextBoxes(&flowBox, lineLayout);
 
                 characterLayout.beginTextPathLayout(&child->renderer(), lineLayout);
             }
 
-            layoutCharactersInTextBoxes(flowBox, characterLayout);
+            layoutCharactersInTextBoxes(&flowBox, characterLayout);
 
             if (isTextPath)
                 characterLayout.endTextPathLayout();
@@ -139,30 +135,28 @@
 {
     for (InlineBox* child = start->firstChild(); child; child = child->nextOnLine()) {
         FloatRect boxRect;
-        if (child->isSVGInlineTextBox()) {
-            ASSERT(child->renderer().isSVGInlineText());
+        if (is<SVGInlineTextBox>(*child)) {
+            ASSERT(is<RenderSVGInlineText>(child->renderer()));
 
-            SVGInlineTextBox* textBox = toSVGInlineTextBox(child);
-            boxRect = textBox->calculateBoundaries();
-            textBox->setX(boxRect.x());
-            textBox->setY(boxRect.y());
-            textBox->setLogicalWidth(boxRect.width());
-            textBox->setLogicalHeight(boxRect.height());
+            auto& textBox = downcast<SVGInlineTextBox>(*child);
+            boxRect = textBox.calculateBoundaries();
+            textBox.setX(boxRect.x());
+            textBox.setY(boxRect.y());
+            textBox.setLogicalWidth(boxRect.width());
+            textBox.setLogicalHeight(boxRect.height());
         } else {
             // Skip generated content.
             if (!child->renderer().node())
                 continue;
 
-            ASSERT_WITH_SECURITY_IMPLICATION(child->isInlineFlowBox());
+            auto& flowBox = downcast<SVGInlineFlowBox>(*child);
+            layoutChildBoxes(&flowBox);
 
-            SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child);
-            layoutChildBoxes(flowBox);
-
-            boxRect = flowBox->calculateBoundaries();
-            flowBox->setX(boxRect.x());
-            flowBox->setY(boxRect.y());
-            flowBox->setLogicalWidth(boxRect.width());
-            flowBox->setLogicalHeight(boxRect.height());
+            boxRect = flowBox.calculateBoundaries();
+            flowBox.setX(boxRect.x());
+            flowBox.setY(boxRect.y());
+            flowBox.setLogicalWidth(boxRect.width());
+            flowBox.setLogicalHeight(boxRect.height());
         }
         if (childRect)
             childRect->unite(boxRect);
@@ -273,7 +267,7 @@
         if (first == last || first == --last)
             return;
 
-        if (!(*last)->isSVGInlineTextBox() || !(*first)->isSVGInlineTextBox()) {
+        if (!is<SVGInlineTextBox>(**last) || !is<SVGInlineTextBox>(**first)) {
             InlineBox* temp = *first;
             *first = *last;
             *last = temp;
@@ -281,18 +275,18 @@
             continue;
         }
 
-        SVGInlineTextBox* firstTextBox = toSVGInlineTextBox(*first);
-        SVGInlineTextBox* lastTextBox = toSVGInlineTextBox(*last);
+        auto& firstTextBox = downcast<SVGInlineTextBox>(**first);
+        auto& lastTextBox = downcast<SVGInlineTextBox>(**last);
 
         // Reordering is only necessary for BiDi text that is _absolutely_ positioned.
-        if (firstTextBox->len() == 1 && firstTextBox->len() == lastTextBox->len()) {
-            RenderSVGInlineText& firstContext = firstTextBox->renderer();
-            RenderSVGInlineText& lastContext = lastTextBox->renderer();
+        if (firstTextBox.len() == 1 && firstTextBox.len() == lastTextBox.len()) {
+            RenderSVGInlineText& firstContext = firstTextBox.renderer();
+            RenderSVGInlineText& lastContext = lastTextBox.renderer();
 
-            SVGTextLayoutAttributes* firstAttributes = 0;
-            SVGTextLayoutAttributes* lastAttributes = 0;
+            SVGTextLayoutAttributes* firstAttributes = nullptr;
+            SVGTextLayoutAttributes* lastAttributes = nullptr;
             findFirstAndLastAttributesInVector(attributes, &firstContext, &lastContext, firstAttributes, lastAttributes);
-            swapItemsInLayoutAttributes(firstAttributes, lastAttributes, firstTextBox->start(), lastTextBox->start());
+            swapItemsInLayoutAttributes(firstAttributes, lastAttributes, firstTextBox.start(), lastTextBox.start());
         }
 
         InlineBox* temp = *first;

Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h	2014-10-16 00:05:37 UTC (rev 174746)
@@ -57,8 +57,8 @@
     float m_logicalHeight;
 };
 
-INLINE_BOX_OBJECT_TYPE_CASTS(SVGRootInlineBox, isSVGRootInlineBox())
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INLINE_BOX(SVGRootInlineBox, isSVGRootInlineBox())
+
 #endif // SVGRootInlineBox_h

Modified: trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp (174745 => 174746)


--- trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp	2014-10-15 22:36:08 UTC (rev 174745)
+++ trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp	2014-10-16 00:05:37 UTC (rev 174746)
@@ -89,17 +89,17 @@
         return;
 
     for (InlineBox* child = flowBox->firstChild(); child; child = child->nextOnLine()) {
-        if (child->isInlineFlowBox()) {
+        if (is<InlineFlowBox>(*child)) {
             // Skip generated content.
             if (!child->renderer().node())
                 continue;
 
-            collectTextBoxesInFlowBox(toInlineFlowBox(child));
+            collectTextBoxesInFlowBox(downcast<InlineFlowBox>(child));
             continue;
         }
 
-        if (child->isSVGInlineTextBox())
-            m_textBoxes.append(toSVGInlineTextBox(child));
+        if (is<SVGInlineTextBox>(*child))
+            m_textBoxes.append(downcast<SVGInlineTextBox>(child));
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to