2011-06-20  Julien Chaffraix  <jchaffraix@webkit.org>

        Reviewed by Darin Adler.

        Remove some unsafe static_cast in rendering/
        https://bugs.webkit.org/show_bug.cgi?id=63014

        Mechanical refactoring, no test needed.

        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
        (WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::getEmphasisMarkPosition):
        * rendering/RenderBlockLineLayout.cpp:
        (WebCore::RenderBlock::LineBreaker::nextLineBreak):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::destroyScrollbar):
        * rendering/RenderRuby.cpp:
        (WebCore::rubyBeforeBlock):
        (WebCore::rubyAfterBlock):
        (WebCore::lastRubyRun):
        (WebCore::findRubyRunParent):
        * rendering/RenderRubyBase.cpp:
        (WebCore::RenderRubyBase::rubyRun):
        * rendering/RenderRubyRun.cpp:
        (WebCore::RenderRubyRun::removeChild):
        Use the proper conversion methods at the previous call-sites.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@89304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 58b1022..2b91764 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2011-06-20  Julien Chaffraix  <jchaffraix@webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Remove some unsafe static_cast in rendering/
+        https://bugs.webkit.org/show_bug.cgi?id=63014
+
+        Mechanical refactoring, no test needed.
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
+        (WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::getEmphasisMarkPosition):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::LineBreaker::nextLineBreak):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::destroyScrollbar):
+        * rendering/RenderRuby.cpp:
+        (WebCore::rubyBeforeBlock):
+        (WebCore::rubyAfterBlock):
+        (WebCore::lastRubyRun):
+        (WebCore::findRubyRunParent):
+        * rendering/RenderRubyBase.cpp:
+        (WebCore::RenderRubyBase::rubyRun):
+        * rendering/RenderRubyRun.cpp:
+        (WebCore::RenderRubyRun::removeChild):
+        Use the proper conversion methods at the previous call-sites.
+
 2011-06-20  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/Source/WebCore/rendering/InlineFlowBox.cpp b/Source/WebCore/rendering/InlineFlowBox.cpp
index 9fba84c..4be5e9c 100644
--- a/Source/WebCore/rendering/InlineFlowBox.cpp
+++ b/Source/WebCore/rendering/InlineFlowBox.cpp
@@ -646,7 +646,7 @@
                 else
                     hasAnnotationsAfter = true;
 
-                RenderRubyRun* rubyRun = static_cast<RenderRubyRun*>(curr->renderer());
+                RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
                 if (RenderRubyBase* rubyBase = rubyRun->rubyBase()) {
                     int bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : 0);
                     int topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : 0);
@@ -1308,7 +1308,7 @@
             result = max(result, static_cast<InlineFlowBox*>(curr)->computeOverAnnotationAdjustment(allowedPosition));
         
         if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun()) {
-            RenderRubyRun* rubyRun = static_cast<RenderRubyRun*>(curr->renderer());
+            RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
             RenderRubyText* rubyText = rubyRun->rubyText();
             if (!rubyText)
                 continue;
diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp
index b81b8fa..4ea45a7 100644
--- a/Source/WebCore/rendering/InlineTextBox.cpp
+++ b/Source/WebCore/rendering/InlineTextBox.cpp
@@ -452,7 +452,7 @@
     if (!containingBlock->parent()->isRubyRun())
         return true; // Cannot get the ruby text.
 
-    RenderRubyText* rubyText = static_cast<RenderRubyRun*>(containingBlock->parent())->rubyText();
+    RenderRubyText* rubyText = toRenderRubyRun(containingBlock->parent())->rubyText();
 
     // The emphasis marks over are suppressed only if there is a ruby text box and it not empty.
     return !rubyText || !rubyText->firstLineBox();
diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
index ca63238..311ba55 100644
--- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -2254,7 +2254,7 @@
 #if ENABLE(SVG)
                 if (isSVGText && current.m_pos > 0) {
                     // Force creation of new InlineBoxes for each absolute positioned character (those that start new text chunks).
-                    if (static_cast<RenderSVGInlineText*>(t)->characterStartsNewTextChunk(current.m_pos)) {
+                    if (toRenderSVGInlineText(t)->characterStartsNewTextChunk(current.m_pos)) {
                         addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos - 1));
                         addMidpoint(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos));
                     }
@@ -2272,7 +2272,7 @@
                 }
 
                 if (collapseWhiteSpace && currentCharacterIsSpace && !ignoringSpaces)
