Commit 9c962752 authored by darin@apple.com's avatar darin@apple.com

2009-07-30 Darin Adler <darin@apple.com>

        Reviewed by David Levin.

        Use checked casts for render tree
        https://bugs.webkit.org/show_bug.cgi?id=23522

        Next step: Add new toRenderWidget cast and use it everywhere.

        Use checked casts in all the places that were using static_cast
        but there is a checked cast available.

        * accessibility/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::stringValue):
        (WebCore::AccessibilityRenderObject::widget):
        (WebCore::AccessibilityRenderObject::widgetForAttachmentView):
        (WebCore::AccessibilityRenderObject::visiblePositionForPoint):
        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
        (getPangoLayoutForAtk):
        * dom/Document.cpp:
        (WebCore::widgetForNode):
        (WebCore::Document::setFocusedNode):
        * html/HTMLEmbedElement.cpp:
        (WebCore::findWidgetRenderer):
        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::defaultEventHandler):
        * html/HTMLObjectElement.cpp:
        (WebCore::HTMLObjectElement::renderWidgetForJSBindings):
        * html/HTMLPlugInElement.cpp:
        (WebCore::HTMLPlugInElement::defaultEventHandler):
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::loadSubframe):
        * loader/PluginDocument.cpp:
        (WebCore::PluginTokenizer::writeRawData):
        * page/EventHandler.cpp:
        (WebCore::EventHandler::hitTestResultAtPoint):
        (WebCore::subframeForTargetNode):
        (WebCore::EventHandler::handleWheelEvent):
        * page/Frame.cpp:
        (WebCore::isFrameElement):
        * page/PrintContext.cpp:
        (WebCore::PrintContext::computePageRects):
        * page/android/EventHandlerAndroid.cpp:
        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
        * page/chromium/EventHandlerChromium.cpp:
        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
        * page/chromium/FrameChromium.cpp:
        (WebCore::computePageRectsForFrame):
        * page/gtk/EventHandlerGtk.cpp:
        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
        * page/haiku/EventHandlerHaiku.cpp:
        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
        * page/mac/EventHandlerMac.mm:
        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
        (WebCore::EventHandler::passSubframeEventToSubframe):
        * page/win/FrameWin.cpp:
        (WebCore::computePageRectsForFrame):
        * page/wx/EventHandlerWx.cpp:
        (WebCore::EventHandler::passWidgetMouseDownEventToWidget):
        * platform/chromium/ClipboardChromium.cpp:
        (WebCore::getCachedImage):
        * platform/chromium/PasteboardChromium.cpp:
        (WebCore::Pasteboard::writeImage):
        * platform/gtk/PasteboardGtk.cpp:
        (WebCore::Pasteboard::writeImage):
        * platform/mac/PasteboardMac.mm:
        (WebCore::Pasteboard::writeImage):
        * platform/qt/ClipboardQt.cpp:
        (WebCore::getCachedImage):
        * platform/qt/PasteboardQt.cpp:
        (WebCore::Pasteboard::writeImage):
        * platform/win/ClipboardWin.cpp:
        (WebCore::getCachedImage):
        * platform/win/PasteboardWin.cpp:
        (WebCore::Pasteboard::writeImage):
        * rendering/InlineBox.h:
        (WebCore::InlineBox::boxModelObject):
        * rendering/RenderInline.cpp:
        (WebCore::RenderInline::splitInlines):
        (WebCore::RenderInline::addChildToContinuation):
        * rendering/RenderLayerBacking.cpp:
        (WebCore::RenderLayerBacking::updateImageContents):
        * rendering/TextControlInnerElements.cpp:
        (WebCore::RenderTextControlInnerBlock::positionForPoint):
        Use checked cast instead of static_cast.
        
        * rendering/RenderWidget.h: Added toRenderWidget.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@46592 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d6b8e53a
