Title: [174587] trunk/Source
Revision
174587
Author
cdu...@apple.com
Date
2014-10-10 08:49:24 -0700 (Fri, 10 Oct 2014)

Log Message

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

Reviewed by Mihnea Ovidenie.

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

Source/WebCore:

No new tests, no behavior change.

* accessibility/AXObjectCache.cpp:
(WebCore::createFromRenderer):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::renderBoxModelObject):
(WebCore::isInlineWithContinuation):
(WebCore::firstChildConsideringContinuation):
(WebCore::lastChildHasContinuation):
(WebCore::AccessibilityRenderObject::nextSibling):
(WebCore::AccessibilityRenderObject::widget):
(WebCore::AccessibilityRenderObject::renderObjectIsObservable):
(WebCore::AccessibilityRenderObject::observableObject):
(WebCore::msaaRoleForRenderer):
* accessibility/AccessibilityRenderObject.h:
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::isDataTable):
* dom/Node.cpp:
(WebCore::Node::renderBox):
(WebCore::Node::renderBoxModelObject):
* inspector/InspectorOverlay.cpp:
(WebCore::buildObjectForElementInfo):
* page/FrameView.cpp:
(WebCore::FrameView::scrollContentsFastPath):
* page/PrintContext.cpp:
(WebCore::enclosingBoxModelObject):
* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::freezeAtTime):
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::startAnimation):
(WebCore::ImplicitAnimation::pauseAnimation):
(WebCore::ImplicitAnimation::endAnimation):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::startAnimation):
(WebCore::KeyframeAnimation::pauseAnimation):
(WebCore::KeyframeAnimation::endAnimation):
* page/ios/FrameIOS.mm:
(WebCore::Frame::overflowScrollPositionChangedForNode):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects):
* rendering/InlineBox.h:
(WebCore::InlineBox::boxModelObject):
* rendering/InlineElementBox.h:
(WebCore::InlineElementBox::renderer):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::placeBoxesInBlockDirection):
* rendering/InlineFlowBox.h:
(WebCore::InlineFlowBox::renderer):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::baselinePosition):
(WebCore::InlineTextBox::lineHeight):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::addChildToContinuation):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeReplacedLogicalWidthUsing):
(WebCore::RenderBox::computeReplacedLogicalHeightUsing):
(WebCore::RenderBox::computePositionedLogicalWidth):
(WebCore::RenderBox::computePositionedLogicalHeight):
(WebCore::RenderBox::computePositionedLogicalWidthReplaced):
(WebCore::RenderBox::computePositionedLogicalHeightReplaced):
* rendering/RenderBoxModelObject.h:
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::adjustedPositionRelativeToOffsetParent):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::splitInlines):
(WebCore::RenderInline::addChildToContinuation):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPosition):
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason):
(WebCore::RenderLayerCompositor::computeStickyViewportConstraints):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::destroy):
(WebCore::RenderObject::offsetParent):
* rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::base):

Source/WebKit/mac:

* Plugins/WebBaseNetscapePluginView.mm:
(-[WebBaseNetscapePluginView invalidatePluginContentRect:]):
* WebView/WebRenderLayer.mm:
(-[WebRenderLayer initWithWebFrame:]):

Source/WebKit2:

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::renderer):
(WebKit::PluginView::invalidateRect):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174586 => 174587)


--- trunk/Source/WebCore/ChangeLog	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/ChangeLog	2014-10-10 15:49:24 UTC (rev 174587)
@@ -1,3 +1,93 @@
+2014-10-10  Chris Dumez  <cdu...@apple.com>
+
+        Use is<>() / downcast<>() for RenderBoxModelObject
+        https://bugs.webkit.org/show_bug.cgi?id=137587
+
+        Reviewed by Mihnea Ovidenie.
+
+        Use is<>() / downcast<>() for RenderBoxModelObject and clean up the
+        surrounding code.
+
+        No new tests, no behavior change.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::createFromRenderer):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::renderBoxModelObject):
+        (WebCore::isInlineWithContinuation):
+        (WebCore::firstChildConsideringContinuation):
+        (WebCore::lastChildHasContinuation):
+        (WebCore::AccessibilityRenderObject::nextSibling):
+        (WebCore::AccessibilityRenderObject::widget):
+        (WebCore::AccessibilityRenderObject::renderObjectIsObservable):
+        (WebCore::AccessibilityRenderObject::observableObject):
+        (WebCore::msaaRoleForRenderer):
+        * accessibility/AccessibilityRenderObject.h:
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::isDataTable):
+        * dom/Node.cpp:
+        (WebCore::Node::renderBox):
+        (WebCore::Node::renderBoxModelObject):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::buildObjectForElementInfo):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollContentsFastPath):
+        * page/PrintContext.cpp:
+        (WebCore::enclosingBoxModelObject):
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::freezeAtTime):
+        * page/animation/ImplicitAnimation.cpp:
+        (WebCore::ImplicitAnimation::startAnimation):
+        (WebCore::ImplicitAnimation::pauseAnimation):
+        (WebCore::ImplicitAnimation::endAnimation):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::startAnimation):
+        (WebCore::KeyframeAnimation::pauseAnimation):
+        (WebCore::KeyframeAnimation::endAnimation):
+        * page/ios/FrameIOS.mm:
+        (WebCore::Frame::overflowScrollPositionChangedForNode):
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects):
+        * rendering/InlineBox.h:
+        (WebCore::InlineBox::boxModelObject):
+        * rendering/InlineElementBox.h:
+        (WebCore::InlineElementBox::renderer):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
+        * rendering/InlineFlowBox.h:
+        (WebCore::InlineFlowBox::renderer):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::baselinePosition):
+        (WebCore::InlineTextBox::lineHeight):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::addChildToContinuation):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeReplacedLogicalWidthUsing):
+        (WebCore::RenderBox::computeReplacedLogicalHeightUsing):
+        (WebCore::RenderBox::computePositionedLogicalWidth):
+        (WebCore::RenderBox::computePositionedLogicalHeight):
+        (WebCore::RenderBox::computePositionedLogicalWidthReplaced):
+        (WebCore::RenderBox::computePositionedLogicalHeightReplaced):
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::adjustedPositionRelativeToOffsetParent):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::splitInlines):
+        (WebCore::RenderInline::addChildToContinuation):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPosition):
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason):
+        (WebCore::RenderLayerCompositor::computeStickyViewportConstraints):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::destroy):
+        (WebCore::RenderObject::offsetParent):
+        * rendering/mathml/RenderMathMLScripts.cpp:
+        (WebCore::RenderMathMLScripts::base):
+
 2014-10-10  Zan Dobersek  <zdober...@igalia.com>
 
         Remove CrossThreadTask

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (174586 => 174587)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -73,6 +73,7 @@
 #include "RenderMenuList.h"
 #include "RenderMeter.h"
 #include "RenderProgress.h"