-                    trailingObjects.setTrailingWhitespace(static_cast<RenderText*>(current.m_obj));
+                    trailingObjects.setTrailingWhitespace(toRenderText(current.m_obj));
                 else if (!current.m_obj->style()->collapseWhiteSpace() || !currentCharacterIsSpace)
                     trailingObjects.clear();
 
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index f7f2481..4035237 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -1903,7 +1903,7 @@
     RefPtr<Scrollbar>& scrollbar = orientation == HorizontalScrollbar ? m_hBar : m_vBar;
     if (scrollbar) {
         if (scrollbar->isCustomScrollbar())
-            static_cast<RenderScrollbar*>(scrollbar.get())->clearOwningRenderer();
+            toRenderScrollbar(scrollbar.get())->clearOwningRenderer();
         else {
             if (orientation == HorizontalScrollbar)
                 willRemoveHorizontalScrollbar(scrollbar.get());
diff --git a/Source/WebCore/rendering/RenderRuby.cpp b/Source/WebCore/rendering/RenderRuby.cpp
index 0b51384..16b0a76 100644
--- a/Source/WebCore/rendering/RenderRuby.cpp
+++ b/Source/WebCore/rendering/RenderRuby.cpp
@@ -52,13 +52,13 @@
 static inline RenderBlock* rubyBeforeBlock(const RenderObject* ruby)
 {
     RenderObject* child = ruby->firstChild();
-    return child && !child->isRubyRun() && child->isRenderBlock() && child->style()->styleType() == BEFORE ? static_cast<RenderBlock*>(child) : 0;
+    return child && !child->isRubyRun() && child->isRenderBlock() && child->style()->styleType() == BEFORE ? toRenderBlock(child) : 0;
 }
 
 static inline RenderBlock* rubyAfterBlock(const RenderObject* ruby)
 {
     RenderObject* child = ruby->lastChild();
-    return child && !child->isRubyRun() && child->isRenderBlock() && child->style()->styleType() == AFTER ? static_cast<RenderBlock*>(child) : 0;
+    return child && !child->isRubyRun() && child->isRenderBlock() && child->style()->styleType() == AFTER ? toRenderBlock(child) : 0;
 }
 
 static RenderBlock* createAnonymousRubyInlineBlock(RenderObject* ruby, PseudoId styleType)
@@ -78,14 +78,14 @@
     if (child && !child->isRubyRun())
         child = child->previousSibling();
     ASSERT(!child || child->isRubyRun() || child->isBeforeContent() || child == rubyBeforeBlock(ruby));
-    return child && child->isRubyRun() ? static_cast<RenderRubyRun*>(child) : 0;
+    return child && child->isRubyRun() ? toRenderRubyRun(child) : 0;
 }
 
 static inline RenderRubyRun* findRubyRunParent(RenderObject* child)
 {
     while (child && !child->isRubyRun())
         child = child->parent();
-    return static_cast<RenderRubyRun*>(child);
+    return toRenderRubyRun(child);
 }
 
 //=== ruby as inline object ===
diff --git a/Source/WebCore/rendering/RenderRubyBase.cpp b/Source/WebCore/rendering/RenderRubyBase.cpp
index d285157..464346d 100644
--- a/Source/WebCore/rendering/RenderRubyBase.cpp
+++ b/Source/WebCore/rendering/RenderRubyBase.cpp
@@ -191,7 +191,7 @@
     ASSERT(parent());
     ASSERT(parent()->isRubyRun());
 
-    return static_cast<RenderRubyRun*>(parent());
+    return toRenderRubyRun(parent());
 }
 
 ETextAlign RenderRubyBase::textAlignmentForLine(bool /* endsWithSoftBreak */) const
diff --git a/Source/WebCore/rendering/RenderRubyRun.cpp b/Source/WebCore/rendering/RenderRubyRun.cpp
index 1329d65..63d2bd4 100644
--- a/Source/WebCore/rendering/RenderRubyRun.cpp
+++ b/Source/WebCore/rendering/RenderRubyRun.cpp
@@ -159,7 +159,7 @@
         RenderObject* rightNeighbour = nextSibling();
         if (base && rightNeighbour && rightNeighbour->isRubyRun()) {
             // Ruby run without a base can happen only at the first run.
-            RenderRubyRun* rightRun = static_cast<RenderRubyRun*>(rightNeighbour);
+            RenderRubyRun* rightRun = toRenderRubyRun(rightNeighbour);
             if (rightRun->hasRubyBase()) {
                 RenderRubyBase* rightBase = rightRun->rubyBaseSafe();
                 // Collect all children in a single base, then swap the bases.