Title: [89704] trunk/Source/WebCore
Revision
89704
Author
[email protected]
Date
2011-06-24 14:22:54 -0700 (Fri, 24 Jun 2011)

Log Message

2011-06-24  Julien Chaffraix  <[email protected]>

        Reviewed by Darin Adler.

        Remove unsafe static_cast inside the InlineBox hierarchy
        https://bugs.webkit.org/show_bug.cgi?id=63077

        Refactoring only, no new test.

        * rendering/InlineFlowBox.h:
        (WebCore::toInlineFlowBox):
        * rendering/InlineTextBox.h:
        (WebCore::toInlineTextBox):
        Added the proper cast methods to those 2 classes from an InlineBox.

        * rendering/InlineBox.cpp:
        (WebCore::InlineBox::nextLeafChild):
        (WebCore::InlineBox::prevLeafChild):
        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::getFlowSpacingLogicalWidth):
        (WebCore::InlineFlowBox::addToLine):
        (WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
        (WebCore::InlineFlowBox::placeBoxesInInlineDirection):
        (WebCore::InlineFlowBox::requiresIdeographicBaseline):
        (WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
        (WebCore::InlineFlowBox::computeLogicalBoxHeights):
        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
        (WebCore::InlineFlowBox::flipLinesInBlockDirection):
        (WebCore::InlineFlowBox::computeOverflow):
        (WebCore::InlineFlowBox::firstLeafChild):
        (WebCore::InlineFlowBox::lastLeafChild):
        (WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
        (WebCore::InlineFlowBox::computeUnderAnnotationAdjustment):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::positionForBox):
        * rendering/RenderBlockLineLayout.cpp:
        (WebCore::RenderBlock::createLineBoxes):
        (WebCore::RenderBlock::constructLine):
        (WebCore::setLogicalWidthForTextRun):
        (WebCore::computeExpansionForJustifiedText):
        (WebCore::RenderBlock::computeInlineDirectionPositionsForLine):
        * rendering/RenderText.cpp:
        (WebCore::RenderText::localCaretRect):
        (WebCore::RenderText::positionLineBox):
        * rendering/RootInlineBox.cpp:
        (WebCore::RootInlineBox::ascentAndDescentForBox):
        (WebCore::RootInlineBox::includeFontForBox):
        (WebCore::RootInlineBox::includeGlyphsForBox):
        Replaced the static_cast in those previous call sites with the new cast methods.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89703 => 89704)


--- trunk/Source/WebCore/ChangeLog	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/ChangeLog	2011-06-24 21:22:54 UTC (rev 89704)
@@ -1,3 +1,53 @@
+2011-06-24  Julien Chaffraix  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        Remove unsafe static_cast inside the InlineBox hierarchy
+        https://bugs.webkit.org/show_bug.cgi?id=63077
+
+        Refactoring only, no new test.
+
+        * rendering/InlineFlowBox.h:
+        (WebCore::toInlineFlowBox):
+        * rendering/InlineTextBox.h:
+        (WebCore::toInlineTextBox):
+        Added the proper cast methods to those 2 classes from an InlineBox.
+
+        * rendering/InlineBox.cpp:
+        (WebCore::InlineBox::nextLeafChild):
+        (WebCore::InlineBox::prevLeafChild):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::getFlowSpacingLogicalWidth):
+        (WebCore::InlineFlowBox::addToLine):
+        (WebCore::InlineFlowBox::determineSpacingForFlowBoxes):
+        (WebCore::InlineFlowBox::placeBoxesInInlineDirection):
+        (WebCore::InlineFlowBox::requiresIdeographicBaseline):
+        (WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
+        (WebCore::InlineFlowBox::computeLogicalBoxHeights):
+        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
+        (WebCore::InlineFlowBox::flipLinesInBlockDirection):
+        (WebCore::InlineFlowBox::computeOverflow):
+        (WebCore::InlineFlowBox::firstLeafChild):
+        (WebCore::InlineFlowBox::lastLeafChild):
+        (WebCore::InlineFlowBox::computeOverAnnotationAdjustment):
+        (WebCore::InlineFlowBox::computeUnderAnnotationAdjustment):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::positionForBox):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::createLineBoxes):
+        (WebCore::RenderBlock::constructLine):
+        (WebCore::setLogicalWidthForTextRun):
+        (WebCore::computeExpansionForJustifiedText):
+        (WebCore::RenderBlock::computeInlineDirectionPositionsForLine):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::localCaretRect):
+        (WebCore::RenderText::positionLineBox):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::ascentAndDescentForBox):
+        (WebCore::RootInlineBox::includeFontForBox):
+        (WebCore::RootInlineBox::includeGlyphsForBox):
+        Replaced the static_cast in those previous call sites with the new cast methods.
+
 2011-06-24  Alexis Menard  <[email protected]>
 
         Unreviewed build fix.

Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (89703 => 89704)


