Make more use of toRenderFoo(RenderObject&) cast helpers.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Sep 2013 05:29:00 +0000 (05:29 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Sep 2013 05:29:00 +0000 (05:29 +0000)
<https://webkit.org/b/120565>

Reviewed by Darin Adler.

To make amends for putting ugly toRenderFoo(&renderer) casts everywhere,
here's a patch that switches a bunch of code over to using reference-based casts.

I removed pointer-based casts altogether for these renderers:

    - RenderBR
    - RenderCombineText
    - RenderListMarker
    - RenderVideo
    - RenderView

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

42 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleHyperlink.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/rendering/InlineBox.h
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/InlineTextBox.h
Source/WebCore/rendering/RenderBR.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderCombineText.h
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h
Source/WebCore/rendering/RenderImage.h
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebCore/rendering/RenderListMarker.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderRubyBase.cpp
Source/WebCore/rendering/RenderRubyRun.h
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderVideo.h
Source/WebCore/rendering/RenderView.h
Source/WebCore/rendering/svg/RenderSVGInlineText.h
Source/WebCore/rendering/svg/RenderSVGText.cpp

index 388e6c5..fc42cfc 100644 (file)
@@ -1,3 +1,21 @@
+2013-08-31  Andreas Kling  <akling@apple.com>
+
+        Make more use of toRenderFoo(RenderObject&) cast helpers.
+        <https://webkit.org/b/120565>
+
+        Reviewed by Darin Adler.
+
+        To make amends for putting ugly toRenderFoo(&renderer) casts everywhere,
+        here's a patch that switches a bunch of code over to using reference-based casts.
+
+        I removed pointer-based casts altogether for these renderers:
+
+            - RenderBR
+            - RenderCombineText
+            - RenderListMarker
+            - RenderVideo
+            - RenderView
+
 2013-08-31  Santosh Mahto  <santosh.ma@samsung.com>
 
         warning: unused parameter â€˜renderingMode'  in ImageBufferCairo.cpp:94
index 2053172..7ac5a5d 100644 (file)
@@ -710,7 +710,7 @@ String AccessibilityRenderObject::stringValue() const
     }
     
     if (m_renderer->isListMarker())
-        return toRenderListMarker(m_renderer)->text();
+        return toRenderListMarker(*m_renderer).text();
     
     if (isWebArea())
         return String();
@@ -1336,7 +1336,7 @@ int AccessibilityRenderObject::layoutCount() const
 {
     if (!m_renderer->isRenderView())
         return 0;
-    return toRenderView(m_renderer)->frameView().layoutCount();
+    return toRenderView(*m_renderer).frameView().layoutCount();
 }
 
 String AccessibilityRenderObject::text() const
index 8ccc811..1e9304b 100644 (file)
@@ -156,10 +156,8 @@ unsigned AccessibilityObject::getLengthForTextRange() const
     // Gtk ATs need this for all text objects; not just text controls.
     Node* node = this->node();
     RenderObject* renderer = node ? node->renderer() : 0;
-    if (renderer && renderer->isText()) {
-        RenderText* renderText = toRenderText(renderer);
-        textLength = renderText ? renderText->textLength() : 0;
-    }
+    if (renderer && renderer->isText())
+        textLength = toRenderText(*renderer).textLength();
 
     // Get the text length from the elements under the
     // accessibility object if the value is still zero.
index e771a23..fe34577 100644 (file)
@@ -223,8 +223,8 @@ static gint getRangeLengthForObject(AccessibilityObject* obj, Range* range)
     if (!renderer || !renderer->isListMarker())
         return baseLength;
 
-    RenderListMarker* marker = toRenderListMarker(renderer);
-    return baseLength + marker->text().length() + marker->suffix().length();
+    RenderListMarker& marker = toRenderListMarker(*renderer);
+    return baseLength + marker.text().length() + marker.suffix().length();
 }
 
 static gint webkitAccessibleHyperlinkGetStartIndex(AtkHyperlink* link)
index 4f0f4b8..f17cdc1 100644 (file)
@@ -388,8 +388,8 @@ static guint accessibilityObjectLength(const AccessibilityObject* object)
     // separately (as in getAccessibilityObjectForOffset)
     RenderObject* renderer = object->renderer();
     if (renderer && renderer->isListMarker()) {
-        RenderListMarker* marker = toRenderListMarker(renderer);
-        return marker->text().length() + marker->suffix().length();
+        RenderListMarker& marker = toRenderListMarker(*renderer);
+        return marker.text().length() + marker.suffix().length();
     }
 
     return 0;
index e2e925c..b2b380c 100644 (file)
@@ -3802,7 +3802,7 @@ void HTMLMediaElement::mediaPlayerSizeChanged(MediaPlayer*)
 bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated(MediaPlayer*)
 {
     if (renderer() && renderer()->isVideo())
-        return renderer()->view().compositor().canAccelerateVideoRendering(toRenderVideo(renderer()));
+        return renderer()->view().compositor().canAccelerateVideoRendering(toRenderVideo(*renderer()));
     return false;
 }
 
index f6a1699..f7d72c5 100644 (file)
@@ -1381,7 +1381,7 @@ void MediaControlTextTrackContainerElement::updateSizes(bool forceUpdate)
 #else
         if (!mediaElement->renderer() || !mediaElement->renderer()->isVideo())
             return;
-        videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
+        videoBox = toRenderVideo(*mediaElement->renderer()).videoBox();
 #endif
     }
 
index e36c560..1c12cfa 100644 (file)
@@ -326,7 +326,7 @@ RenderImageResource* ImageLoader::renderImageResource()
     // We don't return style generated image because it doesn't belong to the ImageLoader.
     // See <https://bugs.webkit.org/show_bug.cgi?id=42840>
     if (renderer->isImage() && !static_cast<RenderImage*>(renderer)->isGeneratedContent())
-        return toRenderImage(renderer)->imageResource();
+        return toRenderImage(*renderer).imageResource();
 
 #if ENABLE(SVG)
     if (renderer->isSVGImage())
@@ -335,7 +335,7 @@ RenderImageResource* ImageLoader::renderImageResource()
 
 #if ENABLE(VIDEO)
     if (renderer->isVideo())
-        return toRenderVideo(renderer)->imageResource();
+        return toRenderVideo(*renderer).imageResource();
 #endif
 
     return 0;
index f934c10..bffeab0 100644 (file)
@@ -1226,7 +1226,7 @@ void FrameView::layout(bool allowSubtree)
         ScrollbarMode vMode;    
         calculateScrollbarModesForLayout(hMode, vMode);
 
-        m_needsFullRepaint = !subtree && (m_firstLayout || toRenderView(root)->printing());
+        m_needsFullRepaint = !subtree && (m_firstLayout || toRenderView(*root).printing());
 
         if (!subtree) {
             // Now set our scrollbar state for the layout.
@@ -1307,7 +1307,7 @@ void FrameView::layout(bool allowSubtree)
 
     bool neededFullRepaint = m_needsFullRepaint;
 
-    if (!subtree && !toRenderView(root)->printing())
+    if (!subtree && !toRenderView(*root).printing())
         adjustViewSize();
 
     m_needsFullRepaint = neededFullRepaint;
index 8754960..47cc390 100644 (file)
@@ -286,7 +286,7 @@ public:
     RenderBoxModelObject* boxModelObject() const
     { 
         if (!m_renderer.isText())
-            return toRenderBoxModelObject(&m_renderer);
+            return &toRenderBoxModelObject(m_renderer);
         return 0;
     }
 
index e4cd7d7..6fc2709 100644 (file)
@@ -167,7 +167,7 @@ void InlineFlowBox::addToLine(InlineBox* child)
             if (box.hasRenderOverflow() || box.hasSelfPaintingLayer())
                 child->clearKnownToHaveNoOverflow();
         } else if (!child->renderer().isBR() && (child->renderer().style(isFirstLineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer()
-                   || (child->renderer().isListMarker() && !toRenderListMarker(&child->renderer())->isInside())
+                   || (child->renderer().isListMarker() && !toRenderListMarker(child->renderer()).isInside())
                    || child->renderer().style(isFirstLineStyle())->hasBorderImageOutsets()))
             child->clearKnownToHaveNoOverflow();
         
@@ -420,7 +420,7 @@ float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin
                 if (knownToHaveNoOverflow())
                     maxLogicalRight = max(logicalLeft, maxLogicalRight);
                 logicalLeft += flow->marginLogicalRight();
-            } else if (!curr->renderer().isListMarker() || toRenderListMarker(&curr->renderer())->isInside()) {
+            } else if (!curr->renderer().isListMarker() || toRenderListMarker(curr->renderer()).isInside()) {
                 // The box can have a different writing-mode than the overall line, so this is a bit complicated.
                 // Just get all the physical margin and overflow values by hand based off |isVertical|.
                 LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop();
@@ -663,9 +663,10 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
             const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineStyle())->fontMetrics();
             newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
             if (curr->isInlineFlowBox()) {
-                RenderBoxModelObject* boxObject = toRenderBoxModelObject(&curr->renderer());
-                newLogicalTop -= boxObject->style(isFirstLineStyle())->isHorizontalWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() : 
-                                 boxObject->borderRight() + boxObject->paddingRight();
+                RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->renderer());
+                newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizontalWritingMode()
+                    ? boxObject.borderTop() + boxObject.paddingTop()
+                    : boxObject.borderRight() + boxObject.paddingRight();
             }
             newLogicalTopIncludingMargins = newLogicalTop;
         } else if (!curr->renderer().isBR()) {
@@ -689,8 +690,8 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
                 else
                     hasAnnotationsAfter = true;
 
-                RenderRubyRun* rubyRun = toRenderRubyRun(&curr->renderer());
-                if (RenderRubyBase* rubyBase = rubyRun->rubyBase()) {
+                RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+                if (RenderRubyBase* rubyBase = rubyRun.rubyBase()) {
                     LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit());
                     LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit());
                     newLogicalTop += !renderer().style()->isFlippedLinesWritingMode() ? topRubyBaseLeading : bottomRubyBaseLeading;
@@ -1514,12 +1515,12 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
             result = max(result, toInlineFlowBox(curr)->computeOverAnnotationAdjustment(allowedPosition));
         
         if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && curr->renderer().style()->rubyPosition() == RubyPositionBefore) {
-            RenderRubyRun* rubyRun = toRenderRubyRun(&curr->renderer());
-            RenderRubyText* rubyText = rubyRun->rubyText();
+            RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+            RenderRubyText* rubyText = rubyRun.rubyText();
             if (!rubyText)
                 continue;
             
-            if (!rubyRun->style()->isFlippedLinesWritingMode()) {
+            if (!rubyRun.style()->isFlippedLinesWritingMode()) {
                 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
                 if (topOfFirstRubyTextLine >= 0)
                     continue;
@@ -1562,12 +1563,12 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
             result = max(result, toInlineFlowBox(curr)->computeUnderAnnotationAdjustment(allowedPosition));
 
         if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && curr->renderer().style()->rubyPosition() == RubyPositionAfter) {
-            RenderRubyRun* rubyRun = toRenderRubyRun(&curr->renderer());
-            RenderRubyText* rubyText = rubyRun->rubyText();
+            RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
+            RenderRubyText* rubyText = rubyRun.rubyText();
             if (!rubyText)
                 continue;
 
-            if (rubyRun->style()->isFlippedLinesWritingMode()) {
+            if (rubyRun.style()->isFlippedLinesWritingMode()) {
                 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
                 if (topOfFirstRubyTextLine >= 0)
                     continue;
index 31e7187..3a193e1 100644 (file)
@@ -109,7 +109,7 @@ LayoutUnit InlineTextBox::lineHeight() const
     if (!isText() || !renderer().parent())
         return 0;
     if (renderer().isBR())
-        return toRenderBR(&renderer())->lineHeight(isFirstLineStyle());
+        return toRenderBR(renderer()).lineHeight(isFirstLineStyle());
     if (&parent()->renderer() == renderer().parent())
         return parent()->lineHeight();
     return toRenderBoxModelObject(renderer().parent())->lineHeight(isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
@@ -563,7 +563,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
     boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y());
     FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight()));
 
-    RenderCombineText* combinedText = styleToUse->hasTextCombine() && textRenderer().isCombineText() && toRenderCombineText(&textRenderer())->isCombined() ? toRenderCombineText(&textRenderer()) : 0;
+    RenderCombineText* combinedText = styleToUse->hasTextCombine() && textRenderer().isCombineText() && toRenderCombineText(textRenderer()).isCombined() ? &toRenderCombineText(textRenderer()) : 0;
 
     bool shouldRotate = !isHorizontal() && !combinedText;
     if (shouldRotate)
index ab3af32..bd78ba7 100644 (file)
@@ -214,7 +214,7 @@ void toInlineTextBox(const InlineTextBox*);
 
 inline RenderText& InlineTextBox::textRenderer() const
 {
-    return *toRenderText(&renderer());
+    return toRenderText(renderer());
 }
 
 void alignSelectionRectToDevicePixels(FloatRect&);
index dc4d832..92aa34b 100644 (file)
@@ -60,21 +60,20 @@ private:
     mutable int m_lineHeight;
 };
 
-
-inline RenderBR* toRenderBR(RenderObject* object)
+inline RenderBR& toRenderBR(RenderObject& object)
 { 
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isBR());
-    return static_cast<RenderBR*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isBR());
+    return static_cast<RenderBR&>(object);
 }
 
-inline const RenderBR* toRenderBR(const RenderObject* object)
-{ 
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isBR());
-    return static_cast<const RenderBR*>(object);
+inline const RenderBR& toRenderBR(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isBR());
+    return static_cast<const RenderBR&>(object);
 }
 
 // This will catch anyone doing an unnecessary cast.
-void toRenderBR(const RenderBR*);
+void toRenderBR(const RenderBR&);
 
 } // namespace WebCore
 
index a049082..107fb04 100644 (file)
@@ -5243,9 +5243,8 @@ bool RenderBlock::hitTestFloats(const HitTestRequest& request, HitTestResult& re
         return false;
 
     LayoutPoint adjustedLocation = accumulatedOffset;
-    if (isRenderView()) {
-        adjustedLocation += toLayoutSize(toRenderView(this)->frameView().scrollPosition());
-    }
+    if (isRenderView())
+        adjustedLocation += toLayoutSize(toRenderView(*this).frameView().scrollPosition());
 
     const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     FloatingObjectSetIterator begin = floatingObjectSet.begin();
@@ -6429,7 +6428,7 @@ void RenderBlock::computeInlinePreferredLogicalWidths(LayoutUnit& minLogicalWidt
                 }
 
                 if (t->style()->hasTextCombine() && t->isCombineText())
-                    toRenderCombineText(t)->combineText();
+                    toRenderCombineText(*t).combineText();
 
                 // Determine if we have a breakable character.  Pass in
                 // whether or not we should ignore any spaces at the front
index 54d8290..21340d7 100644 (file)
@@ -1365,6 +1365,12 @@ inline RenderBlock& toRenderBlock(RenderObject& object)
     return static_cast<RenderBlock&>(object);
 }
 
+inline const RenderBlock& toRenderBlock(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderBlock());
+    return static_cast<const RenderBlock&>(object);
+}
+
 inline RenderBlock* toRenderBlock(RenderObject* object)
 { 
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderBlock());
@@ -1379,6 +1385,7 @@ inline const RenderBlock* toRenderBlock(const RenderObject* object)
 
 // This will catch anyone doing an unnecessary cast.
 void toRenderBlock(const RenderBlock*);
+void toRenderBlock(const RenderBlock&);
 
 #ifndef NDEBUG
 // These structures are used by PODIntervalTree for debugging purposes.
index 3db99bf..fee874e 100644 (file)
@@ -2600,9 +2600,9 @@ void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
             m_block->setLogicalHeight(oldLogicalHeight + marginOffset);
             m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, lineInfo, width);
             m_block->setLogicalHeight(oldLogicalHeight);
-        } else if (object->isText() && object->style()->hasTextCombine() && object->isCombineText() && !toRenderCombineText(object)->isCombined()) {
-            toRenderCombineText(object)->combineText();
-            if (toRenderCombineText(object)->isCombined())
+        } else if (object->isText() && object->style()->hasTextCombine() && object->isCombineText() && !toRenderCombineText(*object).isCombined()) {
+            toRenderCombineText(*object).combineText();
+            if (toRenderCombineText(*object).isCombined())
                 continue;
         }
         resolver.increment();
@@ -2858,9 +2858,9 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
 #endif
 }
 
-static inline bool iteratorIsBeyondEndOfRenderCombineText(const InlineIterator& iter, RenderCombineText* renderer)
+static inline bool iteratorIsBeyondEndOfRenderCombineText(const InlineIterator& iter, RenderCombineText& renderer)
 {
-    return iter.m_obj == renderer && iter.m_pos >= renderer->textLength();
+    return iter.m_obj == &renderer && iter.m_pos >= renderer.textLength();
 }
 
 static inline void commitLineBreakAtCurrentWidth(LineWidth& width, InlineIterator& lBreak, RenderObject* object, unsigned offset = 0, int nextBreak = -1)
@@ -3114,7 +3114,7 @@ InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& re
                     currentCharacterIsWS = true;
                     ignoringSpaces = true;
                 }
-                if (toRenderListMarker(current.m_obj)->isInside())
+                if (toRenderListMarker(*current.m_obj).isInside())
                     width.addUncommittedWidth(replacedLogicalWidth);
             } else
                 width.addUncommittedWidth(replacedLogicalWidth);
@@ -3137,9 +3137,9 @@ InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& re
             if (autoWrap && !RenderStyle::autoWrap(lastWS) && ignoringSpaces)
                 commitLineBreakAtCurrentWidth(width, lBreak, current.m_obj);
 
-            if (t->style()->hasTextCombine() && current.m_obj->isCombineText() && !toRenderCombineText(current.m_obj)->isCombined()) {
-                RenderCombineText* combineRenderer = toRenderCombineText(current.m_obj);
-                combineRenderer->combineText();
+            if (t->style()->hasTextCombine() && current.m_obj->isCombineText() && !toRenderCombineText(*current.m_obj).isCombined()) {
+                RenderCombineText& combineRenderer = toRenderCombineText(*current.m_obj);
+                combineRenderer.combineText();
                 // The length of the renderer's text may have changed. Increment stale iterator positions
                 if (iteratorIsBeyondEndOfRenderCombineText(lBreak, combineRenderer)) {
                     ASSERT(iteratorIsBeyondEndOfRenderCombineText(resolver.position(), combineRenderer));
@@ -3476,7 +3476,7 @@ InlineIterator RenderBlock::LineBreaker::nextSegmentBreak(InlineBidiResolver& re
 
         if (!current.m_obj->isFloatingOrOutOfFlowPositioned()) {
             last = current.m_obj;
-            if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || toRenderListMarker(last)->isInside()))
+            if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || toRenderListMarker(*last).isInside()))
                 commitLineBreakAtCurrentWidth(width, lBreak, next);
         }
 
index 52dd6f1..5ff02ed 100644 (file)
@@ -1539,8 +1539,8 @@ bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer
                 if (drawingRootBackground) {
                     layerRenderer = &view();
 
-                    LayoutUnit rw = toRenderView(layerRenderer)->frameView().contentsWidth();
-                    LayoutUnit rh = toRenderView(layerRenderer)->frameView().contentsHeight();
+                    LayoutUnit rw = toRenderView(*layerRenderer).frameView().contentsWidth();
+                    LayoutUnit rh = toRenderView(*layerRenderer).frameView().contentsHeight();
 
                     rendererRect = LayoutRect(-layerRenderer->marginLeft(),
                         -layerRenderer->marginTop(),
index e6475c2..1d20e87 100644 (file)
@@ -712,6 +712,12 @@ inline RenderBox& toRenderBox(RenderObject& object)
     return static_cast<RenderBox&>(object);
 }
 
+inline const RenderBox& toRenderBox(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isBox());
+    return static_cast<const RenderBox&>(object);
+}
+
 inline RenderBox* toRenderBox(RenderObject* object)
 { 
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isBox());
@@ -726,6 +732,7 @@ inline const RenderBox* toRenderBox(const RenderObject* object)
 
 // This will catch anyone doing an unnecessary cast.
 void toRenderBox(const RenderBox*);