+#include "RenderSVGRoot.h"
 #include "RenderSlider.h"
 #include "RenderTable.h"
 #include "RenderTableCell.h"
@@ -290,40 +291,40 @@
         return AccessibilityMediaControl::create(renderer);
 #endif
 
-    if (renderer->isSVGRoot())
+    if (is<RenderSVGRoot>(*renderer))
         return AccessibilitySVGRoot::create(renderer);
     
     // Search field buttons
     if (is<Element>(node) && downcast<Element>(*node).isSearchFieldCancelButtonElement())
         return AccessibilitySearchFieldCancelButton::create(renderer);
     
-    if (renderer->isBoxModelObject()) {
-        RenderBoxModelObject* cssBox = toRenderBoxModelObject(renderer);
-        if (cssBox->isListBox())
-            return AccessibilityListBox::create(toRenderListBox(cssBox));
-        if (cssBox->isMenuList())
-            return AccessibilityMenuList::create(toRenderMenuList(cssBox));
+    if (is<RenderBoxModelObject>(*renderer)) {
+        RenderBoxModelObject& cssBox = downcast<RenderBoxModelObject>(*renderer);
+        if (is<RenderListBox>(cssBox))
+            return AccessibilityListBox::create(&downcast<RenderListBox>(cssBox));
+        if (is<RenderMenuList>(cssBox))
+            return AccessibilityMenuList::create(&downcast<RenderMenuList>(cssBox));
 
         // standard tables
-        if (cssBox->isTable())
-            return AccessibilityTable::create(toRenderTable(cssBox));
-        if (cssBox->isTableRow())
-            return AccessibilityTableRow::create(toRenderTableRow(cssBox));
-        if (cssBox->isTableCell())
-            return AccessibilityTableCell::create(toRenderTableCell(cssBox));
+        if (is<RenderTable>(cssBox))
+            return AccessibilityTable::create(&downcast<RenderTable>(cssBox));
+        if (is<RenderTableRow>(cssBox))
+            return AccessibilityTableRow::create(&downcast<RenderTableRow>(cssBox));
+        if (is<RenderTableCell>(cssBox))
+            return AccessibilityTableCell::create(&downcast<RenderTableCell>(cssBox));
 
         // progress bar
-        if (cssBox->isProgress())
-            return AccessibilityProgressIndicator::create(toRenderProgress(cssBox));
+        if (is<RenderProgress>(cssBox))
+            return AccessibilityProgressIndicator::create(&downcast<RenderProgress>(cssBox));
 
 #if ENABLE(METER_ELEMENT)
-        if (cssBox->isMeter())
-            return AccessibilityProgressIndicator::create(toRenderMeter(cssBox));
+        if (is<RenderMeter>(cssBox))
+            return AccessibilityProgressIndicator::create(&downcast<RenderMeter>(cssBox));
 #endif
 
         // input type=range
-        if (cssBox->isSlider())
-            return AccessibilitySlider::create(toRenderSlider(cssBox));
+        if (is<RenderSlider>(cssBox))
+            return AccessibilitySlider::create(&downcast<RenderSlider>(cssBox));
     }
 
     return AccessibilityRenderObject::create(renderer);

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (174586 => 174587)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -75,6 +75,7 @@
 #include "RenderLayer.h"
 #include "RenderLineBreak.h"
 #include "RenderListBox.h"
+#include "RenderListItem.h"
 #include "RenderListMarker.h"
 #include "RenderMathMLBlock.h"
 #include "RenderMathMLFraction.h"
@@ -148,9 +149,9 @@
 
 RenderBoxModelObject* AccessibilityRenderObject::renderBoxModelObject() const
 {
-    if (!m_renderer || !m_renderer->isBoxModelObject())
+    if (!is<RenderBoxModelObject>(m_renderer))
         return nullptr;
-    return toRenderBoxModelObject(m_renderer);
+    return downcast<RenderBoxModelObject>(m_renderer);
 }
 
 void AccessibilityRenderObject::setRenderer(RenderObject* renderer)
@@ -159,16 +160,9 @@
     setNode(renderer->node());
 }
 
-static inline bool isInlineWithContinuation(RenderObject* object)
+static inline bool isInlineWithContinuation(RenderObject& object)
 {
-    if (!object->isBoxModelObject())
-        return false;
-
-    RenderBoxModelObject* renderer = toRenderBoxModelObject(object);
-    if (!renderer->isRenderInline())
-        return false;
-
-    return toRenderInline(renderer)->continuation();
+    return is<RenderInline>(object) && downcast<RenderInline>(object).continuation();
 }
 
 static inline RenderObject* firstChildInContinuation(RenderInline& renderer)
@@ -190,7 +184,7 @@
 {
     RenderObject* firstChild = renderer.firstChildSlow();
 
-    if (!firstChild && isInlineWithContinuation(&renderer))
+    if (!firstChild && isInlineWithContinuation(renderer))
         firstChild = firstChildInContinuation(downcast<RenderInline>(renderer));
 
     return firstChild;
@@ -356,7 +350,7 @@
 static inline bool lastChildHasContinuation(RenderElement& renderer)
 {
     RenderObject* child = renderer.lastChild();
-    return child && isInlineWithContinuation(child);
+    return child && isInlineWithContinuation(*child);
 }
 
 AccessibilityObject* AccessibilityRenderObject::nextSibling() const
@@ -388,11 +382,11 @@
 
     // Case 4: node is an inline with a continuation. Next sibling is the next sibling of the end 
     // of the continuation chain.
-    else if (isInlineWithContinuation(m_renderer))
+    else if (isInlineWithContinuation(*m_renderer))
         nextSibling = endOfContinuations(*m_renderer)->nextSibling();
 
     // Case 5: node has no next sibling, and its parent is an inline with a continuation.
-    else if (isInlineWithContinuation(m_renderer->parent())) {
+    else if (isInlineWithContinuation(*m_renderer->parent())) {
         auto& continuation = *downcast<RenderInline>(*m_renderer->parent()).continuation();
         
         // Case 5a: continuation is a block - in this case the block itself is the next sibling.
@@ -1712,9 +1706,9 @@
 
 Widget* AccessibilityRenderObject::widget() const
 {
-    if (!m_renderer->isBoxModelObject() || !toRenderBoxModelObject(m_renderer)->isWidget())
+    if (!is<RenderWidget>(*m_renderer))
         return nullptr;
-    return toRenderWidget(m_renderer)->widget();
+    return downcast<RenderWidget>(*m_renderer).widget();
 }
 
 AccessibilityObject* AccessibilityRenderObject::accessibilityParentForImageMap(HTMLMapElement* map) const
@@ -2377,18 +2371,18 @@
     return nullptr;
 }
 
-bool AccessibilityRenderObject::renderObjectIsObservable(RenderObject* renderer) const
+bool AccessibilityRenderObject::renderObjectIsObservable(RenderObject& renderer) const
 {
     // AX clients will listen for AXValueChange on a text control.
-    if (renderer->isTextControl())
+    if (is<RenderTextControl>(renderer))
         return true;
     
     // AX clients will listen for AXSelectedChildrenChanged on listboxes.
-    Node* node = renderer->node();
+    Node* node = renderer.node();
     if (!node)
         return false;
     
-    if (nodeHasRole(node, "listbox") || (renderer->isBoxModelObject() && toRenderBoxModelObject(renderer)->isListBox()))
+    if (nodeHasRole(node, "listbox") || (is<RenderBoxModelObject>(renderer) && downcast<RenderBoxModelObject>(renderer).isListBox()))
         return true;
 
     // Textboxes should send out notifications.
@@ -2402,7 +2396,7 @@
 {
     // Find the object going up the parent chain that is used in accessibility to monitor certain notifications.
     for (RenderObject* renderer = m_renderer; renderer && renderer->node(); renderer = renderer->parent()) {
-        if (renderObjectIsObservable(renderer)) {
+        if (renderObjectIsObservable(*renderer)) {
             if (AXObjectCache* cache = axObjectCache())
                 return cache->getOrCreate(renderer);
         }
@@ -3419,10 +3413,10 @@
     if (!renderer)
         return UnknownRole;
 
-    if (renderer->isText())
+    if (is<RenderText>(*renderer))
         return EditableTextRole;
 
-    if (renderer->isBoxModelObject() && toRenderBoxModelObject(renderer)->isListItem())
+    if (is<RenderListItem>(*renderer))
         return ListItemRole;
 
     return UnknownRole;

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (174586 => 174587)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2014-10-10 15:49:24 UTC (rev 174587)
@@ -247,7 +247,7 @@
     AccessibilityObject* accessibilityParentForImageMap(HTMLMapElement*) const;
     virtual AccessibilityObject* elementAccessibilityHitTest(const IntPoint&) const override;
 
-    bool renderObjectIsObservable(RenderObject*) const;
+    bool renderObjectIsObservable(RenderObject&) const;
     RenderObject* renderParentObject() const;
     bool isDescendantOfElementType(const QualifiedName& tagName) const;
     

Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.cpp (174586 => 174587)


--- trunk/Source/WebCore/accessibility/AccessibilityTable.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -259,13 +259,13 @@
             
             // For the first 5 rows, cache the background color so we can check if this table has zebra-striped rows.
             if (row < 5 && row == alternatingRowColorCount) {
-                RenderObject* renderRow = cell->parent();
-                if (!renderRow || !renderRow->isBoxModelObject() || !toRenderBoxModelObject(renderRow)->isTableRow())
+                RenderElement* renderRow = cell->parent();
+                if (!is<RenderTableRow>(renderRow))
                     continue;
                 const RenderStyle& rowRenderStyle = renderRow->style();
                 Color rowColor = rowRenderStyle.visitedDependentColor(CSSPropertyBackgroundColor);
                 alternatingRowColors[alternatingRowColorCount] = rowColor;
-                alternatingRowColorCount++;
+                ++alternatingRowColorCount;
             }
         }
         

Modified: trunk/Source/WebCore/dom/Node.cpp (174586 => 174587)


--- trunk/Source/WebCore/dom/Node.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/dom/Node.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -629,13 +629,13 @@
 RenderBox* Node::renderBox() const
 {
     RenderObject* renderer = this->renderer();
-    return renderer && renderer->isBox() ? toRenderBox(renderer) : 0;
+    return is<RenderBox>(renderer) ? downcast<RenderBox>(renderer) : nullptr;
 }
 
 RenderBoxModelObject* Node::renderBoxModelObject() const
 {
     RenderObject* renderer = this->renderer();
-    return renderer && renderer->isBoxModelObject() ? toRenderBoxModelObject(renderer) : 0;
+    return is<RenderBoxModelObject>(renderer) ? downcast<RenderBoxModelObject>(renderer) : nullptr;
 }
 
 LayoutRect Node::boundingBox() const

Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (174586 => 174587)


--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -706,7 +706,7 @@
     Frame* containingFrame = node->document().frame();
     FrameView* containingView = containingFrame->view();
     IntRect boundingBox = snappedIntRect(containingView->contentsToRootView(renderer->absoluteBoundingBoxRect()));
-    RenderBoxModelObject* modelObject = renderer->isBoxModelObject() ? toRenderBoxModelObject(renderer) : nullptr;
+    RenderBoxModelObject* modelObject = is<RenderBoxModelObject>(*renderer) ? downcast<RenderBoxModelObject>(renderer) : nullptr;
     elementInfo->setString("nodeWidth", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), *modelObject) : boundingBox.width()));
     elementInfo->setString("nodeHeight", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), *modelObject) : boundingBox.height()));
     

Modified: trunk/Source/WebCore/page/FrameView.cpp (174586 => 174587)