--- trunk/Source/WebCore/rendering/InlineBox.cpp	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp	2011-06-24 21:22:54 UTC (rev 89704)
@@ -282,7 +282,7 @@
 {
     InlineBox* leaf = 0;
     for (InlineBox* box = nextOnLine(); box && !leaf; box = box->nextOnLine())
-        leaf = box->isLeaf() ? box : static_cast<InlineFlowBox*>(box)->firstLeafChild();
+        leaf = box->isLeaf() ? box : toInlineFlowBox(box)->firstLeafChild();
     if (!leaf && parent())
         leaf = parent()->nextLeafChild();
     return leaf;
@@ -292,7 +292,7 @@
 {
     InlineBox* leaf = 0;
     for (InlineBox* box = prevOnLine(); box && !leaf; box = box->prevOnLine())
-        leaf = box->isLeaf() ? box : static_cast<InlineFlowBox*>(box)->lastLeafChild();
+        leaf = box->isLeaf() ? box : toInlineFlowBox(box)->lastLeafChild();
     if (!leaf && parent())
         leaf = parent()->prevLeafChild();
     return leaf;

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (89703 => 89704)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2011-06-24 21:22:54 UTC (rev 89704)
@@ -61,7 +61,7 @@
     int totWidth = marginBorderPaddingLogicalLeft() + marginBorderPaddingLogicalRight();
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
         if (curr->isInlineFlowBox())
-            totWidth += static_cast<InlineFlowBox*>(curr)->getFlowSpacingLogicalWidth();
+            totWidth += toInlineFlowBox(curr)->getFlowSpacingLogicalWidth();
     }
     return totWidth;
 }
@@ -101,7 +101,7 @@
             m_hasTextChildren = true;
         m_hasTextDescendants = true;
     } else if (child->isInlineFlowBox()) {
-        if (static_cast<InlineFlowBox*>(child)->hasTextDescendants())
+        if (toInlineFlowBox(child)->hasTextDescendants())
             m_hasTextDescendants = true;
     }
 
@@ -127,7 +127,7 @@
                 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
             } else {
                 ASSERT(isInlineFlowBox());
-                InlineFlowBox* childFlowBox = static_cast<InlineFlowBox*>(child);
+                InlineFlowBox* childFlowBox = toInlineFlowBox(child);
                 // Check the child's bit, and then also check for differences in font, line-height, vertical-align
                 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline()
                     || !parentStyle->font().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle->font().fontMetrics())
@@ -155,7 +155,7 @@
                    || (child->renderer()->isListMarker() && !toRenderListMarker(child->renderer())->isInside())))
             child->clearKnownToHaveNoOverflow();
         
-        if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !static_cast<InlineFlowBox*>(child)->knownToHaveNoOverflow())
+        if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlowBox(child)->knownToHaveNoOverflow())
             clearKnownToHaveNoOverflow();
     }
 
@@ -333,7 +333,7 @@
     // Recur into our children.
     for (InlineBox* currChild = firstChild(); currChild; currChild = currChild->nextOnLine()) {
         if (currChild->isInlineFlowBox()) {
-            InlineFlowBox* currFlow = static_cast<InlineFlowBox*>(currChild);
+            InlineFlowBox* currFlow = toInlineFlowBox(currChild);
             currFlow->determineSpacingForFlowBoxes(lastLine, isLogicallyLastRunWrapped, logicallyLastRunRenderer);
         }
     }
@@ -352,7 +352,7 @@
 
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
         if (curr->renderer()->isText()) {
-            InlineTextBox* text = static_cast<InlineTextBox*>(curr);
+            InlineTextBox* text = toInlineTextBox(curr);
             RenderText* rt = toRenderText(text->renderer());
             if (rt->textLength()) {
                 if (needsWordSpacing && isSpaceOrNewline(rt->characters()[text->start()]))
@@ -377,7 +377,7 @@
                 continue; // The positioned object has no effect on the width.
             }
             if (curr->renderer()->isRenderInline()) {
-                InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr);
+                InlineFlowBox* flow = toInlineFlowBox(curr);
                 logicalLeft += flow->marginLogicalLeft();
                 if (knownToHaveNoOverflow())
                     minLogicalLeft = min(logicalLeft, minLogicalLeft);
@@ -424,7 +424,7 @@
             continue; // Positioned placeholders don't affect calculations.
         
         if (curr->isInlineFlowBox()) {
-            if (static_cast<InlineFlowBox*>(curr)->requiresIdeographicBaseline(textBoxDataMap))
+            if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMap))
                 return true;
         } else {
             if (curr->renderer()->style(m_firstLine)->font().primaryFont()->hasVerticalGlyphs())
@@ -432,7 +432,7 @@
             
             const Vector<const SimpleFontData*>* usedFonts = 0;
             if (curr->isInlineTextBox()) {
-                GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDataMap.find(static_cast<InlineTextBox*>(curr));
+                GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDataMap.find(toInlineTextBox(curr));
                 usedFonts = it == textBoxDataMap.end() ? 0 : &it->second.first;
             }
 
@@ -471,7 +471,7 @@
         }
 
         if (curr->isInlineFlowBox())
-            static_cast<InlineFlowBox*>(curr)->adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom);
+            toInlineFlowBox(curr)->adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom);
     }
 }
 
@@ -523,7 +523,7 @@
         if (curr->renderer()->isPositioned())
             continue; // Positioned placeholders don't affect calculations.
         
-        InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? static_cast<InlineFlowBox*>(curr) : 0;
+        InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox(curr) : 0;
         
         bool affectsAscent = false;
         bool affectsDescent = false;
@@ -597,7 +597,7 @@
             continue;
         }
 
-        InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? static_cast<InlineFlowBox*>(curr) : 0;
+        InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox(curr) : 0;
         bool childAffectsTopBottomPos = true;
         if (curr->verticalAlign() == TOP)
             curr->setLogicalTop(top);
@@ -656,7 +656,7 @@
             }
             if (curr->isInlineTextBox()) {
                 TextEmphasisPosition emphasisMarkPosition;
-                if (static_cast<InlineTextBox*>(curr)->getEmphasisMarkPosition(curr->renderer()->style(m_firstLine), emphasisMarkPosition)) {
+                if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->renderer()->style(m_firstLine), emphasisMarkPosition)) {
                     bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver;
                     if (emphasisMarkIsOver != curr->renderer()->style(m_firstLine)->isFlippedLinesWritingMode())
                         hasAnnotationsBefore = true;
@@ -713,7 +713,7 @@
             continue; // Positioned placeholders aren't affected here.
         
         if (curr->isInlineFlowBox())
-            static_cast<InlineFlowBox*>(curr)->flipLinesInBlockDirection(lineTop, lineBottom);
+            toInlineFlowBox(curr)->flipLinesInBlockDirection(lineTop, lineBottom);
         else
             curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - curr->logicalHeight());
     }
@@ -843,7 +843,7 @@
             continue; // Positioned placeholders don't affect calculations.
         
         if (curr->renderer()->isText()) {
-            InlineTextBox* text = static_cast<InlineTextBox*>(curr);
+            InlineTextBox* text = toInlineTextBox(curr);
             RenderText* rt = toRenderText(text->renderer());
             if (rt->isBR())
                 continue;
@@ -851,7 +851,7 @@
             addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow);
             logicalVisualOverflow.unite(textBoxOverflow);
         } else  if (curr->renderer()->isRenderInline()) {
-            InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr);
+            InlineFlowBox* flow = toInlineFlowBox(curr);
             flow->computeOverflow(lineTop, lineBottom, textBoxDataMap);
             if (!flow->boxModelObject()->hasSelfPaintingLayer())
                 logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(lineTop, lineBottom));
@@ -1235,7 +1235,7 @@
 {
     InlineBox* leaf = 0;
     for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnLine())
-        leaf = child->isLeaf() ? child : static_cast<InlineFlowBox*>(child)->firstLeafChild();
+        leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild();
     return leaf;
 }
 
@@ -1243,7 +1243,7 @@
 {
     InlineBox* leaf = 0;
     for (InlineBox* child = lastChild(); child && !leaf; child = child->prevOnLine())
-        leaf = child->isLeaf() ? child : static_cast<InlineFlowBox*>(child)->lastLeafChild();
+        leaf = child->isLeaf() ? child : toInlineFlowBox(child)->lastLeafChild();
     return leaf;
 }
 
@@ -1305,7 +1305,7 @@
             continue; // Positioned placeholders don't affect calculations.
         
         if (curr->isInlineFlowBox())