+void toRenderBox(const RenderBox&);
 
 inline RenderBox* RenderBox::previousSiblingBox() const
 {
index c3400b1..65dac7b 100644 (file)
@@ -531,10 +531,10 @@ void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo
 
     RenderBlock* containingBlock = this->containingBlock();
     RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(ExcludeSelf);
-    RenderBox* enclosingClippingBox = enclosingClippingLayer ? toRenderBox(&enclosingClippingLayer->renderer()) : &view();
+    RenderBox& enclosingClippingBox = enclosingClippingLayer ? toRenderBox(enclosingClippingLayer->renderer()) : view();
 
     LayoutRect containerContentRect;
-    if (!enclosingClippingLayer || (containingBlock != enclosingClippingBox))
+    if (!enclosingClippingLayer || (containingBlock != &enclosingClippingBox))
         containerContentRect = containingBlock->contentBoxRect();
     else {
         containerContentRect = containingBlock->layoutOverflowRect();
@@ -556,12 +556,12 @@ void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo
     containerContentRect.contract(minMargin);
 
     // Finally compute container rect relative to the scrolling ancestor.
-    FloatRect containerRectRelativeToScrollingAncestor = containingBlock->localToContainerQuad(FloatRect(containerContentRect), enclosingClippingBox).boundingBox();
+    FloatRect containerRectRelativeToScrollingAncestor = containingBlock->localToContainerQuad(FloatRect(containerContentRect), &enclosingClippingBox).boundingBox();
     if (enclosingClippingLayer) {
         FloatPoint containerLocationRelativeToScrollingAncestor = containerRectRelativeToScrollingAncestor.location() -
-            FloatSize(enclosingClippingBox->borderLeft() + enclosingClippingBox->paddingLeft(),
-            enclosingClippingBox->borderTop() + enclosingClippingBox->paddingTop());
-        if (enclosingClippingBox != containingBlock)
+            FloatSize(enclosingClippingBox.borderLeft() + enclosingClippingBox.paddingLeft(),
+            enclosingClippingBox.borderTop() + enclosingClippingBox.paddingTop());
+        if (&enclosingClippingBox != containingBlock)
             containerLocationRelativeToScrollingAncestor += enclosingClippingLayer->scrollOffset();
         containerRectRelativeToScrollingAncestor.setLocation(containerLocationRelativeToScrollingAncestor);
     }
@@ -575,11 +575,11 @@ void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo
 
     // FIXME: sucks to call localToContainerQuad again, but we can't just offset from the previously computed rect if there are transforms.
     // Map to the view to avoid including page scale factor.
-    FloatPoint stickyLocationRelativeToScrollingAncestor = flippedStickyBoxRect.location() + containingBlock->localToContainerQuad(FloatRect(FloatPoint(), containingBlock->size()), enclosingClippingBox).boundingBox().location();
+    FloatPoint stickyLocationRelativeToScrollingAncestor = flippedStickyBoxRect.location() + containingBlock->localToContainerQuad(FloatRect(FloatPoint(), containingBlock->size()), &enclosingClippingBox).boundingBox().location();
     if (enclosingClippingLayer) {
-        stickyLocationRelativeToScrollingAncestor -= FloatSize(enclosingClippingBox->borderLeft() + enclosingClippingBox->paddingLeft(),
-            enclosingClippingBox->borderTop() + enclosingClippingBox->paddingTop());
-        if (enclosingClippingBox != containingBlock)
+        stickyLocationRelativeToScrollingAncestor -= FloatSize(enclosingClippingBox.borderLeft() + enclosingClippingBox.paddingLeft(),
+            enclosingClippingBox.borderTop() + enclosingClippingBox.paddingTop());
+        if (&enclosingClippingBox != containingBlock)
             stickyLocationRelativeToScrollingAncestor += enclosingClippingLayer->scrollOffset();
     }
     // FIXME: For now, assume that |this| is not transformed.
@@ -614,9 +614,9 @@ LayoutSize RenderBoxModelObject::stickyPositionOffset() const
     ASSERT(hasLayer());
     RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(ExcludeSelf);
     if (enclosingClippingLayer) {
-        RenderBox* enclosingClippingBox = toRenderBox(&enclosingClippingLayer->renderer());
-        LayoutRect clipRect = enclosingClippingBox->overflowClipRect(LayoutPoint(), 0); // FIXME: make this work in regions.
-        constrainingRect = enclosingClippingBox->localToContainerQuad(FloatRect(clipRect), &view()).boundingBox();
+        RenderBox& enclosingClippingBox = toRenderBox(enclosingClippingLayer->renderer());
+        LayoutRect clipRect = enclosingClippingBox.overflowClipRect(LayoutPoint(), 0); // FIXME: make this work in regions.
+        constrainingRect = enclosingClippingBox.localToContainerQuad(FloatRect(clipRect), &view()).boundingBox();
 
         FloatPoint scrollOffset = FloatPoint() + enclosingClippingLayer->scrollOffset();
         constrainingRect.setLocation(scrollOffset);
index d00403b..37c01d6 100644 (file)
@@ -339,6 +339,18 @@ private:
                             Color, EBorderStyle, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
 };
 
+inline RenderBoxModelObject& toRenderBoxModelObject(RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isBoxModelObject());
+    return static_cast<RenderBoxModelObject&>(object);
+}
+
+inline const RenderBoxModelObject& toRenderBoxModelObject(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isBoxModelObject());
+    return static_cast<const RenderBoxModelObject&>(object);
+}
+
 inline RenderBoxModelObject* toRenderBoxModelObject(RenderObject* object)
 { 
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isBoxModelObject());
@@ -353,6 +365,7 @@ inline const RenderBoxModelObject* toRenderBoxModelObject(const RenderObject* ob
 
 // This will catch anyone doing an unnecessary cast.
 void toRenderBoxModelObject(const RenderBoxModelObject*);
+void toRenderBoxModelObject(const RenderBoxModelObject&);
 
 } // namespace WebCore
 
index ab77550..42313e9 100644 (file)
@@ -49,20 +49,19 @@ private:
     bool m_needsFontUpdate : 1;
 };
 
-inline RenderCombineText* toRenderCombineText(RenderObject* object)
+inline RenderCombineText& toRenderCombineText(RenderObject& object)
 { 
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isCombineText());
-    return static_cast<RenderCombineText*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isCombineText());
+    return static_cast<RenderCombineText&>(object);
 }
 
-inline const RenderCombineText* toRenderCombineText(const RenderObject* object)
+inline const RenderCombineText& toRenderCombineText(const RenderObject& object)
 { 
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isCombineText());
-    return static_cast<const RenderCombineText*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isCombineText());
+    return static_cast<const RenderCombineText&>(object);
 }
 
-// This will catch anyone doing an unnecessary cast.
-void toRenderCombineText(const RenderCombineText*);
+void toRenderCombineText(const RenderCombineText&);
 
 } // namespace WebCore
 
index 18f0adf..c7e3233 100644 (file)
@@ -557,22 +557,22 @@ LayoutPoint RenderFlowThread::adjustedPositionRelativeToOffsetParent(const Rende
         if (wasComputedRelativeToOtherRegion) {
             if (boxModelObject.isBox()) {
                 // Use borderBoxRectInRegion to account for variations such as percentage margins.
-                LayoutRect borderBoxRect = toRenderBox(&boxModelObject)->borderBoxRectInRegion(startRegion, RenderBox::DoNotCacheRenderBoxRegionInfo);
+                LayoutRect borderBoxRect = toRenderBox(boxModelObject).borderBoxRectInRegion(startRegion, RenderBox::DoNotCacheRenderBoxRegionInfo);
                 referencePoint.move(borderBoxRect.location().x(), 0);
             }
             
             // Get the logical top coordinate of the current object.
             LayoutUnit top = 0;
             if (boxModelObject.isRenderBlock())
-                top = toRenderBlock(&boxModelObject)->offsetFromLogicalTopOfFirstPage();
+                top = toRenderBlock(boxModelObject).offsetFromLogicalTopOfFirstPage();
             else {
                 if (boxModelObject.containingBlock())
                     top = boxModelObject.containingBlock()->offsetFromLogicalTopOfFirstPage();
                 
                 if (boxModelObject.isBox())
-                    top += toRenderBox(&boxModelObject)->topLeftLocation().y();
+                    top += toRenderBox(boxModelObject).topLeftLocation().y();
                 else if (boxModelObject.isRenderInline())
-                    top -= toRenderInline(&boxModelObject)->borderTop();
+                    top -= toRenderInline(boxModelObject).borderTop();
             }
             
             // Get the logical top of the region this object starts in
index 7e2be04..668ef55 100644 (file)
@@ -327,6 +327,18 @@ protected:
     bool m_layersToRegionMappingsDirty : 1;
 };
 
+inline RenderFlowThread& toRenderFlowThread(RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderFlowThread());
+    return static_cast<RenderFlowThread&>(object);
+}
+
+inline const RenderFlowThread& toRenderFlowThread(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderFlowThread());
+    return static_cast<const RenderFlowThread&>(object);
+}
+
 inline RenderFlowThread* toRenderFlowThread(RenderObject* object)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderFlowThread());
@@ -341,6 +353,7 @@ inline const RenderFlowThread* toRenderFlowThread(const RenderObject* object)
 
 // This will catch anyone doing an unnecessary cast.
 void toRenderFlowThread(const RenderFlowThread*);
+void toRenderFlowThread(const RenderFlowThread&);
 
 class CurrentRenderFlowThreadMaintainer {
     WTF_MAKE_NONCOPYABLE(CurrentRenderFlowThreadMaintainer);
index 578be1d..ef9c4f9 100644 (file)
@@ -116,6 +116,18 @@ private:
     friend class RenderImageScaleObserver;
 };
 
