Commit b6cb2561 authored by darin@apple.com's avatar darin@apple.com

2009-08-05 Darin Adler <darin@apple.com>

        Reviewed by David Levin.

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

        Last patch. Makes all the casts of RenderObject use checked
        casts instead of using static_cast directly.

        * accessibility/AccessibilityListBox.cpp:
        (WebCore::AccessibilityListBox::visibleChildren):
        (WebCore::AccessibilityListBox::doAccessibilityHitTest):
        * accessibility/AccessibilityListBoxOption.cpp:
        (WebCore::AccessibilityListBoxOption::elementRect):
        * accessibility/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::textUnderElement):
        (WebCore::AccessibilityRenderObject::stringValue):
        (WebCore::AccessibilityRenderObject::titleUIElement):
        (WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
        * accessibility/AccessibilitySlider.cpp:
        (WebCore::AccessibilitySliderThumb::elementRect):
        * dom/InputElement.cpp:
        (WebCore::InputElement::updatePlaceholderVisibility):
        * dom/SelectElement.cpp:
        (WebCore::SelectElement::scrollToSelection):
        (WebCore::SelectElement::recalcStyle):
        (WebCore::SelectElement::setRecalcListItems):
        (WebCore::SelectElement::menuListDefaultEventHandler):
        (WebCore::SelectElement::listBoxDefaultEventHandler):
        * editing/BreakBlockquoteCommand.cpp:
        (WebCore::BreakBlockquoteCommand::doApply):
        * html/HTMLAppletElement.cpp:
        (WebCore::HTMLAppletElement::renderWidgetForJSBindings):
        * html/HTMLCanvasElement.cpp:
        (WebCore::HTMLCanvasElement::reset):
        * html/HTMLEmbedElement.cpp:
        (WebCore::HTMLEmbedElement::updateWidget):
        * html/HTMLFrameElementBase.cpp:
        (WebCore::HTMLFrameElementBase::attach):
        * html/HTMLFrameSetElement.cpp:
        (WebCore::HTMLFrameSetElement::defaultEventHandler):
        * html/HTMLIFrameElement.cpp:
        (WebCore::HTMLIFrameElement::attach):
        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::defaultEventHandler):
        (WebCore::HTMLInputElement::addSearchResult):
        (WebCore::HTMLInputElement::onSearch):
        * html/HTMLLIElement.cpp:
        (WebCore::HTMLLIElement::parseMappedAttribute):
        (WebCore::HTMLLIElement::attach):
        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::setReadyState):
        (WebCore::HTMLMediaElement::mediaPlayerDurationChanged):
        (WebCore::HTMLMediaElement::mediaPlayerSizeChanged):
        (WebCore::HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated):
        (WebCore::HTMLMediaElement::mediaPlayerGraphicsLayer):
        (WebCore::HTMLMediaElement::defaultEventHandler):
        (WebCore::HTMLMediaElement::finishParsingChildren):
        * html/HTMLOListElement.cpp:
        (WebCore::HTMLOListElement::parseMappedAttribute):
        * html/HTMLObjectElement.cpp:
        (WebCore::HTMLObjectElement::updateWidget):
        * html/HTMLTextAreaElement.cpp:
        (WebCore::HTMLTextAreaElement::defaultEventHandler):
        * page/DragController.cpp:
        (WebCore::DragController::concludeEditDrag):
        * page/EventHandler.cpp:
        (WebCore::EventHandler::selectCursor):
        (WebCore::EventHandler::capsLockStateMayHaveChanged):
        * page/Frame.cpp:
        (WebCore::Frame::ownerRenderer):
        * page/FrameView.cpp:
        (WebCore::FrameView::detachCustomScrollbars):
        * page/wince/FrameWince.cpp:
        (WebCore::computePageRectsForFrame):
        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::placeBoxesHorizontally):
        * rendering/MediaControlElements.cpp:
        (WebCore::MediaControlTimelineElement::defaultEventHandler):
        * rendering/RenderBlockLineLayout.cpp:
        (WebCore::RenderBlock::findNextLineBreak):
        * rendering/RenderCounter.cpp:
        (WebCore::planCounter):
        * rendering/RenderFrameSet.cpp:
        (WebCore::RenderFrameSet::computeEdgeInfo):
        (WebCore::RenderFrameSet::setIsResizing):
        * rendering/RenderLayerBacking.cpp:
        (WebCore::RenderLayerBacking::contentsBox):
        * rendering/RenderLayerCompositor.cpp:
        (WebCore::RenderLayerCompositor::updateBacking):
        (WebCore::RenderLayerCompositor::requiresCompositingForVideo):
        * rendering/RenderListItem.cpp:
        (WebCore::previousListItem):
        (WebCore::RenderListItem::explicitValueChanged):
        * rendering/RenderObject.cpp:
        (WebCore::updateListMarkerNumbers):
        * rendering/RenderObjectChildList.cpp:
        (WebCore::updateListMarkerNumbers):
        (WebCore::invalidateCountersInContainer):
        * rendering/RenderScrollbarTheme.cpp:
        (WebCore::RenderScrollbarTheme::minimumThumbLength):
        (WebCore::RenderScrollbarTheme::backButtonRect):
        (WebCore::RenderScrollbarTheme::forwardButtonRect):
        (WebCore::RenderScrollbarTheme::trackRect):
        (WebCore::RenderScrollbarTheme::constrainTrackRectToTrackPieces):
        (WebCore::RenderScrollbarTheme::paintScrollbarBackground):
        (WebCore::RenderScrollbarTheme::paintTrackBackground):
        (WebCore::RenderScrollbarTheme::paintTrackPiece):
        (WebCore::RenderScrollbarTheme::paintButton):
        (WebCore::RenderScrollbarTheme::paintThumb):
        * rendering/RenderSlider.cpp:
        (WebCore::SliderThumbElement::defaultEventHandler):
        * rendering/RenderThemeChromiumMac.mm:
        (WebCore::RenderThemeChromiumMac::paintSliderThumb):
        (WebCore::RenderThemeChromiumMac::paintMediaSliderTrack):
        * rendering/RenderThemeChromiumWin.cpp:
        (WebCore::RenderThemeChromiumWin::determineSliderThumbState):
        * rendering/RenderThemeMac.mm:
        (WebCore::RenderThemeMac::paintSliderThumb):
        * rendering/RenderThemeSafari.cpp:
        (WebCore::RenderThemeSafari::paintSliderThumb):
        * rendering/RenderThemeWin.cpp:
        (WebCore::RenderThemeWin::determineSliderThumbState):
        * rendering/SVGCharacterLayoutInfo.cpp:
        (WebCore::SVGCharacterLayoutInfo::addLayoutInformation):
        * rendering/SVGRootInlineBox.cpp:
        (WebCore::findSVGRootObject):
        * rendering/TextControlInnerElements.cpp:
        (WebCore::RenderTextControlInnerBlock::nodeAtPoint):
        (WebCore::SearchFieldResultsButtonElement::defaultEventHandler):
        * svg/SVGImageElement.cpp:
        (WebCore::SVGImageElement::attach):
        * svg/SVGMarkerElement.cpp:
        (WebCore::SVGMarkerElement::canvasResource):
        * svg/SVGTextContentElement.cpp:
        (WebCore::rootInlineBoxForTextContentElement):
        * wml/WMLInputElement.cpp:
        (WebCore::WMLInputElement::defaultEventHandler):
        Use checked casts.

        * rendering/RenderApplet.h:
        * rendering/RenderCounter.h:
        * rendering/RenderFieldset.h:
        * rendering/RenderFileUploadControl.h:
        * rendering/RenderFrame.h:
        * rendering/RenderFrameSet.h:
        * rendering/RenderHTMLCanvas.h:
        * rendering/RenderListBox.h:
        * rendering/RenderListItem.h:
        * rendering/RenderListMarker.h:
        * rendering/RenderMedia.h:
        * rendering/RenderMenuList.h:
        * rendering/RenderPart.h:
        * rendering/RenderPartObject.h:
        * rendering/RenderPath.h:
        * rendering/RenderSVGContainer.h:
        * rendering/RenderSVGRoot.h:
        * rendering/RenderSVGTextPath.h:
        * rendering/RenderSVGViewportContainer.h:
        * rendering/RenderScrollbar.h:
        * rendering/RenderSlider.h:
        * rendering/RenderTextControlMultiLine.h:
        * rendering/RenderTextControlSingleLine.h:
        * rendering/RenderVideo.h:
        Added a checked cast. Also made most members protected or private.

        * rendering/RenderBlock.h:
        * rendering/RenderInline.h:
        * rendering/RenderReplaced.h:
        * rendering/RenderSVGBlock.h:
        * rendering/RenderSVGImage.h:
        * rendering/RenderSVGInlineText.h:
        * rendering/RenderSVGText.h:
        * rendering/RenderTextControl.h:
        Made most members protected or private.

        * rendering/RenderInline.cpp:
        * rendering/RenderSVGContainer.cpp:
        * rendering/RenderSVGHiddenContainer.cpp:
        * rendering/RenderSVGImage.cpp:
        * rendering/RenderSVGRoot.cpp:
        Removed unneeded destructor.

        * rendering/RenderSVGHiddenContainer.h:
        Removed unneeded virtual function overrides that did the same as
        the default and base class.

        * rendering/RenderSVGViewportContainer.cpp:
        (WebCore::RenderSVGViewportContainer::paint): Updated to use m_viewport
        directly instead of using a function call.
        (WebCore::RenderSVGViewportContainer::applyViewportClip): Ditto.
        (WebCore::RenderSVGViewportContainer::viewportTransform): Ditto.
        (WebCore::RenderSVGViewportContainer::localToParentTransform): Ditto.
        (WebCore::RenderSVGViewportContainer::pointIsInsideViewportClip): Ditto.

        * rendering/RenderScrollbar.cpp:
        (WebCore::pseudoForScrollbarPart): Changed switch statement to use cases for
        all values instead of using a default case.

        * rendering/RenderTreeAsText.cpp:
        (WebCore::operator<<): Removed dependency on casting to types that don't
        have any public members we need to get at. Instead, use function names to
        identify the type rather than doing so much overloading. Changed to use
        checked casts.
        (WebCore::write): Ditto.

        * rendering/SVGRenderSupport.cpp:
        (WebCore::renderSubtreeToImage): Changed to use a checked cast and also
        added a comment about the fact that the code does not do sufficient type
        checking before doing the cast.

        * rendering/SVGRenderTreeAsText.cpp:
        (WebCore::writeRenderSVGTextBox): Renamed this from operator<<.
        (WebCore::writeSVGInlineTextBoxes): Renamed this from writeSVGInlineText.
        (WebCore::writeSVGText): Renamed this from write.
        (WebCore::writeSVGInlineText): Ditto.
        (WebCore::writeSVGImage): Ditto.
        * rendering/SVGRenderTreeAsText.h: Updated for name changes. Removed
        unneeded default arguments.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@46815 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b8283dc0