-            result = max(result, static_cast<InlineFlowBox*>(curr)->computeOverAnnotationAdjustment(allowedPosition));
+            result = max(result, toInlineFlowBox(curr)->computeOverAnnotationAdjustment(allowedPosition));
         
         if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun()) {
             RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
@@ -1331,7 +1331,7 @@
         if (curr->isInlineTextBox()) {
             RenderStyle* style = curr->renderer()->style(m_firstLine);
             TextEmphasisPosition emphasisMarkPosition;
-            if (style->textEmphasisMark() != TextEmphasisMarkNone && static_cast<InlineTextBox*>(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMarkPosition == TextEmphasisPositionOver) {
+            if (style->textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMarkPosition == TextEmphasisPositionOver) {
                 if (!style->isFlippedLinesWritingMode()) {
                     int topOfEmphasisMark = curr->logicalTop() - style->font().emphasisMarkHeight(style->textEmphasisMarkString());
                     result = max(result, allowedPosition - topOfEmphasisMark);
@@ -1353,7 +1353,7 @@
             continue; // Positioned placeholders don't affect calculations.
 
         if (curr->isInlineFlowBox())
-            result = max(result, static_cast<InlineFlowBox*>(curr)->computeUnderAnnotationAdjustment(allowedPosition));
+            result = max(result, toInlineFlowBox(curr)->computeUnderAnnotationAdjustment(allowedPosition));
 
         if (curr->isInlineTextBox()) {
             RenderStyle* style = curr->renderer()->style(m_firstLine);

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (89703 => 89704)


--- trunk/Source/WebCore/rendering/InlineFlowBox.h	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h	2011-06-24 21:22:54 UTC (rev 89704)
@@ -300,6 +300,21 @@
 #endif
 };
 
+inline InlineFlowBox* toInlineFlowBox(InlineBox* object)
+{
+    ASSERT(!object || object->isInlineFlowBox());
+    return static_cast<InlineFlowBox*>(object);
+}
+
+inline const InlineFlowBox* toInlineFlowBox(const InlineBox* object)
+{
+    ASSERT(!object || object->isInlineFlowBox());
+    return static_cast<const InlineFlowBox*>(object);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toInlineFlowBox(const InlineFlowBox*);
+
 #ifdef NDEBUG
 inline void InlineFlowBox::checkConsistency() const
 {

Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (89703 => 89704)


--- trunk/Source/WebCore/rendering/InlineTextBox.h	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h	2011-06-24 21:22:54 UTC (rev 89704)
@@ -186,6 +186,21 @@
     }
 };
 
+inline InlineTextBox* toInlineTextBox(InlineBox* inlineBox)
+{
+    ASSERT(!inlineBox || inlineBox->isInlineTextBox());
+    return static_cast<InlineTextBox*>(inlineBox);
+}
+
+inline const InlineTextBox* toInlineTextBox(const InlineBox* inlineBox)
+{
+    ASSERT(!inlineBox || inlineBox->isInlineTextBox());
+    return static_cast<const InlineTextBox*>(inlineBox);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toInlineTextBox(const InlineTextBox*);
+
 inline RenderText* InlineTextBox::textRenderer() const
 {
     return toRenderText(renderer());

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (89703 => 89704)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-06-24 21:22:54 UTC (rev 89704)
@@ -4095,7 +4095,7 @@
     if (!box->isInlineTextBox())
         return createLegacyEditingPosition(box->renderer()->node(), start ? box->renderer()->caretMinOffset() : box->renderer()->caretMaxOffset());
 
-    InlineTextBox *textBox = static_cast<InlineTextBox *>(box);
+    InlineTextBox* textBox = toInlineTextBox(box);
     return createLegacyEditingPosition(box->renderer()->node(), start ? textBox->start() : textBox->start() + textBox->len());
 }
 

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (89703 => 89704)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2011-06-24 21:22:54 UTC (rev 89704)
@@ -258,7 +258,7 @@
             // made, we need to place it at the end of the current line.
             InlineBox* newBox = createInlineBoxForRenderer(obj, obj == this);
             ASSERT(newBox->isInlineFlowBox());
-            parentBox = static_cast<InlineFlowBox*>(newBox);
+            parentBox = toInlineFlowBox(newBox);
             parentBox->setFirstLineStyleBit(lineInfo.isFirstLine());
             parentBox->setIsHorizontal(isHorizontalWritingMode());
             if (!hasDefaultLineBoxContain)
@@ -349,7 +349,7 @@
         box->setBidiLevel(r->level());
 
         if (box->isInlineTextBox()) {
-            InlineTextBox* text = static_cast<InlineTextBox*>(box);
+            InlineTextBox* text = toInlineTextBox(box);
             text->setStart(r->m_start);
             text->setLen(r->m_stop - r->m_start);
             text->m_dirOverride = r->dirOverride(visuallyOrdered);
@@ -479,7 +479,7 @@
     }
     
     int hyphenWidth = 0;
-    if (static_cast<InlineTextBox*>(run->m_box)->hasHyphen()) {
+    if (toInlineTextBox(run->m_box)->hasHyphen()) {
         const AtomicString& hyphenString = renderer->style()->hyphenString();
         const Font& font = renderer->style(lineInfo.isFirstLine())->font();
         hyphenWidth = font.width(RenderBlock::constructTextRun(renderer, font, hyphenString.string(), renderer->style()));
@@ -487,14 +487,14 @@
     run->m_box->setLogicalWidth(renderer->width(run->m_start, run->m_stop - run->m_start, xPos, lineInfo.isFirstLine(), &fallbackFonts, &glyphOverflow) + hyphenWidth);
     if (!fallbackFonts.isEmpty()) {
         ASSERT(run->m_box->isText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(static_cast<InlineTextBox*>(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
         ASSERT(it->second.first.isEmpty());
         copyToVector(fallbackFonts, it->second.first);
         run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline();
     }
     if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right)) {
         ASSERT(run->m_box->isText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(static_cast<InlineTextBox*>(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
         it->second.second = glyphOverflow;
         run->m_box->clearKnownToHaveNoOverflow();
     }
@@ -517,7 +517,7 @@
             
             // Only justify text if whitespace is collapsed.
             if (r->m_object->style()->collapseWhiteSpace()) {
-                InlineTextBox* textBox = static_cast<InlineTextBox*>(r->m_box);
+                InlineTextBox* textBox = toInlineTextBox(r->m_box);
                 int expansion = (availableLogicalWidth - totalLogicalWidth) * opportunitiesInRun / expansionOpportunityCount;
                 textBox->setExpansion(expansion);
                 totalLogicalWidth += expansion;
@@ -552,7 +552,7 @@
             RenderText* rt = toRenderText(r->m_object);
             if (textAlign == JUSTIFY && r != trailingSpaceRun) {
                 if (!isAfterExpansion)
-                    static_cast<InlineTextBox*>(r->m_box)->setCanHaveLeadingExpansion(true);
+                    toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true);
                 unsigned opportunitiesInRun = Font::expansionOpportunityCount(rt->characters() + r->m_start, r->m_stop - r->m_start, r->m_box->direction(), isAfterExpansion);
                 expansionOpportunities.append(opportunitiesInRun);
                 expansionOpportunityCount += opportunitiesInRun;

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (89703 => 89704)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2011-06-24 21:22:54 UTC (rev 89704)
@@ -523,7 +523,7 @@
     if (!inlineBox->isInlineTextBox())
         return IntRect();
 
-    InlineTextBox* box = static_cast<InlineTextBox*>(inlineBox);
+    InlineTextBox* box = toInlineTextBox(inlineBox);
 
     int height = box->root()->selectionHeight();
     int top = box->root()->selectionTop();
@@ -1248,7 +1248,7 @@
 
 void RenderText::positionLineBox(InlineBox* box)
 {
-    InlineTextBox* s = static_cast<InlineTextBox*>(box);
+    InlineTextBox* s = toInlineTextBox(box);
 
     // FIXME: should not be needed!!!
     if (!s->len()) {

Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (89703 => 89704)


--- trunk/Source/WebCore/rendering/RootInlineBox.cpp	2011-06-24 20:54:58 UTC (rev 89703)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp	2011-06-24 21:22:54 UTC (rev 89704)
@@ -587,7 +587,7 @@
     Vector<const SimpleFontData*>* usedFonts = 0;
     GlyphOverflow* glyphOverflow = 0;
     if (box->isText()) {
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(static_cast<InlineTextBox*>(box));
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toInlineTextBox(box));
         usedFonts = it == textBoxDataMap.end() ? 0 : &it->second.first;
         glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->second.second;
     }
@@ -746,7 +746,7 @@
     if (box->renderer()->isReplaced() || (box->renderer()->isText() && !box->isText()))
         return false;
     
-    if (!box->isText() && box->isInlineFlowBox() && !static_cast<InlineFlowBox*>(box)->hasTextChildren())
+    if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
         return false;
 
     // For now map "glyphs" to "font" in vertical text mode until the bounds returned by glyphs aren't garbage.
@@ -759,7 +759,7 @@
     if (box->renderer()->isReplaced() || (box->renderer()->isText() && !box->isText()))
         return false;
     
-    if (!box->isText() && box->isInlineFlowBox() && !static_cast<InlineFlowBox*>(box)->hasTextChildren())
+    if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
         return false;
 
     // FIXME: We can't fit to glyphs yet for vertical text, since the bounds returned are garbage.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to