+inline RenderImage& toRenderImage(RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderImage());
+    return static_cast<RenderImage&>(object);
+}
+
+inline const RenderImage& toRenderImage(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderImage());
+    return static_cast<const RenderImage&>(object);
+}
+
 inline RenderImage* toRenderImage(RenderObject* object)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderImage());
@@ -130,6 +142,7 @@ inline const RenderImage* toRenderImage(const RenderObject* object)
 
 // This will catch anyone doing an unnecessary cast.
 void toRenderImage(const RenderImage*);
+void toRenderImage(const RenderImage&);
 
 } // namespace WebCore
 
index db9fccd..3c455c4 100644 (file)
@@ -194,6 +194,12 @@ inline RenderInline& toRenderInline(RenderObject& object)
     return static_cast<RenderInline&>(object);
 }
 
+inline const RenderInline& toRenderInline(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderInline());
+    return static_cast<const RenderInline&>(object);
+}
+
 inline RenderInline* toRenderInline(RenderObject* object)
 { 
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderInline());
@@ -208,6 +214,7 @@ inline const RenderInline* toRenderInline(const RenderObject* object)
 
 // This will catch anyone doing an unnecessary cast.
 void toRenderInline(const RenderInline*);
+void toRenderInline(const RenderInline&);
 
 } // namespace WebCore
 
index f56a015..dd8b37e 100644 (file)
@@ -1214,8 +1214,8 @@ bool RenderLayer::updateLayerPosition()
     LayoutPoint localPoint;
     LayoutSize inlineBoundingBoxOffset; // We don't put this into the RenderLayer x/y for inlines, so we need to subtract it out when done.
     if (renderer().isInline() && renderer().isRenderInline()) {
-        RenderInline* inlineFlow = toRenderInline(&renderer());
-        IntRect lineBox = inlineFlow->linesBoundingBox();
+        RenderInline& inlineFlow = toRenderInline(renderer());
+        IntRect lineBox = inlineFlow.linesBoundingBox();
         setSize(lineBox.size());
         inlineBoundingBoxOffset = toSize(lineBox.location());
         localPoint += inlineBoundingBoxOffset;
@@ -1254,7 +1254,7 @@ bool RenderLayer::updateLayerPosition()
         }
         
         if (renderer().isOutOfFlowPositioned() && positionedParent->renderer().isInFlowPositioned() && positionedParent->renderer().isRenderInline()) {
-            LayoutSize offset = toRenderInline(&positionedParent->renderer())->offsetForInFlowPositionedInline(toRenderBox(&renderer()));
+            LayoutSize offset = toRenderInline(positionedParent->renderer()).offsetForInFlowPositionedInline(&toRenderBox(renderer()));
             localPoint += offset;
         }
     } else if (parent()) {
@@ -1266,7 +1266,7 @@ bool RenderLayer::updateLayerPosition()
     
     bool positionOrOffsetChanged = false;
     if (renderer().isInFlowPositioned()) {
-        LayoutSize newOffset = toRenderBoxModelObject(&renderer())->offsetForInFlowPosition();
+        LayoutSize newOffset = toRenderBoxModelObject(renderer()).offsetForInFlowPosition();
         positionOrOffsetChanged = newOffset != m_offsetForInFlowPosition;
         m_offsetForInFlowPosition = newOffset;
         localPoint.move(m_offsetForInFlowPosition);
@@ -1292,7 +1292,7 @@ TransformationMatrix RenderLayer::perspectiveTransform() const
         return TransformationMatrix();
 
     // Maybe fetch the perspective from the backing?
-    const IntRect borderBox = toRenderBox(&renderer())->pixelSnappedBorderBoxRect();
+    const IntRect borderBox = toRenderBox(renderer()).pixelSnappedBorderBoxRect();
     const float boxWidth = borderBox.width();
     const float boxHeight = borderBox.height();
 
@@ -1317,7 +1317,7 @@ FloatPoint RenderLayer::perspectiveOrigin() const
     if (!renderer().hasTransform())
         return FloatPoint();
 
-    const LayoutRect borderBox = toRenderBox(&renderer())->borderBoxRect();
+    const LayoutRect borderBox = toRenderBox(renderer()).borderBoxRect();
     RenderStyle* style = renderer().style();
 
     return FloatPoint(floatValueForLength(style->perspectiveOriginX(), borderBox.width()),
@@ -1373,7 +1373,7 @@ static RenderLayer* parentLayerCrossFrame(const RenderLayer* layer)
 RenderLayer* RenderLayer::enclosingScrollableLayer() const
 {
     for (RenderLayer* nextLayer = parentLayerCrossFrame(this); nextLayer; nextLayer = parentLayerCrossFrame(nextLayer)) {
-        if (nextLayer->renderer().isBox() && toRenderBox(&nextLayer->renderer())->canBeScrolledAndHasScrollableArea())
+        if (nextLayer->renderer().isBox() && toRenderBox(nextLayer->renderer()).canBeScrolledAndHasScrollableArea())
             return nextLayer;
     }
 
@@ -1513,8 +1513,7 @@ void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect,
     }
     
     if (parentLayer->isRootLayer()) {
-        RenderView* view = toRenderView(&parentLayer->renderer());
-        view->repaintViewRectangle(parentLayerRect, immediate);
+        toRenderView(parentLayer->renderer()).repaintViewRectangle(parentLayerRect, immediate);
         return;
     }
     
@@ -1668,8 +1667,8 @@ static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLaye
         // We have to break up the transformed extent across our columns.
         // Split our box up into the actual fragment boxes that render in the columns/pages and unite those together to
         // get our true bounding box.
-        RenderFlowThread* enclosingFlowThread = toRenderFlowThread(&paginationLayer->renderer());
-        result = enclosingFlowThread->fragmentsBoundingBox(result);
+        RenderFlowThread& enclosingFlowThread = toRenderFlowThread(paginationLayer->renderer());
+        result = enclosingFlowThread.fragmentsBoundingBox(result);
         
         LayoutPoint rootLayerDelta;
         paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta);
@@ -2864,7 +2863,7 @@ bool RenderLayer::scrollsOverflow() const
     if (!renderer().isBox())
         return false;
 
-    return toRenderBox(&renderer())->scrollsOverflow();
+    return toRenderBox(renderer()).scrollsOverflow();
 }
 
 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar)
@@ -3120,7 +3119,7 @@ void RenderLayer::updateScrollbarsAfterLayout()
                 m_inOverflowRelayout = true;
                 renderer().setNeedsLayout(true, MarkOnlyThis);
                 if (renderer().isRenderBlock()) {
-                    RenderBlock& block = *toRenderBlock(&renderer());
+                    RenderBlock& block = toRenderBlock(renderer());
                     block.scrollbarsChanged(autoHorizontalScrollBarChanged, autoVerticalScrollBarChanged);
                     block.layoutBlock(true);
                 } else