2009-07-30 Darin Adler <darin@apple.com>
Reviewed by David Levin.
Use checked casts for render tree
https://bugs.webkit.org/show_bug.cgi?id=23522
Next step: Add new toRenderWidget cast and use it everywhere.
Use checked casts in all the places that were using static_cast
but there is a checked cast available.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::stringValue):
(WebCore::AccessibilityRenderObject::widget):
(WebCore::AccessibilityRenderObject::widgetForAttachmentView):
(WebCore::AccessibilityRenderObject::visiblePositionForPoint):
* accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
(getPangoLayoutForAtk):
* dom/Document.cpp:
(WebCore::widgetForNode):
(WebCore::Document::setFocusedNode):
* html/HTMLEmbedElement.cpp:
(WebCore::findWidgetRenderer):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::defaultEventHandler):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::renderWidgetForJSBindings):
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::defaultEventHandler):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadSubframe):
* loader/PluginDocument.cpp:
(WebCore::PluginTokenizer::writeRawData):
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint):
(WebCore::subframeForTargetNode):
(WebCore::EventHandler::handleWheelEvent):
* page/Frame.cpp:
(WebCore::isFrameElement):
* page/PrintContext.cpp:
(WebCore::PrintContext::computePageRects):
* page/android/EventHandlerAndroid.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/chromium/EventHandlerChromium.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/chromium/FrameChromium.cpp:
(WebCore::computePageRectsForFrame):
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/haiku/EventHandlerHaiku.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
(WebCore::EventHandler::passSubframeEventToSubframe):
* page/win/FrameWin.cpp:
(WebCore::computePageRectsForFrame):
* page/wx/EventHandlerWx.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* platform/chromium/ClipboardChromium.cpp:
(WebCore::getCachedImage):
* platform/chromium/PasteboardChromium.cpp:
(WebCore::Pasteboard::writeImage):
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::writeImage):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::writeImage):
* platform/qt/ClipboardQt.cpp:
(WebCore::getCachedImage):
* platform/qt/PasteboardQt.cpp:
(WebCore::Pasteboard::writeImage):
* platform/win/ClipboardWin.cpp:
(WebCore::getCachedImage):
* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::writeImage):
* rendering/InlineBox.h:
(WebCore::InlineBox::boxModelObject):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::splitInlines):
(WebCore::RenderInline::addChildToContinuation):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateImageContents):
* rendering/TextControlInnerElements.cpp:
(WebCore::RenderTextControlInnerBlock::positionForPoint):
Use checked cast instead of static_cast.
* rendering/RenderWidget.h: Added toRenderWidget.
2009-07-30 Yong Li <yong.li@torchmobile.com>
Reviewed by George Staikos.
......
......@@ -775,7 +775,7 @@ String AccessibilityRenderObject::stringValue() const
return static_cast<RenderListMarker*>(m_renderer)->text();
if (m_renderer->isRenderButton())
return static_cast<RenderButton*>(m_renderer)->text();
return toRenderButton(m_renderer)->text();
if (isWebArea()) {
if (m_renderer->document()->frame())
......@@ -1603,8 +1603,7 @@ Widget* AccessibilityRenderObject::widget() const
{
if (!m_renderer->isWidget())
return 0;
return static_cast<RenderWidget*>(m_renderer)->widget();
return toRenderWidget(m_renderer)->widget();
}
AXObjectCache* AccessibilityRenderObject::axObjectCache() const
......@@ -1675,7 +1674,7 @@ Widget* AccessibilityRenderObject::widgetForAttachmentView() const
{
if (!isAttachment())
return 0;
return static_cast<RenderWidget*>(m_renderer)->widget();
return toRenderWidget(m_renderer)->widget();
}
FrameView* AccessibilityRenderObject::frameViewIfRenderView() const
......@@ -1880,7 +1879,7 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForPoint(const IntPoin
break;
// descend into widget (FRAME, IFRAME, OBJECT...)
Widget* widget = static_cast<RenderWidget*>(renderer)->widget();
Widget* widget = toRenderWidget(renderer)->widget();
if (!widget || !widget->isFrameView())
break;
Frame* frame = static_cast<FrameView*>(widget)->frame();
......
......@@ -564,7 +564,7 @@ static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
AccessibilityRenderObject* accObject = static_cast<AccessibilityRenderObject*>(coreObject);
if (!accObject)
return 0;
RenderText* renderText = static_cast<RenderText*>(accObject->renderer());
RenderText* renderText = toRenderText(accObject->renderer());
if (!renderText)
return 0;
......
......@@ -267,7 +267,7 @@ static Widget* widgetForNode(Node* focusedNode)
RenderObject* renderer = focusedNode->renderer();
if (!renderer || !renderer->isWidget())
return 0;
return static_cast<RenderWidget*>(renderer)->widget();
return toRenderWidget(renderer)->widget();
}
static bool acceptsEditingFocus(Node *node)
......@@ -2541,13 +2541,12 @@ bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode)
oldFocusedNode->setFocus(false);
// Dispatch a change event for text fields or textareas that have been edited
RenderObject* r = static_cast<RenderObject*>(oldFocusedNode.get()->renderer());
RenderObject* r = oldFocusedNode->renderer();
if (r && r->isTextControl() && toRenderTextControl(r)->isEdited()) {
oldFocusedNode->dispatchEvent(eventNames().changeEvent, true, false);
if ((r = static_cast<RenderObject*>(oldFocusedNode.get()->renderer()))) {
if (r->isTextControl())
toRenderTextControl(r)->setEdited(false);
}
r = oldFocusedNode->renderer();
if (r && r->isTextControl())
toRenderTextControl(r)->setEdited(false);
}
// Dispatch the blur event and let the node do any other blur related activities (important for text fields)
......
......@@ -61,7 +61,7 @@ static inline RenderWidget* findWidgetRenderer(const Node* n)
while (n && !n->hasTagName(objectTag));
if (n && n->renderer() && n->renderer()->isWidget())
return static_cast<RenderWidget*>(n->renderer());
return toRenderWidget(n->renderer());
return 0;
}
......
......@@ -1615,7 +1615,7 @@ void HTMLMediaElement::defaultEventHandler(Event* event)
if (!r || !r->isWidget())
return;
Widget* widget = static_cast<RenderWidget*>(r)->widget();
Widget* widget = toRenderWidget(r)->widget();
if (widget)
widget->handleEvent(event);
#else
......
......@@ -60,10 +60,10 @@ HTMLObjectElement::~HTMLObjectElement()
RenderWidget* HTMLObjectElement::renderWidgetForJSBindings() const
{
RenderWidget* renderWidget = (renderer() && renderer()->isWidget()) ? static_cast<RenderWidget*>(renderer()) : 0;
RenderWidget* renderWidget = (renderer() && renderer()->isWidget()) ? toRenderWidget(renderer()) : 0;
if (renderWidget && !renderWidget->widget()) {
document()->updateLayoutIgnorePendingStylesheets();
renderWidget = (renderer() && renderer()->isWidget()) ? static_cast<RenderWidget*>(renderer()) : 0;
renderWidget = (renderer() && renderer()->isWidget()) ? toRenderWidget(renderer()) : 0;
}
return renderWidget;
}
......
......@@ -177,9 +177,10 @@ void HTMLPlugInElement::defaultEventHandler(Event* event)
RenderObject* r = renderer();
if (!r || !r->isWidget())
return;
if (Widget* widget = static_cast<RenderWidget*>(r)->widget())
widget->handleEvent(event);
Widget* widget = toRenderWidget(r)->widget();
if (!widget)
return;
widget->handleEvent(event);
}
#if ENABLE(NETSCAPE_PLUGIN_API)
......
......@@ -464,7 +464,7 @@ Frame* FrameLoader::loadSubframe(HTMLFrameOwnerElement* ownerElement, const KURL
RenderObject* renderer = ownerElement->renderer();
FrameView* view = frame->view();
if (renderer && renderer->isWidget() && view)
static_cast<RenderWidget*>(renderer)->setWidget(view);
toRenderWidget(renderer)->setWidget(view);
checkCallImplicitClose();
......
......@@ -106,12 +106,12 @@ bool PluginTokenizer::writeRawData(const char*, int)
Settings* settings = frame->settings();
if (settings && settings->arePluginsEnabled()) {
m_doc->updateLayout();
if (RenderWidget* renderer = static_cast<RenderWidget*>(m_embedElement->renderer())) {
if (RenderWidget* renderer = toRenderWidget(m_embedElement->renderer())) {
frame->loader()->client()->redirectDataToPlugin(renderer->widget());
frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
}
finish();
}
}
......
......@@ -764,7 +764,7 @@ HitTestResult EventHandler::hitTestResultAtPoint(const IntPoint& point, bool all
Node* n = result.innerNode();
if (!result.isOverWidget() || !n || !n->renderer() || !n->renderer()->isWidget())
break;
RenderWidget* renderWidget = static_cast<RenderWidget*>(n->renderer());
RenderWidget* renderWidget = toRenderWidget(n->renderer());
Widget* widget = renderWidget->widget();
if (!widget || !widget->isFrameView())
break;
......@@ -914,7 +914,7 @@ Frame* subframeForTargetNode(Node* node)
if (!renderer || !renderer->isWidget())
return 0;
Widget* widget = static_cast<RenderWidget*>(renderer)->widget();
Widget* widget = toRenderWidget(renderer)->widget();
if (!widget || !widget->isFrameView())
return 0;
......@@ -1771,8 +1771,7 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e)
RenderObject* target = node->renderer();
if (isOverWidget && target && target->isWidget()) {
Widget* widget = static_cast<RenderWidget*>(target)->widget();
Widget* widget = toRenderWidget(target)->widget();
if (widget && passWheelEventToWidget(e, widget)) {
e.accept();
return true;
......
......@@ -559,7 +559,7 @@ static bool isFrameElement(const Node *n)
RenderObject *renderer = n->renderer();
if (!renderer || !renderer->isWidget())
return false;
Widget* widget = static_cast<RenderWidget*>(renderer)->widget();
Widget* widget = toRenderWidget(renderer)->widget();
return widget && widget->isFrameView();
}
......
......@@ -53,7 +53,7 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer())
return;
RenderView* root = static_cast<RenderView*>(m_frame->document()->renderer());
RenderView* root = toRenderView(m_frame->document()->renderer());
if (!root) {
LOG_ERROR("document to be printed has no renderer");
......
......@@ -58,8 +58,7 @@ bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
if (!target || !target->isWidget())
return false;
return passMouseDownEventToWidget(static_cast<RenderWidget*>(target)->widget());
return passMouseDownEventToWidget(toRenderWidget(target)->widget());
}
bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
......
......@@ -105,8 +105,7 @@ bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
// Figure out which view to send the event to.
if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetNode()->renderer()->isWidget())
return false;
return passMouseDownEventToWidget(static_cast<RenderWidget*>(event.targetNode()->renderer())->widget());
return passMouseDownEventToWidget(toRenderWidget(event.targetNode()->renderer())->widget());
}
bool EventHandler::passMouseDownEventToWidget(Widget* widget)
......
......@@ -46,7 +46,7 @@ void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float head
if (!frame->document() || !frame->view() || !frame->document()->renderer())
return;
RenderView* root = static_cast<RenderView*>(frame->document()->renderer());
RenderView* root = toRenderView(frame->document()->renderer());
if (!root) {
LOG_ERROR("document to be printed has no renderer");
......
......@@ -62,8 +62,7 @@ bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
if (!target || !target->isWidget())
return false;
return passMouseDownEventToWidget(static_cast<RenderWidget*>(target)->widget());
return passMouseDownEventToWidget(toRenderWidget(target)->widget());
}
bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
......
......@@ -89,8 +89,7 @@ bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
if (!target || !target->isWidget())
return false;
return passMouseDownEventToWidget(static_cast<RenderWidget*>(target)->widget());
return passMouseDownEventToWidget(toRenderWidget(target)->widget());
}
bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
......
......@@ -232,7 +232,7 @@ bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
// just pass currentEvent down to the widget, we don't want to call it for events that
// don't correspond to Cocoa events. The mousedown/ups will have already been passed on as
// part of the pressed/released handling.
return passMouseDownEventToWidget(static_cast<RenderWidget*>(target)->widget());
return passMouseDownEventToWidget(toRenderWidget(target)->widget());
}
bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
......@@ -449,10 +449,10 @@ bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& eve
RenderObject* renderer = node->renderer();
if (!renderer || !renderer->isWidget())
return false;
Widget* widget = static_cast<RenderWidget*>(renderer)->widget();
Widget* widget = toRenderWidget(renderer)->widget();
if (!widget || !widget->isFrameView())
return false;
if (!passWidgetMouseDownEventToWidget(static_cast<RenderWidget*>(renderer)))
if (!passWidgetMouseDownEventToWidget(toRenderWidget(renderer)))
return false;
m_mouseDownWasInSubframe = true;
return true;
......
......@@ -47,7 +47,7 @@ void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float head
if (!frame->document() || !frame->view() || !frame->document()->renderer())
return;
RenderView* root = static_cast<RenderView*>(frame->document()->renderer());
RenderView* root = toRenderView(frame->document()->renderer());
if (!root) {
LOG_ERROR("document to be printed has no renderer");
......
......@@ -62,7 +62,7 @@ bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR
if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetNode()->renderer()->isWidget())
return false;
return passMouseDownEventToWidget(static_cast<RenderWidget*>(event.targetNode()->renderer())->widget());
return passMouseDownEventToWidget(toRenderWidget(event.targetNode()->renderer())->widget());
}
bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
......
......@@ -252,7 +252,7 @@ static CachedImage* getCachedImage(Element* element)
if (!renderer || !renderer->isImage())
return 0;
RenderImage* image = static_cast<RenderImage*>(renderer);
RenderImage* image = toRenderImage(renderer);
if (image->cachedImage() && !image->cachedImage()->errorOccurred())
return image->cachedImage();
......
......@@ -104,8 +104,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String& title)
ASSERT(node);
ASSERT(node->renderer());
ASSERT(node->renderer()->isImage());
RenderImage* renderer = static_cast<RenderImage*>(node->renderer());
CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
RenderImage* renderer = toRenderImage(node->renderer());
CachedImage* cachedImage = renderer->cachedImage();
ASSERT(cachedImage);
Image* image = cachedImage->image();
ASSERT(image);
......
......@@ -131,8 +131,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD);
ASSERT(node && node->renderer() && node->renderer()->isImage());
RenderImage* renderer = static_cast<RenderImage*>(node->renderer());
CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
RenderImage* renderer = toRenderImage(node->renderer());
CachedImage* cachedImage = renderer->cachedImage();
ASSERT(cachedImage);
Image* image = cachedImage->image();
ASSERT(image);
......
......@@ -279,7 +279,7 @@ void Pasteboard::writeImage(Node* node, const KURL& url, const String& title)
ASSERT(node->renderer() && node->renderer()->isImage());
RenderImage* renderer = toRenderImage(node->renderer());
CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
CachedImage* cachedImage = renderer->cachedImage();
ASSERT(cachedImage);
if (cachedImage->errorOccurred())
......
......@@ -229,7 +229,7 @@ static CachedImage* getCachedImage(Element* element)
if (!renderer || !renderer->isImage())
return 0;
RenderImage* image = static_cast<RenderImage*>(renderer);
RenderImage* image = toRenderImage(renderer);
if (image->cachedImage() && !image->cachedImage()->errorOccurred())
return image->cachedImage();
......
......@@ -138,7 +138,7 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
ASSERT(node && node->renderer() && node->renderer()->isImage());
#ifndef QT_NO_CLIPBOARD
CachedImage* cachedImage = static_cast<RenderImage*>(node->renderer())->cachedImage();
CachedImage* cachedImage = toRenderImage(node->renderer())->cachedImage();
ASSERT(cachedImage);
Image* image = cachedImage->image();
......
......@@ -643,7 +643,7 @@ static CachedImage* getCachedImage(Element* element)
if (!renderer || !renderer->isImage())
return 0;
RenderImage* image = static_cast<RenderImage*>(renderer);
RenderImage* image = toRenderImage(renderer);
if (image->cachedImage() && !image->cachedImage()->errorOccurred())
return image->cachedImage();
......
......@@ -188,8 +188,8 @@ void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame)
void Pasteboard::writeImage(Node* node, const KURL&, const String&)
{
ASSERT(node && node->renderer() && node->renderer()->isImage());
RenderImage* renderer = static_cast<RenderImage*>(node->renderer());
CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
RenderImage* renderer = toRenderImage(node->renderer());
CachedImage* cachedImage = renderer->cachedImage();
ASSERT(cachedImage);
Image* image = cachedImage->image();
ASSERT(image);
......
......@@ -246,7 +246,7 @@ public:
RenderBoxModelObject* boxModelObject() const
{
if (!m_renderer->isText())
return static_cast<RenderBoxModelObject*>(m_renderer);
return toRenderBoxModelObject(m_renderer);
return 0;
}
......
......@@ -258,7 +258,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
// We have been reparented and are now under the fromBlock. We need
// to walk up our inline parent chain until we hit the containing block.
// Once we hit the containing block we're done.
RenderBoxModelObject* curr = static_cast<RenderBoxModelObject*>(parent());
RenderBoxModelObject* curr = toRenderBoxModelObject(parent());
RenderBoxModelObject* currChild = this;
// FIXME: Because splitting is O(n^2) as tags nest pathologically, we cap the depth at which we're willing to clone.
......@@ -302,7 +302,7 @@ void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
// Keep walking up the chain.
currChild = curr;
curr = static_cast<RenderBoxModelObject*>(curr->parent());
curr = toRenderBoxModelObject(curr->parent());
splitDepth++;
}
......@@ -384,7 +384,7 @@ void RenderInline::addChildToContinuation(RenderObject* newChild, RenderObject*
ASSERT(!beforeChild || beforeChild->parent()->isRenderBlock() || beforeChild->parent()->isRenderInline());
RenderBoxModelObject* beforeChildParent = 0;
if (beforeChild)
beforeChildParent = static_cast<RenderBoxModelObject*>(beforeChild->parent());
beforeChildParent = toRenderBoxModelObject(beforeChild->parent());
else {
RenderBoxModelObject* cont = nextContinuation(flow);
if (cont)
......
......@@ -607,7 +607,7 @@ void RenderLayerBacking::rendererContentChanged()
void RenderLayerBacking::updateImageContents()
{
ASSERT(renderer()->isImage());
RenderImage* imageRenderer = static_cast<RenderImage*>(renderer());
RenderImage* imageRenderer = toRenderImage(renderer());
CachedImage* cachedImage = imageRenderer->cachedImage();
if (!cachedImage)
......
......@@ -69,6 +69,21 @@ private:
int m_refCount;
};
inline RenderWidget* toRenderWidget(RenderObject* o)
{
ASSERT(!o || o->isWidget());
return static_cast<RenderWidget*>(o);
}
inline const RenderWidget* toRenderWidget(const RenderObject* o)
{
ASSERT(!o || o->isWidget());
return static_cast<const RenderWidget*>(o);
}
// This will catch anyone doing an unnecessary cast.
void toRenderWidget(const RenderWidget*);
} // namespace WebCore
#endif // RenderWidget_h
......@@ -69,7 +69,7 @@ VisiblePosition RenderTextControlInnerBlock::positionForPoint(const IntPoint& po
// Multiline text controls have the scroll on shadowAncestorNode, so we need to take that
// into account here.
if (m_multiLine) {
RenderTextControl* renderer = static_cast<RenderTextControl*>(node()->shadowAncestorNode()->renderer());
RenderTextControl* renderer = toRenderTextControl(node()->shadowAncestorNode()->renderer());
if (renderer->hasOverflowClip())
renderer->layer()->addScrolledContentOffset(contentsX, contentsY);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment