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
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.
2009-08-05 Peter Kasting <pkasting@google.com>
Reviewed by Sam Weinig.
......
......@@ -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*)