@@ -4010,8 +4009,8 @@ void RenderLayer::collectFragments(LayerFragments& fragments, const RenderLayer*
 
     // Tell the flow thread to collect the fragments. We pass enough information to create a minimal number of fragments based off the pages/columns
     // that intersect the actual dirtyRect as well as the pages/columns that intersect our layer's bounding box.
-    RenderFlowThread* enclosingFlowThread = toRenderFlowThread(&enclosingPaginationLayer()->renderer());
-    enclosingFlowThread->collectLayerFragments(fragments, layerBoundingBoxInFlowThread, dirtyRectInFlowThread);
+    RenderFlowThread& enclosingFlowThread = toRenderFlowThread(enclosingPaginationLayer()->renderer());
+    enclosingFlowThread.collectLayerFragments(fragments, layerBoundingBoxInFlowThread, dirtyRectInFlowThread);
     
     if (fragments.isEmpty())
         return;
@@ -4251,29 +4250,29 @@ void RenderLayer::paintPaginatedChildLayer(RenderLayer* childLayer, GraphicsCont
 void RenderLayer::paintChildLayerIntoColumns(RenderLayer* childLayer, GraphicsContext* context, const LayerPaintingInfo& paintingInfo,
     PaintLayerFlags paintFlags, const Vector<RenderLayer*>& columnLayers, size_t colIndex)
 {
-    RenderBlock* columnBlock = toRenderBlock(&columnLayers[colIndex]->renderer());
+    RenderBlock& columnBlock = toRenderBlock(columnLayers[colIndex]->renderer());
 
-    ASSERT(columnBlock && columnBlock->hasColumns());
-    if (!columnBlock || !columnBlock->hasColumns())
+    ASSERT(columnBlock.hasColumns());
+    if (!columnBlock.hasColumns())
         return;
     
     LayoutPoint layerOffset;
     // FIXME: It looks suspicious to call convertToLayerCoords here
     // as canUseConvertToLayerCoords is true for this layer.
-    columnBlock->layer()->convertToLayerCoords(paintingInfo.rootLayer, layerOffset);
+    columnBlock.layer()->convertToLayerCoords(paintingInfo.rootLayer, layerOffset);
     
-    bool isHorizontal = columnBlock->style()->isHorizontalWritingMode();
+    bool isHorizontal = columnBlock.style()->isHorizontalWritingMode();
 
-    ColumnInfo* colInfo = columnBlock->columnInfo();
-    unsigned colCount = columnBlock->columnCount(colInfo);
-    LayoutUnit currLogicalTopOffset = columnBlock->initialBlockOffsetForPainting();
-    LayoutUnit blockDelta = columnBlock->blockDeltaForPaintingNextColumn();
+    ColumnInfo* colInfo = columnBlock.columnInfo();
+    unsigned colCount = columnBlock.columnCount(colInfo);
+    LayoutUnit currLogicalTopOffset = columnBlock.initialBlockOffsetForPainting();
+    LayoutUnit blockDelta = columnBlock.blockDeltaForPaintingNextColumn();
     for (unsigned i = 0; i < colCount; i++) {
         // For each rect, we clip to the rect, and then we adjust our coords.
-        LayoutRect colRect = columnBlock->columnRectAt(colInfo, i);
-        columnBlock->flipForWritingMode(colRect);
+        LayoutRect colRect = columnBlock.columnRectAt(colInfo, i);
+        columnBlock.flipForWritingMode(colRect);
 
-        LayoutUnit logicalLeftOffset = (isHorizontal ? colRect.x() : colRect.y()) - columnBlock->logicalLeftOffsetForContent();
+        LayoutUnit logicalLeftOffset = (isHorizontal ? colRect.x() : colRect.y()) - columnBlock.logicalLeftOffsetForContent();
         LayoutSize offset = isHorizontal ? LayoutSize(logicalLeftOffset, currLogicalTopOffset) : LayoutSize(currLogicalTopOffset, logicalLeftOffset);
         colRect.moveBy(layerOffset);
         
@@ -4345,7 +4344,7 @@ bool RenderLayer::hitTest(const HitTestRequest& request, const HitTestLocation&
 
     renderer().document().updateLayout();
     
-    LayoutRect hitTestArea = isOutOfFlowRenderFlowThread() ? toRenderFlowThread(&renderer())->borderBoxRect() : renderer().view().documentRect();
+    LayoutRect hitTestArea = isOutOfFlowRenderFlowThread() ? toRenderFlowThread(renderer()).borderBoxRect() : renderer().view().documentRect();
     if (!request.ignoreClipping())
         hitTestArea.intersect(frameVisibleRect(renderer()));
 
@@ -4355,7 +4354,7 @@ bool RenderLayer::hitTest(const HitTestRequest& request, const HitTestLocation&
         // return ourselves. We do this so mouse events continue getting delivered after a drag has 
         // exited the WebView, and so hit testing over a scrollbar hits the content document.
         if (!request.isChildFrameHitTest() && (request.active() || request.release()) && isRootLayer()) {
-            renderer().updateHitTestResult(result, toRenderView(&renderer())->flipForWritingMode(hitTestLocation.point()));
+            renderer().updateHitTestResult(result, toRenderView(renderer()).flipForWritingMode(hitTestLocation.point()));
             insideLayer = this;
         }
     }
@@ -4812,28 +4811,28 @@ RenderLayer* RenderLayer::hitTestChildLayerColumns(RenderLayer* childLayer, Rend
                                                    const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const HitTestingTransformState* transformState, double* zOffset,
                                                    const Vector<RenderLayer*>& columnLayers, size_t columnIndex)
 {
-    RenderBlock* columnBlock = toRenderBlock(&columnLayers[columnIndex]->renderer());
+    RenderBlock& columnBlock = toRenderBlock(columnLayers[columnIndex]->renderer());
 
-    ASSERT(columnBlock && columnBlock->hasColumns());
-    if (!columnBlock || !columnBlock->hasColumns())
+    ASSERT(columnBlock.hasColumns());
+    if (!columnBlock.hasColumns())
         return 0;
 
     LayoutPoint layerOffset;
-    columnBlock->layer()->convertToLayerCoords(rootLayer, layerOffset);
+    columnBlock.layer()->convertToLayerCoords(rootLayer, layerOffset);
 
-    ColumnInfo* colInfo = columnBlock->columnInfo();
-    int colCount = columnBlock->columnCount(colInfo);
+    ColumnInfo* colInfo = columnBlock.columnInfo();
+    int colCount = columnBlock.columnCount(colInfo);
 
     // We have to go backwards from the last column to the first.
-    bool isHorizontal = columnBlock->style()->isHorizontalWritingMode();
-    LayoutUnit logicalLeft = columnBlock->logicalLeftOffsetForContent();
-    LayoutUnit currLogicalTopOffset = columnBlock->initialBlockOffsetForPainting();
-    LayoutUnit blockDelta = columnBlock->blockDeltaForPaintingNextColumn();
+    bool isHorizontal = columnBlock.style()->isHorizontalWritingMode();
+    LayoutUnit logicalLeft = columnBlock.logicalLeftOffsetForContent();
+    LayoutUnit currLogicalTopOffset = columnBlock.initialBlockOffsetForPainting();
+    LayoutUnit blockDelta = columnBlock.blockDeltaForPaintingNextColumn();
     currLogicalTopOffset += colCount * blockDelta;
     for (int i = colCount - 1; i >= 0; i--) {
         // For each rect, we clip to the rect, and then we adjust our coords.
-        LayoutRect colRect = columnBlock->columnRectAt(colInfo, i);
-        columnBlock->flipForWritingMode(colRect);
+        LayoutRect colRect = columnBlock.columnRectAt(colInfo, i);
+        columnBlock.flipForWritingMode(colRect);
         LayoutUnit currLogicalLeftOffset = (isHorizontal ? colRect.x() : colRect.y()) - logicalLeft;
         currLogicalTopOffset -= blockDelta;
 
@@ -4982,7 +4981,7 @@ void RenderLayer::calculateClipRects(const ClipRectsContext& clipRectsContext, C
             offset -= renderer().view().frameView().scrollOffsetForFixedPosition();
         
         if (renderer().hasOverflowClip()) {
-            ClipRect newOverflowClip = toRenderBox(&renderer())->overflowClipRectForChildLayers(offset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy);
+            ClipRect newOverflowClip = toRenderBox(renderer()).overflowClipRectForChildLayers(offset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy);
             if (renderer().style()->hasBorderRadius())
                 newOverflowClip.setHasRadius(true);
             clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRects.overflowClipRect()));
@@ -4990,7 +4989,7 @@ void RenderLayer::calculateClipRects(const ClipRectsContext& clipRectsContext, C
                 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects.posClipRect()));
         }
         if (renderer().hasClip()) {
-            LayoutRect newPosClip = toRenderBox(&renderer())->clipRect(offset, clipRectsContext.region);
+            LayoutRect newPosClip = toRenderBox(renderer()).clipRect(offset, clipRectsContext.region);
             clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipRect()));
             clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.overflowClipRect()));
             clipRects.setFixedClipRect(intersection(newPosClip, clipRects.fixedClipRect()));
@@ -5069,14 +5068,14 @@ void RenderLayer::calculateRects(const ClipRectsContext& clipRectsContext, const
     if (renderer().hasClipOrOverflowClip()) {
         // This layer establishes a clip of some kind.
         if (renderer().hasOverflowClip() && (this != clipRectsContext.rootLayer || clipRectsContext.respectOverflowClip == RespectOverflowClip)) {
-            foregroundRect.intersect(toRenderBox(&renderer())->overflowClipRect(offset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy));
+            foregroundRect.intersect(toRenderBox(renderer()).overflowClipRect(offset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy));
             if (renderer().style()->hasBorderRadius())
                 foregroundRect.setHasRadius(true);
         }
 
         if (renderer().hasClip()) {
             // Clip applies to *us* as well, so go ahead and update the damageRect.
-            LayoutRect newPosClip = toRenderBox(&renderer())->clipRect(offset, clipRectsContext.region);
+            LayoutRect newPosClip = toRenderBox(renderer()).clipRect(offset, clipRectsContext.region);
             backgroundRect.intersect(newPosClip);
             foregroundRect.intersect(newPosClip);
             outlineRect.intersect(newPosClip);
@@ -5172,9 +5171,9 @@ void RenderLayer::repaintBlockSelectionGaps()
     LayoutRect rect = m_blockSelectionGapsBounds;
     rect.move(-scrolledContentOffset());
     if (renderer().hasOverflowClip() && !usesCompositedScrolling())
-        rect.intersect(toRenderBox(&renderer())->overflowClipRect(LayoutPoint(), 0)); // FIXME: Regions not accounted for.
+        rect.intersect(toRenderBox(renderer()).overflowClipRect(LayoutPoint(), 0)); // FIXME: Regions not accounted for.
     if (renderer().hasClip())
-        rect.intersect(toRenderBox(&renderer())->clipRect(LayoutPoint(), 0)); // FIXME: Regions not accounted for.
+        rect.intersect(toRenderBox(renderer()).clipRect(LayoutPoint(), 0)); // FIXME: Regions not accounted for.
     if (!rect.isEmpty())
         renderer().repaintRectangle(rect);
 }
@@ -5214,7 +5213,7 @@ LayoutRect RenderLayer::localBoundingBox(CalculateLayerBoundsFlags flags) const
     // floats.
     LayoutRect result;
     if (renderer().isInline() && renderer().isRenderInline())
-        result = toRenderInline(&renderer())->linesVisualOverflowBoundingBox();
+        result = toRenderInline(renderer()).linesVisualOverflowBoundingBox();
     else if (renderer().isTableRow()) {
         // Our bounding box is just the union of all of our cells' border/overflow rects.
         for (RenderObject* child = renderer().firstChild(); child; child = child->nextSibling()) {
@@ -5260,8 +5259,8 @@ LayoutRect RenderLayer::boundingBox(const RenderLayer* ancestorLayer, CalculateL
         convertToLayerCoords(enclosingPaginationLayer(), offsetWithinPaginationLayer);        
         result.moveBy(offsetWithinPaginationLayer);
 
-        RenderFlowThread* enclosingFlowThread = toRenderFlowThread(&enclosingPaginationLayer()->renderer());
-        result = enclosingFlowThread->fragmentsBoundingBox(result);
+        RenderFlowThread& enclosingFlowThread = toRenderFlowThread(enclosingPaginationLayer()->renderer());
+        result = enclosingFlowThread.fragmentsBoundingBox(result);
         
         LayoutPoint delta;
         if (offsetFromRoot)
@@ -5304,7 +5303,7 @@ LayoutRect RenderLayer::calculateLayerBounds(const RenderLayer* ancestorLayer, c
     LayoutRect boundingBoxRect = localBoundingBox(flags);
 
     if (renderer().isBox())
-        toRenderBox(&renderer())->flipForWritingMode(boundingBoxRect);
+        toRenderBox(renderer()).flipForWritingMode(boundingBoxRect);
     else
         renderer().containingBlock()->flipForWritingMode(boundingBoxRect);
 
@@ -5606,7 +5605,7 @@ void RenderLayer::dirtyZOrderLists()
 #if USE(ACCELERATED_COMPOSITING)
     if (!renderer().documentBeingDestroyed()) {
         if (renderer().isOutOfFlowRenderFlowThread())
-            toRenderFlowThread(&renderer())->setNeedsLayerToRegionMappingsUpdate();
+            toRenderFlowThread(renderer()).setNeedsLayerToRegionMappingsUpdate();
         compositor().setCompositingLayersNeedRebuild();
         if (acceleratedCompositingForOverflowScrollEnabled())
             compositor().setShouldReevaluateCompositingAfterLayout();
@@ -5632,7 +5631,7 @@ void RenderLayer::dirtyNormalFlowList()
 #if USE(ACCELERATED_COMPOSITING)
     if (!renderer().documentBeingDestroyed()) {
         if (renderer().isOutOfFlowRenderFlowThread())
-            toRenderFlowThread(&renderer())->setNeedsLayerToRegionMappingsUpdate();
+            toRenderFlowThread(renderer()).setNeedsLayerToRegionMappingsUpdate();
         compositor().setCompositingLayersNeedRebuild();
         if (acceleratedCompositingForOverflowScrollEnabled())
             compositor().setShouldReevaluateCompositingAfterLayout();
index c0794c9..2bd8256 100644 (file)
@@ -324,7 +324,7 @@ public:
     String name() const;
 
     RenderLayerModelObject& renderer() const { return m_renderer; }
-    RenderBox* renderBox() const { return renderer().isBox() ? toRenderBox(&renderer()) : 0; }
+    RenderBox* renderBox() const { return renderer().isBox() ? &toRenderBox(renderer()) : 0; }
     RenderLayer* parent() const { return m_parent; }
     RenderLayer* previousSibling() const { return m_previous; }
     RenderLayer* nextSibling() const { return m_next; }
@@ -909,7 +909,7 @@ private:
     void setFirstChild(RenderLayer* first) { m_first = first; }
     void setLastChild(RenderLayer* last) { m_last = last; }
 
-    LayoutPoint renderBoxLocation() const { return renderer().isBox() ? toRenderBox(&renderer())->location() : LayoutPoint(); }
+    LayoutPoint renderBoxLocation() const { return renderer().isBox() ? toRenderBox(renderer()).location() : LayoutPoint(); }
 
     void collectLayers(bool includeHiddenLayers, CollectLayersBehavior, OwnPtr<Vector<RenderLayer*> >&, OwnPtr<Vector<RenderLayer*> >&);
 
index e19422b..97591d6 100644 (file)
@@ -78,7 +78,7 @@ namespace WebCore {
 using namespace HTMLNames;
 
 static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle*);
-static IntRect clipBox(RenderBox* renderer);
+static IntRect clipBox(RenderBox& renderer);
 
 static inline bool isAcceleratedCanvas(RenderObject* renderer)
 {
@@ -359,7 +359,7 @@ void RenderLayerBacking::updateTransform(const RenderStyle* style)
     // baked into it, and we don't want that.
     TransformationMatrix t;
     if (m_owningLayer->hasTransform()) {
-        style->applyTransform(t, toRenderBox(&renderer())->pixelSnappedBorderBoxRect().size(), RenderStyle::ExcludeTransformOrigin);
+        style->applyTransform(t, toRenderBox(renderer()).pixelSnappedBorderBoxRect().size(), RenderStyle::ExcludeTransformOrigin);
         makeMatrixRenderable(t, compositor().canRender3DTransforms());
     }
     
@@ -574,14 +574,14 @@ bool RenderLayerBacking::updateGraphicsLayerConfiguration()
     return layerConfigChanged;
 }
 
-static IntRect clipBox(RenderBox* renderer)
+static IntRect clipBox(RenderBox& renderer)
 {
     LayoutRect result = PaintInfo::infiniteRect();
-    if (renderer->hasOverflowClip())
-        result = renderer->overflowClipRect(LayoutPoint(), 0); // FIXME: Incorrect for CSS regions.
+    if (renderer.hasOverflowClip())
+        result = renderer.overflowClipRect(LayoutPoint(), 0); // FIXME: Incorrect for CSS regions.
 
-    if (renderer->hasClip())
-        result.intersect(renderer->clipRect(LayoutPoint(), 0)); // FIXME: Incorrect for CSS regions.
+    if (renderer.hasClip())
+        result.intersect(renderer.clipRect(LayoutPoint(), 0)); // FIXME: Incorrect for CSS regions.
 
     return pixelSnappedIntRect(result);
 }
@@ -649,7 +649,7 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
     if (compAncestor && compAncestor->backing()->hasClippingLayer()) {
         // If the compositing ancestor has a layer to clip children, we parent in that, and therefore
         // position relative to it.
-        IntRect clippingBox = clipBox(toRenderBox(&compAncestor->renderer()));
+        IntRect clippingBox = clipBox(toRenderBox(compAncestor->renderer()));
         graphicsLayerParentLocation = clippingBox.location();
     } else if (compAncestor)
         graphicsLayerParentLocation = ancestorCompositingBounds.location();
@@ -657,9 +657,9 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
         graphicsLayerParentLocation = renderer().view().documentRect().location();
 
     if (compAncestor && compAncestor->needsCompositedScrolling()) {
-        RenderBox* renderBox = toRenderBox(&compAncestor->renderer());
+        RenderBox& renderBox = toRenderBox(compAncestor->renderer());
         IntSize scrollOffset = compAncestor->scrolledContentOffset();
-        IntPoint scrollOrigin(renderBox->borderLeft(), renderBox->borderTop());
+        IntPoint scrollOrigin(renderBox.borderLeft(), renderBox.borderTop());
         graphicsLayerParentLocation = scrollOrigin - scrollOffset;
     }
     
@@ -703,7 +703,7 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
     // If we have a layer that clips children, position it.
     IntRect clippingBox;
     if (GraphicsLayer* clipLayer = clippingLayer()) {
-        clippingBox = clipBox(toRenderBox(&renderer()));
+        clippingBox = clipBox(toRenderBox(renderer()));
         clipLayer->setPosition(FloatPoint(clippingBox.location() - localCompositingBounds.location()));
         clipLayer->setSize(clippingBox.size());
         clipLayer->setOffsetFromRenderer(toIntSize(clippingBox.location()));
@@ -716,7 +716,7 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
     }
     
     if (m_owningLayer->hasTransform()) {
-        const IntRect borderBox = toRenderBox(&renderer())->pixelSnappedBorderBoxRect();
+        const IntRect borderBox = toRenderBox(renderer()).pixelSnappedBorderBoxRect();
 
         // Get layout bounds in the coords of compAncestor to match relativeCompositingBounds.
         IntRect layerBounds(delta, borderBox.size());
@@ -797,8 +797,8 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
 
     if (m_scrollingLayer) {
         ASSERT(m_scrollingContentsLayer);
-        RenderBox* renderBox = toRenderBox(&renderer());
-        IntRect paddingBox(renderBox->borderLeft(), renderBox->borderTop(), renderBox->width() - renderBox->borderLeft() - renderBox->borderRight(), renderBox->height() - renderBox->borderTop() - renderBox->borderBottom());
+        RenderBox& renderBox = toRenderBox(renderer());
+        IntRect paddingBox(renderBox.borderLeft(), renderBox.borderTop(), renderBox.width() - renderBox.borderLeft() - renderBox.borderRight(), renderBox.height() - renderBox.borderTop() - renderBox.borderBottom());
         IntSize scrollOffset = m_owningLayer->scrollOffset();
 
         m_scrollingLayer->setPosition(FloatPoint(paddingBox.location() - localCompositingBounds.location()));
@@ -929,7 +929,7 @@ void RenderLayerBacking::resetContentsRect()
     
     LayoutRect contentsClippingRect;
     if (renderer().isBox())
-        contentsClippingRect = toRenderBox(&renderer())->contentBoxRect();
+        contentsClippingRect = toRenderBox(renderer()).contentBoxRect();
 
     contentsClippingRect.move(contentOffsetInCompostingLayer());
     m_graphicsLayer->setContentsClippingRect(pixelSnappedIntRect(contentsClippingRect));
@@ -1454,7 +1454,7 @@ void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleCo
     IntSize tileSize;
 
     RefPtr<Image> image = style->backgroundLayers()->image()->cachedImage()->image();
-    toRenderBox(&renderer())->getGeometryForBackgroundImage(&m_owningLayer->renderer(), destRect, phase, tileSize);
+    toRenderBox(renderer()).getGeometryForBackgroundImage(&m_owningLayer->renderer(), destRect, phase, tileSize);
     m_graphicsLayer->setContentsTileSize(tileSize);
     m_graphicsLayer->setContentsTilePhase(phase);
     m_graphicsLayer->setContentsRect(destRect);
@@ -1661,7 +1661,7 @@ bool RenderLayerBacking::containsPaintedContent(bool isSimpleContainer) const
     // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely,
     // and set background color on the layer in that case, instead of allocating backing store and painting.
 #if ENABLE(VIDEO)
-    if (renderer().isVideo() && toRenderVideo(&renderer())->shouldDisplayVideo())
+    if (renderer().isVideo() && toRenderVideo(renderer()).shouldDisplayVideo())
         return m_owningLayer->hasBoxDecorationsOrBackground();
 #endif
 #if PLATFORM(MAC) && USE(CA)
@@ -1680,12 +1680,12 @@ bool RenderLayerBacking::isDirectlyCompositedImage() const
     if (!renderer().isImage() || m_owningLayer->hasBoxDecorationsOrBackground() || renderer().hasClip())
         return false;
 
-    RenderImage* imageRenderer = toRenderImage(&renderer());
-    if (CachedImage* cachedImage = imageRenderer->cachedImage()) {
+    RenderImage& imageRenderer = toRenderImage(renderer());
+    if (CachedImage* cachedImage = imageRenderer.cachedImage()) {
         if (!cachedImage->hasImage())
             return false;
 
-        Image* image = cachedImage->imageForRenderer(imageRenderer);
+        Image* image = cachedImage->imageForRenderer(&imageRenderer);
         if (!image->isBitmapImage())
             return false;
 
@@ -1725,13 +1725,13 @@ void RenderLayerBacking::contentChanged(ContentChangeType changeType)
 void RenderLayerBacking::updateImageContents()
 {
     ASSERT(renderer().isImage());
-    RenderImage* imageRenderer = toRenderImage(&renderer());
+    RenderImage& imageRenderer = toRenderImage(renderer());
 
-    CachedImage* cachedImage = imageRenderer->cachedImage();
+    CachedImage* cachedImage = imageRenderer.cachedImage();
     if (!cachedImage)
         return;
 
-    Image* image = cachedImage->imageForRenderer(imageRenderer);
+    Image* image = cachedImage->imageForRenderer(&imageRenderer);
     if (!image)
         return;
 
@@ -1742,7 +1742,7 @@ void RenderLayerBacking::updateImageContents()
     // This is a no-op if the layer doesn't have an inner layer for the image.
     m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox()));
 
-    LayoutRect contentsClippingRect = imageRenderer->contentBoxRect();
+    LayoutRect contentsClippingRect = imageRenderer.contentBoxRect();
     contentsClippingRect.move(contentOffsetInCompostingLayer());
     m_graphicsLayer->setContentsClippingRect(pixelSnappedIntRect(contentsClippingRect));
 
@@ -1793,13 +1793,12 @@ LayoutRect RenderLayerBacking::contentsBox() const
     if (!renderer().isBox())
         return LayoutRect();
 
-    RenderBox& renderBox = *toRenderBox(&renderer());
+    RenderBox& renderBox = toRenderBox(renderer());
     LayoutRect contentsRect;
 #if ENABLE(VIDEO)
-    if (renderBox.isVideo()) {
-        RenderVideo* videoRenderer = toRenderVideo(&renderBox);
-        contentsRect = videoRenderer->videoBox();
-    } else
+    if (renderBox.isVideo())
+        contentsRect = toRenderVideo(renderBox).videoBox();
+    else
 #endif
     if (renderBox.isRenderReplaced()) {
         RenderReplaced& renderReplaced = *toRenderReplaced(&renderBox);
@@ -1811,15 +1810,15 @@ LayoutRect RenderLayerBacking::contentsBox() const
     return contentsRect;
 }
 
-static LayoutRect backgroundRectForBox(const RenderBox* box)
+static LayoutRect backgroundRectForBox(const RenderBox& box)
 {
-    switch (box->style()->backgroundClip()) {
+    switch (box.style()->backgroundClip()) {
     case BorderFillBox:
-        return box->borderBoxRect();
+        return box.borderBoxRect();
     case PaddingFillBox:
-        return box->paddingBoxRect();
+        return box.paddingBoxRect();
     case ContentFillBox:
-        return box->contentBoxRect();
+        return box.contentBoxRect();
     case TextFillBox:
         break;
     }
@@ -1833,7 +1832,7 @@ IntRect RenderLayerBacking::backgroundBox() const
     if (!renderer().isBox())
         return IntRect();
 
-    LayoutRect backgroundBox = backgroundRectForBox(toRenderBox(&renderer()));
+    LayoutRect backgroundBox = backgroundRectForBox(toRenderBox(renderer()));
     backgroundBox.move(contentOffsetInCompostingLayer());
     return pixelSnappedIntRect(backgroundBox);
 }
@@ -2136,7 +2135,7 @@ bool RenderLayerBacking::startAnimation(double timeOffset, const Animation* anim
 
     bool didAnimate = false;
     
-    if (hasTransform && m_graphicsLayer->addAnimation(transformVector, toRenderBox(&renderer())->pixelSnappedBorderBoxRect().size(), anim, keyframes.animationName(), timeOffset))
+    if (hasTransform && m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer()).pixelSnappedBorderBoxRect().size(), anim, keyframes.animationName(), timeOffset))
         didAnimate = true;
 
     if (hasOpacity && m_graphicsLayer->addAnimation(opacityVector, IntSize(), anim, keyframes.animationName(), timeOffset))
@@ -2187,7 +2186,7 @@ bool RenderLayerBacking::startTransition(double timeOffset, CSSPropertyID proper
             KeyframeValueList transformVector(AnimatedPropertyWebkitTransform);
             transformVector.insert(TransformAnimationValue::create(0, fromStyle->transform()));
             transformVector.insert(TransformAnimationValue::create(1, toStyle->transform()));
-            if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(&renderer())->pixelSnappedBorderBoxRect().size(), transformAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitTransform), timeOffset)) {
+            if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer()).pixelSnappedBorderBoxRect().size(), transformAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitTransform), timeOffset)) {
                 // To ensure that the correct transform is visible when the animation ends, also set the final transform.
                 updateTransform(toStyle);
                 didAnimate = true;
index aaad9f7..a76e93d 100644 (file)
@@ -735,8 +735,7 @@ bool RenderLayerCompositor::updateBacking(RenderLayer* layer, CompositingChangeR
 #if ENABLE(VIDEO)
     if (layerChanged && layer->renderer().isVideo()) {
         // If it's a video, give the media player a chance to hook up to the layer.
-        RenderVideo* video = toRenderVideo(&layer->renderer());
-        video->acceleratedRenderingStateChanged();
+        toRenderVideo(layer->renderer()).acceleratedRenderingStateChanged();
     }
 #endif
 
@@ -1168,12 +1167,12 @@ void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer)
 }
 
 #if ENABLE(VIDEO)
-bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideoo) const
+bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo& video) const
 {
     if (!m_hasAcceleratedCompositing)
         return false;
 
-    return o->supportsAcceleratedRendering();
+    return video.supportsAcceleratedRendering();
 }
 #endif
 
@@ -2074,8 +2073,8 @@ bool RenderLayerCompositor::requiresCompositingForVideo(RenderObject* renderer)
         return false;
 #if ENABLE(VIDEO)
     if (renderer->isVideo()) {
-        RenderVideo* video = toRenderVideo(renderer);
-        return (video->requiresImmediateCompositing() || video->shouldDisplayVideo()) && canAccelerateVideoRendering(video);
+        RenderVideo& video = toRenderVideo(*renderer);
+        return (video.requiresImmediateCompositing() || video.shouldDisplayVideo()) && canAccelerateVideoRendering(video);
     }
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     else if (renderer->isRenderPart()) {
@@ -3118,15 +3117,15 @@ StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo
 
     LayoutRect viewportRect = m_renderView.frameView().viewportConstrainedVisibleContentRect();
 
-    RenderBoxModelObject* renderer = toRenderBoxModelObject(&layer->renderer());
+    RenderBoxModelObject& renderer = toRenderBoxModelObject(layer->renderer());
 
     StickyPositionViewportConstraints constraints;
-    renderer->computeStickyPositionConstraints(constraints, viewportRect);
+    renderer.computeStickyPositionConstraints(constraints, viewportRect);
 
     GraphicsLayer* graphicsLayer = layer->backing()->graphicsLayer();
 
     constraints.setLayerPositionAtLastLayout(graphicsLayer->position());
-    constraints.setStickyOffsetAtLastLayout(renderer->stickyPositionOffset());
+    constraints.setStickyOffsetAtLastLayout(renderer.stickyPositionOffset());
 
     return constraints;
 }
index 065c0f8..c168ebf 100644 (file)
@@ -214,7 +214,7 @@ public:
     
 #if ENABLE(VIDEO)
     // Use by RenderVideo to ask if it should try to use accelerated compositing.
-    bool canAccelerateVideoRendering(RenderVideo*) const;
+    bool canAccelerateVideoRendering(RenderVideo&) const;
 #endif
 
     // Walk the tree looking for layers with 3d transforms. Useful in case you need
index 1255498..64d8549 100644 (file)
@@ -86,20 +86,19 @@ private:
     RenderListItem* m_listItem;
 };
 
-inline RenderListMarker* toRenderListMarker(RenderObject* object)
+inline RenderListMarker& toRenderListMarker(RenderObject& object)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isListMarker());
-    return static_cast<RenderListMarker*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isListMarker());
+    return static_cast<RenderListMarker&>(object);
 }
 
-inline const RenderListMarker* toRenderListMarker(const RenderObject* object)
+inline const RenderListMarker& toRenderListMarker(const RenderObject& object)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isListMarker());
-    return static_cast<const RenderListMarker*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isListMarker());
+    return static_cast<const RenderListMarker&>(object);
 }
 
-// This will catch anyone doing an unnecessary cast.
-void toRenderListMarker(const RenderListMarker*);
+void toRenderListMarker(const RenderListMarker&);
 
 } // namespace WebCore
 
index 951f83f..c1fed0a 100644 (file)
@@ -1354,7 +1354,7 @@ void RenderObject::repaintUsingContainer(const RenderLayerModelObject* repaintCo
     }
 #else
     if (repaintContainer->isRenderView())
-        toRenderView(repaintContainer)->repaintViewRectangle(r, immediate);
+        toRenderView(*repaintContainer).repaintViewRectangle(r, immediate);
 #endif
 }
 
@@ -2306,7 +2306,7 @@ bool RenderObject::isRooted(RenderView** view) const
         return false;
 
     if (view)
-        *view = const_cast<RenderView*>(toRenderView(o));
+        *view = &const_cast<RenderView&>(toRenderView(*o));
 
     return true;
 }
@@ -2740,7 +2740,7 @@ bool RenderObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitT
 void RenderObject::scheduleRelayout()
 {
     if (isRenderView())
-        toRenderView(this)->frameView().scheduleRelayout();
+        toRenderView(*this).frameView().scheduleRelayout();
     else {
         if (isRooted())
             view().frameView().scheduleRelayoutOfSubtree(this);
index adc2f0d..0623b9e 100644 (file)
@@ -136,7 +136,7 @@ RenderRubyRun* RenderRubyBase::rubyRun() const
     ASSERT(parent());
     ASSERT(parent()->isRubyRun());
 
-    return toRenderRubyRun(parent());
+    return &toRenderRubyRun(*parent());
 }
 
 ETextAlign RenderRubyBase::textAlignmentForLine(bool /* endsWithSoftBreak */) const
index bbae7a5..98a0d8f 100644 (file)
@@ -78,6 +78,18 @@ private:
     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
 };
 