This diff is collapsed.
......@@ -135,7 +135,7 @@ void AccessibilityListBox::visibleChildren(AccessibilityChildrenVector& result)
unsigned length = m_children.size();
for (unsigned i = 0; i < length; i++) {
if (static_cast<RenderListBox*>(m_renderer)->listIndexIsVisible(i))
if (toRenderListBox(m_renderer)->listIndexIsVisible(i))
result.append(m_children[i]);
}
}
......@@ -168,7 +168,7 @@ AccessibilityObject* AccessibilityListBox::doAccessibilityHitTest(const IntPoint
const Vector<Element*>& listItems = static_cast<HTMLSelectElement*>(node)->listItems();
unsigned length = listItems.size();
for (unsigned i = 0; i < length; i++) {
IntRect rect = static_cast<RenderListBox*>(m_renderer)->itemBoundingBoxRect(parentRect.x(), parentRect.y(), i);
IntRect rect = toRenderListBox(m_renderer)->itemBoundingBoxRect(parentRect.x(), parentRect.y(), i);
// The cast to HTMLElement below is safe because the only other possible listItem type
// would be a WMLElement, but WML builds don't use accessbility features at all.
if (rect.contains(point))
......
......@@ -100,7 +100,7 @@ IntRect AccessibilityListBoxOption::elementRect() const
IntRect parentRect = listBoxRenderer->document()->axObjectCache()->getOrCreate(listBoxRenderer)->boundingBoxRect();
int index = listBoxOptionIndex();
if (index != -1)
rect = static_cast<RenderListBox*>(listBoxRenderer)->itemBoundingBoxRect(parentRect.x(), parentRect.y(), index);
rect = toRenderListBox(listBoxRenderer)->itemBoundingBoxRect(parentRect.x(), parentRect.y(), index);
return rect;
}
......
......@@ -697,10 +697,8 @@ String AccessibilityRenderObject::textUnderElement() const
if (!m_renderer)
return String();
if (isFileUploadButton()) {
RenderFileUploadControl* uploadControl = static_cast<RenderFileUploadControl*>(m_renderer);
return uploadControl->buttonValue();
}
if (isFileUploadButton())
return toRenderFileUploadControl(m_renderer)->buttonValue();
Node* node = m_renderer->node();
if (node) {
......@@ -793,10 +791,10 @@ String AccessibilityRenderObject::stringValue() const
return textUnderElement();
if (m_renderer->isMenuList())
return static_cast<RenderMenuList*>(m_renderer)->text();
return toRenderMenuList(m_renderer)->text();
if (m_renderer->isListMarker())
return static_cast<RenderListMarker*>(m_renderer)->text();
return toRenderListMarker(m_renderer)->text();
if (m_renderer->isRenderButton())
return toRenderButton(m_renderer)->text();
......@@ -817,10 +815,8 @@ String AccessibilityRenderObject::stringValue() const
if (isTextControl())
return text();
if (isFileUploadButton()) {
RenderFileUploadControl* uploadControl = static_cast<RenderFileUploadControl*>(m_renderer);
return uploadControl->fileTextValue();
}
if (isFileUploadButton())
return toRenderFileUploadControl(m_renderer)->fileTextValue();
// FIXME: We might need to implement a value here for more types
// FIXME: It would be better not to advertise a value at all for the types for which we don't implement one;
......@@ -1223,7 +1219,7 @@ AccessibilityObject* AccessibilityRenderObject::titleUIElement() const
// if isFieldset is true, the renderer is guaranteed to be a RenderFieldset
if (isFieldset())
return axObjectCache()->getOrCreate(static_cast<RenderFieldset*>(m_renderer)->findLegend());
return axObjectCache()->getOrCreate(toRenderFieldset(m_renderer)->findLegend());
if (!exposesTitleUIElement())
return 0;
......@@ -1334,7 +1330,7 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
}
if (node && node->hasTagName(canvasTag)) {
RenderHTMLCanvas* canvas = static_cast<RenderHTMLCanvas*>(m_renderer);
RenderHTMLCanvas* canvas = toRenderHTMLCanvas(m_renderer);
if (canvas->height() <= 1 || canvas->width() <= 1)
return true;
return false;
......
......@@ -166,7 +166,7 @@ IntRect AccessibilitySliderThumb::elementRect() const
if (!m_parentSlider->renderer())
return IntRect();
IntRect intRect = static_cast<RenderSlider*>(m_parentSlider->renderer())->thumbRect();
IntRect intRect = toRenderSlider(m_parentSlider->renderer())->thumbRect();
FloatQuad floatQuad = m_parentSlider->renderer()->localToAbsoluteQuad(FloatRect(intRect));
return floatQuad.enclosingBoundingBox();
......
......@@ -93,7 +93,7 @@ void InputElement::updatePlaceholderVisibility(InputElementData& data, InputElem
&& !inputElement->placeholder().isEmpty());
if ((oldPlaceholderShouldBeVisible != data.placeholderShouldBeVisible() || placeholderValueChanged) && element->renderer())
static_cast<RenderTextControlSingleLine*>(element->renderer())->updatePlaceholderVisibility();
toRenderTextControlSingleLine(element->renderer())->updatePlaceholderVisibility();
}
void InputElement::updateFocusAppearance(InputElementData& data, InputElement* inputElement, Element* element, bool restorePreviousSelection)
......
......@@ -218,7 +218,7 @@ void SelectElement::scrollToSelection(SelectElementData& data, Element* element)
return;
if (RenderObject* renderer = element->renderer())
static_cast<RenderListBox*>(renderer)->selectionChanged();
toRenderListBox(renderer)->selectionChanged();
}
void SelectElement::recalcStyle(SelectElementData& data, Element* element)
......@@ -226,9 +226,9 @@ void SelectElement::recalcStyle(SelectElementData& data, Element* element)
RenderObject* renderer = element->renderer();
if (element->childNeedsStyleRecalc() && renderer) {
if (data.usesMenuList())
static_cast<RenderMenuList*>(renderer)->setOptionsChanged(true);
toRenderMenuList(renderer)->setOptionsChanged(true);
else
static_cast<RenderListBox*>(renderer)->setOptionsChanged(true);
toRenderListBox(renderer)->setOptionsChanged(true);
} else if (data.shouldRecalcListItems())
recalcListItems(data, element);
}
......@@ -239,9 +239,9 @@ void SelectElement::setRecalcListItems(SelectElementData& data, Element* element
data.setActiveSelectionAnchorIndex(-1); // Manual selection anchor is reset when manipulating the select programmatically.
if (RenderObject* renderer = element->renderer()) {
if (data.usesMenuList())
static_cast<RenderMenuList*>(renderer)->setOptionsChanged(true);
toRenderMenuList(renderer)->setOptionsChanged(true);
else
static_cast<RenderListBox*>(renderer)->setOptionsChanged(true);
toRenderListBox(renderer)->setOptionsChanged(true);
}
element->setNeedsStyleRecalc();
}
......@@ -561,7 +561,7 @@ void SelectElement::menuListDefaultEventHandler(SelectElementData& data, Element
// Save the selection so it can be compared to the new selection when dispatching change events during setSelectedIndex,
// which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu.
saveLastSelection(data, element);
if (RenderMenuList* menuList = static_cast<RenderMenuList*>(element->renderer()))
if (RenderMenuList* menuList = toRenderMenuList(element->renderer()))
menuList->showPopup();
handled = true;
}
......@@ -611,7 +611,7 @@ void SelectElement::menuListDefaultEventHandler(SelectElementData& data, Element
// Save the selection so it can be compared to the new selection when dispatching change events during setSelectedIndex,
// which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu.
saveLastSelection(data, element);
if (RenderMenuList* menuList = static_cast<RenderMenuList*>(element->renderer()))
if (RenderMenuList* menuList = toRenderMenuList(element->renderer()))
menuList->showPopup();
handled = true;
}
......@@ -621,7 +621,7 @@ void SelectElement::menuListDefaultEventHandler(SelectElementData& data, Element
// Save the selection so it can be compared to the new selection when dispatching change events during setSelectedIndex,
// which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu.
saveLastSelection(data, element);
if (RenderMenuList* menuList = static_cast<RenderMenuList*>(element->renderer()))
if (RenderMenuList* menuList = toRenderMenuList(element->renderer()))
menuList->showPopup();
handled = true;
} else if (keyCode == '\r') {
......@@ -644,7 +644,7 @@ void SelectElement::menuListDefaultEventHandler(SelectElementData& data, Element
if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
element->focus();
if (RenderMenuList* menuList = static_cast<RenderMenuList*>(element->renderer())) {
if (RenderMenuList* menuList = toRenderMenuList(element->renderer())) {
if (menuList->popupIsVisible())
menuList->hidePopup();
else {
......@@ -668,7 +668,7 @@ void SelectElement::listBoxDefaultEventHandler(SelectElementData& data, Element*
// Convert to coords relative to the list box if needed.
MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
IntPoint localOffset = roundedIntPoint(element->renderer()->absoluteToLocal(mouseEvent->absoluteLocation(), false, true));
int listIndex = static_cast<RenderListBox*>(element->renderer())->listIndexAtOffset(localOffset.x(), localOffset.y());
int listIndex = toRenderListBox(element->renderer())->listIndexAtOffset(localOffset.x(), localOffset.y());
if (listIndex >= 0) {
// Save the selection so it can be compared to the new selection when dispatching change events during mouseup, or after autoscroll finishes.
saveLastSelection(data, element);
......@@ -761,7 +761,7 @@ void SelectElement::listBoxDefaultEventHandler(SelectElementData& data, Element*
setActiveSelectionAnchorIndex(data, element, data.activeSelectionEndIndex());
}
static_cast<RenderListBox*>(element->renderer())->scrollToRevealElementAtListIndex(endIndex);
toRenderListBox(element->renderer())->scrollToRevealElementAtListIndex(endIndex);
updateListBoxSelection(data, element, deselectOthers);
listBoxOnChange(data, element);
event->setDefaultHandled();
......
......@@ -144,7 +144,7 @@ void BreakBlockquoteCommand::doApply()
while (listChildNode && !listChildNode->hasTagName(liTag))
listChildNode = listChildNode->nextSibling();
if (listChildNode && listChildNode->renderer())
setNodeAttribute(static_cast<Element*>(clonedChild.get()), startAttr, String::number(static_cast<RenderListItem*>(listChildNode->renderer())->value()));
setNodeAttribute(static_cast<Element*>(clonedChild.get()), startAttr, String::number(toRenderListItem(listChildNode->renderer())->value()));
}
appendNode(clonedChild.get(), clonedAncestor.get());
......
......@@ -141,7 +141,7 @@ RenderWidget* HTMLAppletElement::renderWidgetForJSBindings() const
if (!settings || !settings->isJavaEnabled())
return 0;
RenderApplet* applet = static_cast<RenderApplet*>(renderer());
RenderApplet* applet = toRenderApplet(renderer());
if (applet)
applet->createWidgetIfNecessary();
......
......@@ -195,14 +195,15 @@ void HTMLCanvasElement::reset()
if (m_2DContext)
m_2DContext->reset();
if (RenderObject* ro = renderer())
if (RenderObject* renderer = this->renderer()) {
if (m_rendererIsCanvas) {
if (oldSize != m_size)
static_cast<RenderHTMLCanvas*>(ro)->canvasSizeChanged();
toRenderHTMLCanvas(renderer)->canvasSizeChanged();
if (hadImageBuffer)
ro->repaint();
renderer->repaint();
}
}
if (m_observer)
m_observer->canvasResized(this);
}
......
......@@ -182,7 +182,7 @@ void HTMLEmbedElement::updateWidget()
{
document()->updateStyleIfNeeded();
if (m_needWidgetUpdate && renderer() && !isImageType())
static_cast<RenderPartObject*>(renderer())->updateWidget(true);
toRenderPartObject(renderer())->updateWidget(true);
}
void HTMLEmbedElement::insertedIntoDocument()
......
......@@ -193,9 +193,10 @@ void HTMLFrameElementBase::attach()
HTMLFrameOwnerElement::attach();
if (RenderPart* renderPart = static_cast<RenderPart*>(renderer()))
if (RenderPart* renderPart = toRenderPart(renderer())) {
if (Frame* frame = contentFrame())
renderPart->setWidget(frame->view());
}
}
KURL HTMLFrameElementBase::location() const
......
......@@ -191,7 +191,7 @@ void HTMLFrameSetElement::attach()
void HTMLFrameSetElement::defaultEventHandler(Event* evt)
{
if (evt->isMouseEvent() && !noresize && renderer()) {
if (static_cast<RenderFrameSet*>(renderer())->userResize(static_cast<MouseEvent*>(evt))) {
if (toRenderFrameSet(renderer())->userResize(static_cast<MouseEvent*>(evt))) {
evt->setDefaultHandled();
return;
}
......
......@@ -117,7 +117,7 @@ void HTMLIFrameElement::attach()
{
HTMLFrameElementBase::attach();
if (RenderPartObject* renderPartObject = static_cast<RenderPartObject*>(renderer()))
if (RenderPartObject* renderPartObject = toRenderPartObject(renderer()))
renderPartObject->updateWidget(false);
}
......
......@@ -1314,7 +1314,7 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
m_activeSubmit = false;
}
} else if (inputType() == FILE && renderer())
static_cast<RenderFileUploadControl*>(renderer())->click();
toRenderFileUploadControl(renderer())->click();
}
// Use key press event here since sending simulated mouse events
......@@ -1501,10 +1501,10 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
InputElement::handleBeforeTextInsertedEvent(m_data, this, document(), evt);
if (isTextField() && renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent() || evt->type() == eventNames().blurEvent || evt->type() == eventNames().focusEvent))
static_cast<RenderTextControlSingleLine*>(renderer())->forwardEvent(evt);
toRenderTextControlSingleLine(renderer())->forwardEvent(evt);
if (inputType() == RANGE && renderer() && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent()))
static_cast<RenderSlider*>(renderer())->forwardEvent(evt);
toRenderSlider(renderer())->forwardEvent(evt);
if (!callBaseClassEarly && !evt->defaultHandled())
HTMLFormControlElementWithState::defaultEventHandler(evt);
......@@ -1704,14 +1704,14 @@ void HTMLInputElement::addSearchResult()
{
ASSERT(isSearchField());
if (renderer())
static_cast<RenderTextControlSingleLine*>(renderer())->addSearchResult();
toRenderTextControlSingleLine(renderer())->addSearchResult();
}
void HTMLInputElement::onSearch()
{
ASSERT(isSearchField());
if (renderer())
static_cast<RenderTextControlSingleLine*>(renderer())->stopSearchEventTimer();
toRenderTextControlSingleLine(renderer())->stopSearchEventTimer();
dispatchEvent(eventNames().searchEvent, true, false);
}
......
......@@ -56,9 +56,9 @@ void HTMLLIElement::parseMappedAttribute(MappedAttribute* attr)
m_requestedValue = attr->value().toInt();
if (renderer() && renderer()->isListItem()) {
if (m_requestedValue > 0)
static_cast<RenderListItem*>(renderer())->setExplicitValue(m_requestedValue);
toRenderListItem(renderer())->setExplicitValue(m_requestedValue);
else
static_cast<RenderListItem*>(renderer())->clearExplicitValue();
toRenderListItem(renderer())->clearExplicitValue();
}
} else if (attr->name() == typeAttr) {
if (attr->value() == "a")
......@@ -84,7 +84,7 @@ void HTMLLIElement::attach()
HTMLElement::attach();
if (renderer() && renderer()->isListItem()) {
RenderListItem* render = static_cast<RenderListItem*>(renderer());
RenderListItem* render = toRenderListItem(renderer());
// Find the enclosing list node.
Node* listNode = 0;
......
......@@ -765,7 +765,7 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state)
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
if (renderer() && renderer()->isVideo()) {
static_cast<RenderVideo*>(renderer())->videoSizeChanged();
toRenderVideo(renderer())->videoSizeChanged();
}
#endif
m_delayingTheLoadEvent = false;
......@@ -1340,7 +1340,7 @@ void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer*)
if (renderer()) {
renderer()->updateFromElement();
if (renderer()->isVideo())
static_cast<RenderVideo*>(renderer())->videoSizeChanged();
toRenderVideo(renderer())->videoSizeChanged();
}
#endif
endProcessingMediaPlayerCallback();
......@@ -1380,7 +1380,7 @@ void HTMLMediaElement::mediaPlayerSizeChanged(MediaPlayer*)
beginProcessingMediaPlayerCallback();
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
if (renderer() && renderer()->isVideo())
static_cast<RenderVideo*>(renderer())->videoSizeChanged();
toRenderVideo(renderer())->videoSizeChanged();
#endif
endProcessingMediaPlayerCallback();
}
......@@ -1390,7 +1390,7 @@ bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated(MediaPlayer*)
{
if (renderer() && renderer()->isVideo()) {
ASSERT(renderer()->view());
return renderer()->view()->compositor()->canAccelerateVideoRendering(static_cast<RenderVideo*>(renderer()));
return renderer()->view()->compositor()->canAccelerateVideoRendering(toRenderVideo(renderer()));
}
return false;
}
......@@ -1398,7 +1398,7 @@ bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated(MediaPlayer*)
GraphicsLayer* HTMLMediaElement::mediaPlayerGraphicsLayer(MediaPlayer*)
{
if (renderer() && renderer()->isVideo())
return static_cast<RenderVideo*>(renderer())->videoGraphicsLayer();
return toRenderVideo(renderer())->videoGraphicsLayer();
return 0;
}
#endif
......@@ -1620,7 +1620,7 @@ void HTMLMediaElement::defaultEventHandler(Event* event)
widget->handleEvent(event);
#else
if (renderer() && renderer()->isMedia())
static_cast<RenderMedia*>(renderer())->forwardEvent(event);
toRenderMedia(renderer())->forwardEvent(event);
if (event->defaultHandled())
return;
HTMLElement::defaultEventHandler(event);
......@@ -1637,6 +1637,7 @@ bool HTMLMediaElement::processingUserGesture() const
}
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
void HTMLMediaElement::deliverNotification(MediaPlayerProxyNotificationType notification)
{
if (notification == MediaPlayerNotificationPlayPauseButtonPressed) {
......@@ -1674,8 +1675,9 @@ void HTMLMediaElement::finishParsingChildren()
document()->updateStyleIfNeeded();
if (m_needWidgetUpdate && renderer())
static_cast<RenderPartObject*>(renderer())->updateWidget(true);
toRenderPartObject(renderer())->updateWidget(true);
}
#endif
}
......
......@@ -72,7 +72,7 @@ void HTMLOListElement::parseMappedAttribute(MappedAttribute* attr)
m_start = start;
for (RenderObject* child = renderer(); child; child = child->nextInPreOrder(renderer())) {
if (child->isListItem())
static_cast<RenderListItem*>(child)->updateValue();
toRenderListItem(child)->updateValue();
}
} else
HTMLElement::parseMappedAttribute(attr);
......
......@@ -166,7 +166,7 @@ void HTMLObjectElement::updateWidget()
{
document()->updateStyleIfNeeded();
if (m_needWidgetUpdate && renderer() && !m_useFallbackContent && !isImageType())
static_cast<RenderPartObject*>(renderer())->updateWidget(true);
toRenderPartObject(renderer())->updateWidget(true);
}
void HTMLObjectElement::finishParsingChildren()
......
......@@ -267,7 +267,7 @@ void HTMLTextAreaElement::updateFocusAppearance(bool restorePreviousSelection)
void HTMLTextAreaElement::defaultEventHandler(Event* event)
{
if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->isWheelEvent() || event->type() == eventNames().blurEvent))
static_cast<RenderTextControlMultiLine*>(renderer())->forwardEvent(event);
toRenderTextControlMultiLine(renderer())->forwardEvent(event);
HTMLFormControlElementWithState::defaultEventHandler(event);
}
......
......@@ -379,11 +379,10 @@ bool DragController::concludeEditDrag(DragData* dragData)
if (filenames.isEmpty())
return false;
// Ugly. For security none of the API's available to us to set the input value
// on file inputs. Even forcing a change in HTMLInputElement doesn't work as
// RenderFileUploadControl clears the file when doing updateFromElement()
RenderFileUploadControl* renderer = static_cast<RenderFileUploadControl*>(fileInput->renderer());
// Ugly. For security none of the APIs available to us can set the input value
// on file inputs. Even forcing a change in HTMLInputElement doesn't work as
// RenderFileUploadControl clears the file when doing updateFromElement().
RenderFileUploadControl* renderer = toRenderFileUploadControl(fileInput->renderer());
if (!renderer)
return false;
......
......@@ -945,10 +945,10 @@ Cursor EventHandler::selectCursor(const MouseEventWithHitTestResults& event, Scr
RenderStyle* style = renderer ? renderer->style() : 0;
if (renderer && renderer->isFrameSet()) {
RenderFrameSet* fs = static_cast<RenderFrameSet*>(renderer);
if (fs->canResizeRow(event.localPoint()))
RenderFrameSet* frameSetRenderer = toRenderFrameSet(renderer);
if (frameSetRenderer->canResizeRow(event.localPoint()))
return rowResizeCursor();
if (fs->canResizeColumn(event.localPoint()))
if (frameSetRenderer->canResizeColumn(event.localPoint()))
return columnResizeCursor();
}
......@@ -2414,7 +2414,7 @@ void EventHandler::capsLockStateMayHaveChanged()
if (Node* node = d->focusedNode()) {
if (RenderObject* r = node->renderer()) {
if (r->isTextField())
static_cast<RenderTextControlSingleLine*>(r)->capsLockStateMayHaveChanged();
toRenderTextControlSingleLine(r)->capsLockStateMayHaveChanged();
}
}
}
......
......@@ -1154,7 +1154,7 @@ RenderPart* Frame::ownerRenderer() const
// https://bugs.webkit.org/show_bug.cgi?id=18585
if (!object->isRenderPart())
return 0;
return static_cast<RenderPart*>(object);
return toRenderPart(object);
}
bool Frame::isDisconnected() const
......
......@@ -244,11 +244,11 @@ void FrameView::detachCustomScrollbars()
RenderBox* renderBox = body->renderBox();
Scrollbar* horizontalBar = horizontalScrollbar();
if (horizontalBar && horizontalBar->isCustomScrollbar() && reinterpret_cast<RenderScrollbar*>(horizontalBar)->owningRenderer() == renderBox)
if (horizontalBar && horizontalBar->isCustomScrollbar() && toRenderScrollbar(horizontalBar)->owningRenderer() == renderBox)
setHasHorizontalScrollbar(false);
Scrollbar* verticalBar = verticalScrollbar();
if (verticalBar && verticalBar->isCustomScrollbar() && reinterpret_cast<RenderScrollbar*>(verticalBar)->owningRenderer() == renderBox)
if (verticalBar && verticalBar->isCustomScrollbar() && toRenderScrollbar(verticalBar)->owningRenderer() == renderBox)
setHasVerticalScrollbar(false);
}
......
......@@ -72,7 +72,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");
......
......@@ -309,7 +309,7 @@ int InlineFlowBox::placeBoxesHorizontally(int xPos, int& leftPosition, int& righ
xPos += flow->marginLeft();
xPos = flow->placeBoxesHorizontally(xPos, leftPosition, rightPosition, needsWordSpacing);
xPos += flow->marginRight();
} else if (!curr->renderer()->isListMarker() || static_cast<RenderListMarker*>(curr->renderer())->isInside()) {
} else if (!curr->renderer()->isListMarker() || toRenderListMarker(curr->renderer())->isInside()) {
xPos += curr->boxModelObject()->marginLeft();
curr->setX(xPos);
leftPosition = min(xPos + toRenderBox(curr->renderer())->overflowLeft(false), leftPosition);
......
......@@ -487,9 +487,8 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event)
MediaControlInputElement::defaultEventHandler(event);
if (event->type() == eventNames().mouseoverEvent || event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mousemoveEvent) {
if (event->type() == eventNames().mouseoverEvent || event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mousemoveEvent)
return;
}
float time = narrowPrecisionToFloat(value().toDouble());
if (time != m_mediaElement->currentTime()) {
......@@ -497,9 +496,9 @@ void MediaControlTimelineElement::defaultEventHandler(Event* event)
m_mediaElement->setCurrentTime(time, ec);
}
RenderSlider* slider = static_cast<RenderSlider*>(renderer());
RenderSlider* slider = toRenderSlider(renderer());
if (slider && slider->inDragMode())
static_cast<RenderMedia*>(m_mediaElement->renderer())->updateTimeDisplay();
toRenderMedia(m_mediaElement->renderer())->updateTimeDisplay();
if (event->type() == eventNames().mouseupEvent)
m_mediaElement->endScrubbing();
......
......@@ -46,6 +46,15 @@ namespace WebCore {
HashMap<String, String> m_args;
};
inline RenderApplet* toRenderApplet(RenderObject* object)
{
ASSERT(!object || object->isApplet());
return static_cast<RenderApplet*>(object);
}
// This will catch anyone doing an unnecessary cast.
void toRenderApplet(const RenderApplet*);
} // namespace WebCore
#endif // RenderApplet_h
This diff is collapsed.
......@@ -1786,7 +1786,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
// Optimize for a common case. If we can't find whitespace after the list
// item, then this is all moot. -dwh
if (o->isListMarker() && !static_cast<RenderListMarker*>(o)->isInside()) {
if (o->isListMarker() && !toRenderListMarker(o)->isInside()) {
if (style()->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(this, o, lineMidpointState)) {
// Like with inline flows, we start ignoring spaces to make sure that any
// additional spaces we see will be discarded.
......@@ -2106,7 +2106,7 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
if (!o->isFloatingOrPositioned()) {
last = o;
if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || static_cast<RenderListMarker*>(last)->isInside())) {
if (last->isReplaced() && autoWrap && (!last->isImage() || allowImagesToBreak) && (!last->isListMarker() || toRenderListMarker(last)->isInside())) {
w += tmpW;
tmpW = 0;
lBreak.obj = next;
......
......@@ -251,7 +251,7 @@ public:
virtual void paintObject(PaintInfo&, int /*tx*/, int /*ty*/) { ASSERT_NOT_REACHED(); }
virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
virtual void paintMask(PaintInfo& paintInfo, int tx, int ty);
virtual void paintMask(PaintInfo&, int tx, int ty);
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
// Called when a positioned object moves but doesn't change size. A simplified layout is done
......
......@@ -107,8 +107,8 @@ static bool planCounter(RenderObject* object, const AtomicString& counterName, b
if (counterName == "list-item") {
if (object->isListItem()) {
if (static_cast<RenderListItem*>(object)->hasExplicitValue()) {
value = static_cast<RenderListItem*>(object)->explicitValue();
if (toRenderListItem(object)->hasExplicitValue()) {
value = toRenderListItem(object)->explicitValue();
isReset = true;
return true;
}
......
/*
* Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -33,21 +33,30 @@ class RenderCounter : public RenderText {
public:
RenderCounter(Document*, const CounterContent&);