--- trunk/Source/WebCore/page/FrameView.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/page/FrameView.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -1782,7 +1782,7 @@
 
         // Fixed items should always have layers.
         ASSERT(renderer->hasLayer());
-        RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
+        RenderLayer* layer = downcast<RenderBoxModelObject>(*renderer).layer();
 
         if (layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotCompositedForBoundsOutOfView
             || layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotCompositedForNoVisibleContent) {

Modified: trunk/Source/WebCore/page/PrintContext.cpp (174586 => 174587)


--- trunk/Source/WebCore/page/PrintContext.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/page/PrintContext.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -225,11 +225,11 @@
 static RenderBoxModelObject* enclosingBoxModelObject(RenderObject* object)
 {
 
-    while (object && !object->isBoxModelObject())
+    while (object && !is<RenderBoxModelObject>(*object))
         object = object->parent();
     if (!object)
-        return 0;
-    return toRenderBoxModelObject(object);
+        return nullptr;
+    return downcast<RenderBoxModelObject>(object);
 }
 
 int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSizeInPixels)

Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (174586 => 174587)


--- trunk/Source/WebCore/page/animation/AnimationBase.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -658,7 +658,7 @@
         m_pauseTime = m_startTime + t - m_animation->delay();
 
     if (m_object && m_object->isComposited())
-        toRenderBoxModelObject(m_object)->suspendAnimations(m_pauseTime);
+        downcast<RenderBoxModelObject>(*m_object).suspendAnimations(m_pauseTime);
 }
 
 double AnimationBase::beginAnimationUpdateTime() const

Modified: trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp (174586 => 174587)


--- trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -102,7 +102,7 @@
 bool ImplicitAnimation::startAnimation(double timeOffset)
 {
     if (m_object && m_object->isComposited())
-        return toRenderBoxModelObject(m_object)->startTransition(timeOffset, m_animatingProperty, m_fromStyle.get(), m_toStyle.get());
+        return downcast<RenderBoxModelObject>(*m_object).startTransition(timeOffset, m_animatingProperty, m_fromStyle.get(), m_toStyle.get());
     return false;
 }
 
@@ -112,7 +112,7 @@
         return;
 
     if (m_object->isComposited())
-        toRenderBoxModelObject(m_object)->transitionPaused(timeOffset, m_animatingProperty);
+        downcast<RenderBoxModelObject>(*m_object).transitionPaused(timeOffset, m_animatingProperty);
     // Restore the original (unanimated) style
     if (!paused())
         setNeedsStyleRecalc(m_object->element());
@@ -121,7 +121,7 @@
 void ImplicitAnimation::endAnimation()
 {
     if (m_object && m_object->isComposited())
-        toRenderBoxModelObject(m_object)->transitionFinished(m_animatingProperty);
+        downcast<RenderBoxModelObject>(*m_object).transitionFinished(m_animatingProperty);
 }
 
 void ImplicitAnimation::onAnimationEnd(double elapsedTime)

Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp (174586 => 174587)


--- trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -205,9 +205,8 @@
 
 bool KeyframeAnimation::startAnimation(double timeOffset)
 {
-    if (m_object && m_object->isComposited()) {
-        return toRenderBoxModelObject(m_object)->startAnimation(timeOffset, m_animation.get(), m_keyframes);
-    }
+    if (m_object && m_object->isComposited())
+        return downcast<RenderBoxModelObject>(*m_object).startAnimation(timeOffset, m_animation.get(), m_keyframes);
     return false;
 }
 
@@ -217,7 +216,7 @@
         return;
 
     if (m_object->isComposited())
-        toRenderBoxModelObject(m_object)->animationPaused(timeOffset, m_keyframes.animationName());
+        downcast<RenderBoxModelObject>(*m_object).animationPaused(timeOffset, m_keyframes.animationName());
 
     // Restore the original (unanimated) style
     if (!paused())
@@ -230,7 +229,7 @@
         return;
 
     if (m_object->isComposited())
-        toRenderBoxModelObject(m_object)->animationFinished(m_keyframes.animationName());
+        downcast<RenderBoxModelObject>(*m_object).animationFinished(m_keyframes.animationName());
 
     // Restore the original (unanimated) style
     if (!paused())

Modified: trunk/Source/WebCore/page/ios/FrameIOS.mm (174586 => 174587)


--- trunk/Source/WebCore/page/ios/FrameIOS.mm	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/page/ios/FrameIOS.mm	2014-10-10 15:49:24 UTC (rev 174587)
@@ -853,12 +853,12 @@
     if (!renderer || !renderer->hasLayer())
         return;
 
-    RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
+    RenderLayer& layer = *downcast<RenderBoxModelObject>(*renderer).layer();
 
-    layer->setIsUserScroll(isUserScroll);
-    layer->scrollToOffsetWithoutAnimation(position);
-    layer->setIsUserScroll(false);
-    layer->didEndScroll(); // FIXME: Should we always call this?
+    layer.setIsUserScroll(isUserScroll);
+    layer.scrollToOffsetWithoutAnimation(position);
+    layer.setIsUserScroll(false);
+    layer.didEndScroll(); // FIXME: Should we always call this?
 }
 
 void Frame::resetAllGeolocationPermission()

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (174586 => 174587)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -310,12 +310,12 @@
         return false;
 
     for (FrameView::ViewportConstrainedObjectSet::const_iterator it = viewportConstrainedObjects->begin(), end = viewportConstrainedObjects->end(); it != end; ++it) {
-        RenderObject* viewportConstrainedObject = *it;
-        if (!viewportConstrainedObject->isBoxModelObject() || !viewportConstrainedObject->hasLayer())
+        RenderObject& viewportConstrainedObject = **it;
+        if (!is<RenderBoxModelObject>(viewportConstrainedObject) || !viewportConstrainedObject.hasLayer())
             return true;
-        RenderLayer* layer = toRenderBoxModelObject(viewportConstrainedObject)->layer();
+        RenderLayer& layer = *downcast<RenderBoxModelObject>(viewportConstrainedObject).layer();
         // Any explicit reason that a fixed position element is not composited shouldn't cause slow scrolling.
-        if (!layer->isComposited() && layer->viewportConstrainedNotCompositedReason() == RenderLayer::NoNotCompositedReason)
+        if (!layer.isComposited() && layer.viewportConstrainedNotCompositedReason() == RenderLayer::NoNotCompositedReason)
             return true;
     }
     return false;

Modified: trunk/Source/WebCore/rendering/InlineBox.h (174586 => 174587)


--- trunk/Source/WebCore/rendering/InlineBox.h	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2014-10-10 15:49:24 UTC (rev 174587)
@@ -22,6 +22,7 @@
 #define InlineBox_h
 
 #include "RenderBoxModelObject.h"
+#include "RenderText.h"
 #include "TextDirection.h"
 
 namespace WebCore {
@@ -252,9 +253,9 @@
     // Use with caution! The type is not checked!
     RenderBoxModelObject* boxModelObject() const
     { 
-        if (!m_renderer.isText())
-            return &toRenderBoxModelObject(m_renderer);
-        return 0;
+        if (!is<RenderText>(m_renderer))
+            return &downcast<RenderBoxModelObject>(m_renderer);
+        return nullptr;
     }
 
     FloatPoint locationIncludingFlipping();

Modified: trunk/Source/WebCore/rendering/InlineElementBox.h (174586 => 174587)


--- trunk/Source/WebCore/rendering/InlineElementBox.h	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/InlineElementBox.h	2014-10-10 15:49:24 UTC (rev 174587)
@@ -42,7 +42,7 @@
     {
     }
 
-    RenderBoxModelObject& renderer() const { return toRenderBoxModelObject(InlineBox::renderer()); }
+    RenderBoxModelObject& renderer() const { return downcast<RenderBoxModelObject>(InlineBox::renderer()); }
 
     virtual void deleteLine() override;
     virtual void extractLine() override;

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -655,7 +655,7 @@
             const FontMetrics& fontMetrics = childLineStyle.fontMetrics();
             newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
             if (curr->isInlineFlowBox()) {
-                RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->renderer());
+                RenderBoxModelObject& boxObject = downcast<RenderBoxModelObject>(curr->renderer());
                 newLogicalTop -= childLineStyle.isHorizontalWritingMode()
                     ? boxObject.borderTop() + boxObject.paddingTop()
                     : boxObject.borderRight() + boxObject.paddingRight();

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (174586 => 174587)


--- trunk/Source/WebCore/rendering/InlineFlowBox.h	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h	2014-10-10 15:49:24 UTC (rev 174587)
@@ -75,7 +75,7 @@
     virtual const char* boxName() const override;
 #endif
 
-    RenderBoxModelObject& renderer() const { return toRenderBoxModelObject(InlineBox::renderer()); }
+    RenderBoxModelObject& renderer() const { return downcast<RenderBoxModelObject>(InlineBox::renderer()); }
     const RenderStyle& lineStyle() const { return isFirstLine() ? renderer().firstLineStyle() : renderer().style(); }
 
     InlineFlowBox* prevLineBox() const { return m_prevLineBox; }

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -169,7 +169,7 @@
         return 0;
     if (&parent()->renderer() == renderer().parent())
         return parent()->baselinePosition(baselineType);
-    return toRenderBoxModelObject(renderer().parent())->baselinePosition(baselineType, isFirstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
+    return downcast<RenderBoxModelObject>(*renderer().parent()).baselinePosition(baselineType, isFirstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
 }
 
 LayoutUnit InlineTextBox::lineHeight() const
@@ -178,7 +178,7 @@
         return 0;
     if (&parent()->renderer() == renderer().parent())
         return parent()->lineHeight();
-    return toRenderBoxModelObject(renderer().parent())->lineHeight(isFirstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
+    return downcast<RenderBoxModelObject>(*renderer().parent()).lineHeight(isFirstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
 }
 
 LayoutUnit InlineTextBox::selectionTop() const

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -353,14 +353,14 @@
 void RenderBlock::addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild)
 {
     RenderBlock* flow = continuationBefore(beforeChild);
-    ASSERT(!beforeChild || beforeChild->parent()->isRenderBlock());
-    RenderBoxModelObject* beforeChildParent = 0;
+    ASSERT(!beforeChild || is<RenderBlock>(*beforeChild->parent()));
+    RenderBoxModelObject* beforeChildParent = nullptr;
     if (beforeChild)
-        beforeChildParent = toRenderBoxModelObject(beforeChild->parent());
+        beforeChildParent = downcast<RenderBoxModelObject>(beforeChild->parent());
     else {
-        RenderBoxModelObject* cont = flow->continuation();
-        if (cont)
-            beforeChildParent = cont;
+        RenderBoxModelObject* continuation = flow->continuation();
+        if (continuation)
+            beforeChildParent = continuation;
         else
             beforeChildParent = flow;
     }

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -2904,7 +2904,7 @@
             // FIXME: containingBlockLogicalWidthForContent() is wrong if the replaced element's block-flow is perpendicular to the
             // containing block's block-flow.
             // https://bugs.webkit.org/show_bug.cgi?id=46496
-            const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogicalWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockLogicalWidthForContent();
+            const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogicalWidthForPositioned(downcast<RenderBoxModelObject>(container())) : containingBlockLogicalWidthForContent();
             Length containerLogicalWidth = containingBlock()->style().logicalWidth();
             // FIXME: Handle cases when containing block width is calculated or viewport percent.
             // https://bugs.webkit.org/show_bug.cgi?id=91071
@@ -2969,7 +2969,7 @@
             // https://bugs.webkit.org/show_bug.cgi?id=46496
             LayoutUnit availableHeight;
             if (isOutOfFlowPositioned())
-                availableHeight = containingBlockLogicalHeightForPositioned(toRenderBoxModelObject(cb));
+                availableHeight = containingBlockLogicalHeightForPositioned(downcast<RenderBoxModelObject>(cb));
             else {
                 availableHeight = containingBlockLogicalHeightForContent(IncludeMarginBorderPadding);
                 // It is necessary to use the border-box to match WinIE's broken
@@ -3248,7 +3248,7 @@
 
     // We don't use containingBlock(), since we may be positioned by an enclosing
     // relative positioned inline.
-    const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
+    const RenderBoxModelObject* containerBlock = downcast<RenderBoxModelObject>(container());
     
     const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, region);
 
@@ -3576,7 +3576,7 @@
 
 
     // We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
-    const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
+    const RenderBoxModelObject* containerBlock = downcast<RenderBoxModelObject>(container());
 
     const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPositioned(containerBlock);
 
@@ -3829,10 +3829,10 @@
 
     // We don't use containingBlock(), since we may be positioned by an enclosing
     // relative positioned inline.
-    const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
+    const RenderBoxModelObject* containerBlock = downcast<RenderBoxModelObject>(container());
 
     const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock);
-    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, false);
+    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, nullptr, false);
 
     // To match WinIE, in quirks mode use the parent's 'direction' property
     // instead of the the container block's.
@@ -3997,10 +3997,10 @@
     // the numbers correspond to numbers in spec)
 
     // We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
-    const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
+    const RenderBoxModelObject* containerBlock = downcast<RenderBoxModelObject>(container());
 
     const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPositioned(containerBlock);
-    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, false);
+    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, nullptr, false);
 
     // Variables to solve.
     Length marginBefore = style().marginBefore();

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2014-10-10 15:49:24 UTC (rev 174587)
@@ -339,8 +339,6 @@
     void pixelSnapBackgroundImageGeometryForPainting(BackgroundImageGeometry&) const;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderBoxModelObject, isBoxModelObject())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBoxModelObject, isBoxModelObject())

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -432,7 +432,7 @@
     RenderRegion* startRegion = regionAtBlockOffset(objContainingBlock, referencePoint.y());
     if (startRegion) {
         // Take into account the offset coordinates of the region.
-        RenderBoxModelObject* startRegionBox = startRegion->isRenderNamedFlowFragment() ? toRenderBoxModelObject(startRegion->parent()) : startRegion;
+        RenderBoxModelObject* startRegionBox = is<RenderNamedFlowFragment>(*startRegion) ? downcast<RenderBoxModelObject>(startRegion->parent()) : startRegion;
         RenderBoxModelObject* currObject = startRegionBox;
         RenderBoxModelObject* currOffsetParent;
         while ((currOffsetParent = currObject->offsetParent())) {

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -368,10 +368,10 @@
 
     // Now take all of the children from beforeChild to the end and remove
     // them from |this| and place them in the clone.
-    RenderObject* o = beforeChild;
-    while (o) {
-        RenderObject* tmp = o;
-        o = tmp->nextSibling();
+    RenderObject* renderer = beforeChild;
+    while (renderer) {
+        RenderObject* tmp = renderer;
+        renderer = tmp->nextSibling();
         removeChildInternal(*tmp, NotifyChildren);
         cloneInline->addChildIgnoringContinuation(tmp);
         tmp->setNeedsLayoutAndPrefWidthsRecalc();
@@ -383,8 +383,8 @@
     // We have been reparented and are now under the fromBlock.  We need
     // to walk up our inline parent chain until we hit the containing block.
     // Once we hit the containing block we're done.
-    RenderBoxModelObject* curr = toRenderBoxModelObject(parent());
-    RenderBoxModelObject* currChild = this;
+    RenderBoxModelObject* current = downcast<RenderBoxModelObject>(parent());
+    RenderBoxModelObject* currentChild = this;
     
     // FIXME: Because splitting is O(n^2) as tags nest pathologically, we cap the depth at which we're willing to clone.
     // There will eventually be a better approach to this problem that will let us nest to a much
@@ -392,49 +392,48 @@
     // incorrect rendering, but the alternative is to hang forever.
     unsigned splitDepth = 1;
     const unsigned cMaxSplitDepth = 200; 
-    while (curr && curr != fromBlock) {
-        ASSERT(curr->isRenderInline());
+    while (current && current != fromBlock) {
         if (splitDepth < cMaxSplitDepth) {
             // Create a new clone.
             RenderPtr<RenderInline> cloneChild = WTF::move(cloneInline);
-            cloneInline = toRenderInline(curr)->clone();
+            cloneInline = downcast<RenderInline>(*current).clone();
 
             // Insert our child clone as the first child.
             cloneInline->addChildIgnoringContinuation(cloneChild.leakPtr());
 
             // Hook the clone up as a continuation of |curr|.
-            RenderInline* inlineCurr = toRenderInline(curr);
-            oldCont = inlineCurr->continuation();
-            inlineCurr->setContinuation(cloneInline.get());
+            RenderInline& currentInline = downcast<RenderInline>(*current);
+            oldCont = currentInline.continuation();
+            currentInline.setContinuation(cloneInline.get());
             cloneInline->setContinuation(oldCont);
 
             // Now we need to take all of the children starting from the first child
-            // *after* currChild and append them all to the clone.
-            o = currChild->nextSibling();
-            while (o) {
-                RenderObject* tmp = o;
-                o = tmp->nextSibling();
-                inlineCurr->removeChildInternal(*tmp, NotifyChildren);
+            // *after* currentChild and append them all to the clone.
+            renderer = currentChild->nextSibling();
+            while (renderer) {
+                RenderObject* tmp = renderer;
+                renderer = tmp->nextSibling();
+                currentInline.removeChildInternal(*tmp, NotifyChildren);
                 cloneInline->addChildIgnoringContinuation(tmp);
                 tmp->setNeedsLayoutAndPrefWidthsRecalc();
             }
         }
         
         // Keep walking up the chain.
-        currChild = curr;
-        curr = toRenderBoxModelObject(curr->parent());
-        splitDepth++;
+        currentChild = current;
+        current = downcast<RenderBoxModelObject>(current->parent());
+        ++splitDepth;
     }
 
     // Now we are at the block level. We need to put the clone into the toBlock.
     toBlock->insertChildInternal(cloneInline.leakPtr(), nullptr, NotifyChildren);
 
-    // Now take all the children after currChild and remove them from the fromBlock
+    // Now take all the children after currentChild and remove them from the fromBlock
     // and put them in the toBlock.
-    o = currChild->nextSibling();
-    while (o) {
-        RenderObject* tmp = o;
-        o = tmp->nextSibling();
+    renderer = currentChild->nextSibling();
+    while (renderer) {
+        RenderObject* tmp = renderer;
+        renderer = tmp->nextSibling();
         fromBlock->removeChildInternal(*tmp, NotifyChildren);
         toBlock->insertChildInternal(tmp, nullptr, NotifyChildren);
     }
@@ -508,14 +507,13 @@
 void RenderInline::addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild)
 {
     RenderBoxModelObject* flow = continuationBefore(beforeChild);
-    ASSERT(!beforeChild || beforeChild->parent()->isRenderBlock() || beforeChild->parent()->isRenderInline());
-    RenderBoxModelObject* beforeChildParent = 0;
+    ASSERT(!beforeChild || is<RenderBlock>(*beforeChild->parent()) || is<RenderInline>(*beforeChild->parent()));
+    RenderBoxModelObject* beforeChildParent = nullptr;
     if (beforeChild)
-        beforeChildParent = toRenderBoxModelObject(beforeChild->parent());
+        beforeChildParent = downcast<RenderBoxModelObject>(beforeChild->parent());
     else {
-        RenderBoxModelObject* cont = nextContinuation(flow);
-        if (cont)
-            beforeChildParent = cont;
+        if (RenderBoxModelObject* continuation = nextContinuation(flow))
+            beforeChildParent = continuation;
         else
             beforeChildParent = flow;
     }

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -1251,7 +1251,7 @@
     
     bool positionOrOffsetChanged = false;
     if (renderer().isInFlowPositioned()) {
-        LayoutSize newOffset = toRenderBoxModelObject(renderer()).offsetForInFlowPosition();
+        LayoutSize newOffset = downcast<RenderBoxModelObject>(renderer()).offsetForInFlowPosition();
         positionOrOffsetChanged = newOffset != m_offsetForInFlowPosition;
         m_offsetForInFlowPosition = newOffset;
         localPoint.move(m_offsetForInFlowPosition);
@@ -5404,10 +5404,10 @@
     foregroundRect = backgroundRect;
     outlineRect = backgroundRect;
 
-    RenderFlowThread* flowThread = namedFlowFragment ? namedFlowFragment->flowThread() : 0;
+    RenderFlowThread* flowThread = namedFlowFragment ? namedFlowFragment->flowThread() : nullptr;
     if (isSelfPaintingLayer() && flowThread && !renderer().isInFlowRenderFlowThread()) {
         ASSERT(namedFlowFragment->isValid());
-        const RenderBoxModelObject& boxModelObject = toRenderBoxModelObject(renderer());
+        const RenderBoxModelObject& boxModelObject = downcast<RenderBoxModelObject>(renderer());
         LayoutRect layerBoundsWithVisualOverflow = namedFlowFragment->visualOverflowRectForBox(&boxModelObject);
 
         // Layers are in physical coordinates so the origin must be moved to the physical top-left of the flowthread.
@@ -5593,7 +5593,7 @@
     // to the flow thread, not the last region (in which it will end up because of bottom:0px)
     if (namedFlowFragment && renderer().flowThreadContainingBlock()) {
         LayoutRect b = layerBounds;
-        b.moveBy(namedFlowFragment->visualOverflowRectForBox(toRenderBoxModelObject(&renderer())).location());
+        b.moveBy(namedFlowFragment->visualOverflowRectForBox(downcast<RenderBoxModelObject>(&renderer())).location());
         b.inflate(renderer().view().maximalOutlineSize());
         if (b.intersects(damageRect))
             return true;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -988,7 +988,7 @@
         }
 
         // Move the ancestor position at the top of the region where the composited layer is going to display.
-        RenderFlowThread& flowThread = toRenderFlowThread(flowThreadLayer->renderer());
+        RenderFlowThread& flowThread = downcast<RenderFlowThread>(flowThreadLayer->renderer());
         RenderNamedFlowFragment* parentRegion = flowThread.cachedRegionForCompositedLayer(m_owningLayer);
         if (!parentRegion)
             return;
@@ -996,7 +996,7 @@
         IntPoint flowDelta;
         m_owningLayer.convertToPixelSnappedLayerCoords(flowThreadLayer, flowDelta);
         parentRegion->adjustRegionBoundsFromFlowThreadPortionRect(ancestorCompositingBounds);
-        RenderBoxModelObject& layerOwner = toRenderBoxModelObject(parentRegion->layerOwner());
+        RenderBoxModelObject& layerOwner = downcast<RenderBoxModelObject>(parentRegion->layerOwner());
         RenderLayerBacking* layerOwnerBacking = layerOwner.layer()->backing();
         if (!layerOwnerBacking)
             return;

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -2558,7 +2558,7 @@
 
 bool RenderLayerCompositor::requiresCompositingForIndirectReason(RenderLayerModelObject& renderer, bool hasCompositedDescendants, bool has3DTransformedDescendants, RenderLayer::IndirectCompositingReason& reason) const
 {
-    RenderLayer& layer = *toRenderBoxModelObject(renderer).layer();
+    RenderLayer& layer = *downcast<RenderBoxModelObject>(renderer).layer();
 
     // When a layer has composited descendants, some effects, like 2d transforms, filters, masks etc must be implemented
     // via compositing so that they also apply to those composited descendants.
@@ -3653,7 +3653,7 @@
     ASSERT(!layer.enclosingOverflowClipLayer(ExcludeSelf));
 #endif
 
-    RenderBoxModelObject& renderer = toRenderBoxModelObject(layer.renderer());
+    RenderBoxModelObject& renderer = downcast<RenderBoxModelObject>(layer.renderer());
 
     StickyPositionViewportConstraints constraints;
     renderer.computeStickyPositionConstraints(constraints, renderer.constrainingRectForStickyPosition());

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -2124,7 +2124,7 @@
 {
 #if PLATFORM(IOS)
     if (hasLayer())
-        toRenderBoxModelObject(this)->layer()->willBeDestroyed();
+        downcast<RenderBoxModelObject>(*this).layer()->willBeDestroyed();
 #endif
 
     willBeDestroyed();
@@ -2424,7 +2424,7 @@
     // A is the HTML body element.
     // The computed value of the position property for element A is fixed.
     if (isRoot() || isBody() || (isOutOfFlowPositioned() && style().position() == FixedPosition))
-        return 0;
+        return nullptr;
 
     // If A is an area HTML element which has a map HTML element somewhere in the ancestor
     // chain return the nearest ancestor map HTML element and stop this algorithm.
@@ -2440,24 +2440,24 @@
 
     bool skipTables = isPositioned();
     float currZoom = style().effectiveZoom();
-    auto curr = parent();
-    while (curr && (!curr->element() || (!curr->isPositioned() && !curr->isBody())) && !curr->isRenderNamedFlowThread()) {
-        Element* element = curr->element();
+    auto current = parent();
+    while (current && (!current->element() || (!current->isPositioned() && !current->isBody())) && !is<RenderNamedFlowThread>(*current)) {
+        Element* element = current->element();
         if (!skipTables && element && (is<HTMLTableElement>(*element) || is<HTMLTableCellElement>(*element)))
             break;
  
-        float newZoom = curr->style().effectiveZoom();
+        float newZoom = current->style().effectiveZoom();
         if (currZoom != newZoom)
             break;
         currZoom = newZoom;
-        curr = curr->parent();
+        current = current->parent();
     }
     
     // CSS regions specification says that region flows should return the body element as their offsetParent.
-    if (curr && curr->isRenderNamedFlowThread())
-        curr = document().body() ? document().body()->renderer() : 0;
+    if (is<RenderNamedFlowThread>(current))
+        current = document().body() ? document().body()->renderer() : nullptr;
     
-    return curr && curr->isBoxModelObject() ? toRenderBoxModelObject(curr) : 0;
+    return is<RenderBoxModelObject>(current) ? downcast<RenderBoxModelObject>(current) : nullptr;
 }
 
 VisiblePosition RenderObject::createVisiblePosition(int offset, EAffinity affinity) const

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp (174586 => 174587)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -76,11 +76,11 @@
 RenderBoxModelObject* RenderMathMLScripts::base() const
 {
     if (!m_baseWrapper)
-        return 0;
+        return nullptr;
     RenderObject* base = m_baseWrapper->firstChild();
-    if (!base || !base->isBoxModelObject())
-        return 0;
-    return toRenderBoxModelObject(base);
+    if (!is<RenderBoxModelObject>(base))
+        return nullptr;
+    return downcast<RenderBoxModelObject>(base);
 }
 
 void RenderMathMLScripts::fixAnonymousStyleForSubSupPair(RenderObject* subSupPair, bool isPostScript)

Modified: trunk/Source/WebKit/mac/ChangeLog (174586 => 174587)


--- trunk/Source/WebKit/mac/ChangeLog	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-10-10 15:49:24 UTC (rev 174587)
@@ -1,3 +1,18 @@
+2014-10-10  Chris Dumez  <cdu...@apple.com>
+
+        Use is<>() / downcast<>() for RenderBoxModelObject
+        https://bugs.webkit.org/show_bug.cgi?id=137587
+
+        Reviewed by Mihnea Ovidenie.
+
+        Use is<>() / downcast<>() for RenderBoxModelObject and clean up the
+        surrounding code.
+
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView invalidatePluginContentRect:]):
+        * WebView/WebRenderLayer.mm:
+        (-[WebRenderLayer initWithWebFrame:]):
+
 2014-10-09  Dean Jackson  <d...@apple.com>
 
         Remove ENABLE_CSS3_CONDITIONAL_RULES

Modified: trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm (174586 => 174587)


--- trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm	2014-10-10 15:49:24 UTC (rev 174587)
@@ -864,7 +864,7 @@
 
 - (void)invalidatePluginContentRect:(NSRect)rect
 {
-    if (RenderBoxModelObject *renderer = toRenderBoxModelObject(_element->renderer())) {
+    if (RenderBoxModelObject* renderer = downcast<RenderBoxModelObject>(_element->renderer())) {
         IntRect contentRect(rect);
         contentRect.move(renderer->borderLeft() + renderer->paddingLeft(), renderer->borderTop() + renderer->paddingTop());
         

Modified: trunk/Source/WebKit/mac/WebView/WebRenderLayer.mm (174586 => 174587)


--- trunk/Source/WebKit/mac/WebView/WebRenderLayer.mm	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebKit/mac/WebView/WebRenderLayer.mm	2014-10-10 15:49:24 UTC (rev 174587)
@@ -145,7 +145,7 @@
     }
 
     if (renderer->hasLayer()) {
-        RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
+        RenderLayer* layer = downcast<RenderBoxModelObject>(*renderer).layer();
 
         name = [[WebRenderLayer nameForLayer:layer] retain];
         bounds = layer->absoluteBoundingBox();

Modified: trunk/Source/WebKit2/ChangeLog (174586 => 174587)


--- trunk/Source/WebKit2/ChangeLog	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebKit2/ChangeLog	2014-10-10 15:49:24 UTC (rev 174587)
@@ -1,3 +1,17 @@
+2014-10-10  Chris Dumez  <cdu...@apple.com>
+
+        Use is<>() / downcast<>() for RenderBoxModelObject
+        https://bugs.webkit.org/show_bug.cgi?id=137587
+
+        Reviewed by Mihnea Ovidenie.
+
+        Use is<>() / downcast<>() for RenderBoxModelObject and clean up the
+        surrounding code.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::renderer):
+        (WebKit::PluginView::invalidateRect):
+
 2014-10-10  Pascal Jacquemart  <p.jacquem...@samsung.com>
 
         [SOUP] Remove custom URI schemes implementation

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (174586 => 174587)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2014-10-10 15:34:50 UTC (rev 174586)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2014-10-10 15:49:24 UTC (rev 174587)
@@ -464,7 +464,7 @@
 
 RenderBoxModelObject* PluginView::renderer() const
 {
-    return toRenderBoxModelObject(m_pluginElement->renderer());
+    return downcast<RenderBoxModelObject>(m_pluginElement->renderer());
 }
 
 void PluginView::pageScaleFactorDidChange()
@@ -1297,7 +1297,7 @@
     if (m_pluginElement->displayState() < HTMLPlugInElement::Restarting)
         return;
 
-    RenderBoxModelObject* renderer = toRenderBoxModelObject(m_pluginElement->renderer());
+    RenderBoxModelObject* renderer = downcast<RenderBoxModelObject>(m_pluginElement->renderer());
     if (!renderer)
         return;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to