+inline RenderRubyRun& toRenderRubyRun(RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRubyRun());
+    return static_cast<RenderRubyRun&>(object);
+}
+
+inline const RenderRubyRun& toRenderRubyRun(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRubyRun());
+    return static_cast<const RenderRubyRun&>(object);
+}
+
 inline RenderRubyRun* toRenderRubyRun(RenderObject* object)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRubyRun());
@@ -91,6 +103,7 @@ inline const RenderRubyRun* toRenderRubyRun(const RenderObject* object)
 }
 
 void toRenderRubyRun(const RenderRubyRun*);
+void toRenderRubyRun(const RenderRubyRun&);
 
 } // namespace WebCore
 
index 19d6fd6..15ee7df 100644 (file)
@@ -721,9 +721,9 @@ LayoutRect RenderText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay
 ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len, float xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
 {
     if (style()->hasTextCombine() && isCombineText()) {
-        const RenderCombineText* combineText = toRenderCombineText(this);
-        if (combineText->isCombined())
-            return combineText->combinedTextWidth(f);
+        const RenderCombineText& combineText = toRenderCombineText(*this);
+        if (combineText.isCombined())
+            return combineText.combinedTextWidth(f);
     }
 
     if (f.isFixedPitch() && !f.isSmallCaps() && m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
index a9a2365..e18c1a1 100644 (file)
@@ -198,6 +198,18 @@ private:
     InlineTextBox* m_lastTextBox;
 };
 
+inline RenderText& toRenderText(RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isText());
+    return static_cast<RenderText&>(object);
+}
+
+inline const RenderText& toRenderText(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isText());
+    return static_cast<const RenderText&>(object);
+}
+
 inline RenderText* toRenderText(RenderObject* object)
 { 
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isText());
@@ -212,6 +224,7 @@ inline const RenderText* toRenderText(const RenderObject* object)
 
 // This will catch anyone doing an unnecessary cast.
 void toRenderText(const RenderText*);
+void toRenderText(const RenderText&);
 
 #ifdef NDEBUG
 inline void RenderText::checkConsistency() const
index a96cc70..f45682c 100644 (file)
@@ -247,14 +247,14 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
     if (o.isText()) {
         // FIXME: Would be better to dump the bounding box x and y rather than the first run's x and y, but that would involve updating
         // many test results.
-        const RenderText& text = *toRenderText(&o);
+        const RenderText& text = toRenderText(o);
         IntRect linesBox = text.linesBoundingBox();
         r = IntRect(text.firstRunX(), text.firstRunY(), linesBox.width(), linesBox.height());
         if (adjustForTableCells && !text.firstTextBox())
             adjustForTableCells = false;
     } else if (o.isRenderInline()) {
         // FIXME: Would be better not to just dump 0, 0 as the x and y here.
-        const RenderInline& inlineFlow = *toRenderInline(&o);
+        const RenderInline& inlineFlow = toRenderInline(o);
         r = IntRect(0, 0, inlineFlow.linesBoundingBox().width(), inlineFlow.linesBoundingBox().height());
         adjustForTableCells = false;
     } else if (o.isTableCell()) {
@@ -264,7 +264,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
         const RenderTableCell& cell = *toRenderTableCell(&o);
         r = LayoutRect(cell.x(), cell.y() + cell.intrinsicPaddingBefore(), cell.width(), cell.height() - cell.intrinsicPaddingBefore() - cell.intrinsicPaddingAfter());
     } else if (o.isBox())
-        r = toRenderBox(&o)->frameRect();
+        r = toRenderBox(o).frameRect();
 
     // FIXME: Temporary in order to ensure compatibility with existing layout test results.
     if (adjustForTableCells)
@@ -306,7 +306,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
         if (!o.isBoxModelObject())
             return;
 
-        const RenderBoxModelObject& box = *toRenderBoxModelObject(&o);
+        const RenderBoxModelObject& box = toRenderBoxModelObject(o);
         if (box.borderTop() || box.borderRight() || box.borderBottom() || box.borderLeft()) {
             ts << " [border:";
 
@@ -411,7 +411,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
 #endif
 
     if (o.isListMarker()) {
-        String text = toRenderListMarker(&o)->text();
+        String text = toRenderListMarker(o).text();
         if (!text.isEmpty()) {
             if (text.length() != 1)
                 text = quoteAndEscapeNonPrintables(text);
@@ -557,7 +557,7 @@ void write(TextStream& ts, const RenderObject& o, int indent, RenderAsTextBehavi
         return;
     }
     if (o.isSVGInlineText()) {
-        writeSVGInlineText(ts, *toRenderSVGInlineText(&o), indent);
+        writeSVGInlineText(ts, toRenderSVGInlineText(o), indent);
         return;
     }
     if (o.isSVGImage()) {
@@ -572,7 +572,7 @@ void write(TextStream& ts, const RenderObject& o, int indent, RenderAsTextBehavi
     ts << "\n";
 
     if (o.isText() && !o.isBR()) {
-        const RenderText& text = *toRenderText(&o);
+        const RenderText& text = toRenderText(o);
         for (InlineTextBox* box = text.firstTextBox(); box; box = box->nextTextBox()) {
             writeIndent(ts, indent + 1);
             writeTextRun(ts, text, *box);
@@ -690,13 +690,13 @@ static void writeRenderRegionList(const RenderRegionList& flowThreadRegionList,
     }
 }
 
-static void writeRenderNamedFlowThreads(TextStream& ts, RenderView* renderView, const RenderLayer* rootLayer,
+static void writeRenderNamedFlowThreads(TextStream& ts, RenderView& renderView, const RenderLayer* rootLayer,
                         const LayoutRect& paintRect, int indent, RenderAsTextBehavior behavior)
 {
-    if (!renderView->hasRenderNamedFlowThreads())
+    if (!renderView.hasRenderNamedFlowThreads())
         return;
 
-    const RenderNamedFlowThreadList* list = renderView->flowThreadController().renderNamedFlowThreadList();
+    const RenderNamedFlowThreadList* list = renderView.flowThreadController().renderNamedFlowThreadList();
 
     writeIndent(ts, indent);
     ts << "Flow Threads\n";
@@ -799,10 +799,8 @@ static void writeLayers(TextStream& ts, const RenderLayer* rootLayer, RenderLaye
     
     // Altough the RenderFlowThread requires a layer, it is not collected by its parent,
     // so we have to treat it as a special case.
-    if (l->renderer().isRenderView()) {
-        RenderView* renderView = toRenderView(&l->renderer());
-        writeRenderNamedFlowThreads(ts, renderView, rootLayer, paintDirtyRect, indent, behavior);
-    }
+    if (l->renderer().isRenderView())
+        writeRenderNamedFlowThreads(ts, toRenderView(l->renderer()), rootLayer, paintDirtyRect, indent, behavior);
 }
 
 static String nodePosition(Node* node)
index a5e3198..1a9128b 100644 (file)
@@ -90,14 +90,19 @@ private:
     LayoutSize m_cachedImageSize;
 };
 
-inline RenderVideo* toRenderVideo(RenderObject* object)
+inline RenderVideo& toRenderVideo(RenderObject& object)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isVideo());
-    return static_cast<RenderVideo*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isVideo());
+    return static_cast<RenderVideo&>(object);
 }
 
-// This will catch anyone doing an unnecessary cast.
-void toRenderVideo(const RenderVideo*);
+inline const RenderVideo& toRenderVideo(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isVideo());
+    return static_cast<const RenderVideo&>(object);
+}
+
+void toRenderVideo(const RenderVideo&);
 
 } // namespace WebCore
 
index f72af5d..79f1262 100644 (file)
@@ -348,20 +348,19 @@ private:
     bool m_selectionWasCaret;
 };
 
-inline RenderView* toRenderView(RenderObject* object)
+inline RenderView& toRenderView(RenderObject& object)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderView());
-    return static_cast<RenderView*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderView());
+    return static_cast<RenderView&>(object);
 }
 
-inline const RenderView* toRenderView(const RenderObject* object)
+inline const RenderView& toRenderView(const RenderObject& object)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderView());
-    return static_cast<const RenderView*>(object);
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderView());
+    return static_cast<const RenderView&>(object);
 }
 
-// This will catch anyone doing an unnecessary cast.
-void toRenderView(const RenderView*);
+void toRenderView(const RenderView&);
 
 // Stack-based class to assist with LayoutState push/pop
 class LayoutStateMaintainer {
index d60c051..8c9e6ae 100644 (file)
@@ -73,6 +73,12 @@ inline RenderSVGInlineText& toRenderSVGInlineText(RenderObject& object)
     return static_cast<RenderSVGInlineText&>(object);
 }
 
+inline const RenderSVGInlineText& toRenderSVGInlineText(const RenderObject& object)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(object.isSVGInlineText());
+    return static_cast<const RenderSVGInlineText&>(object);
+}
+
 inline RenderSVGInlineText* toRenderSVGInlineText(RenderObject* object)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isSVGInlineText());
index 2cd9aa3..d940469 100644 (file)
@@ -339,10 +339,10 @@ static inline void updateFontInAllDescendants(RenderObject* start, SVGTextLayout
     for (RenderObject* descendant = start; descendant; descendant = descendant->nextInPreOrder(start)) {
         if (!descendant->isSVGInlineText())
             continue;
-        RenderSVGInlineText* text = toRenderSVGInlineText(descendant);
-        text->updateScaledFont();
+        RenderSVGInlineText& text = toRenderSVGInlineText(*descendant);
+        text.updateScaledFont();
         if (builder)
-            builder->rebuildMetricsForTextRenderer(text);
+            builder->rebuildMetricsForTextRenderer(&text);
     }
 }