Commit 9aa9e8d7 authored by inferno@chromium.org's avatar inferno@chromium.org

Replace static_casts with to* helper functions.

https://bugs.webkit.org/show_bug.cgi?id=112296

Reviewed by Kentaro Hara.

to* helper functions are preferred over static_cast calls since they
help to catch bad casts easily on the testing infrastructure.

Source/WebCore:

* accessibility/AXObjectCache.cpp:
(WebCore::nodeHasRole):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::hasAttribute):
(WebCore::AccessibilityObject::getAttribute):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::anchorElement):
(WebCore::AccessibilityRenderObject::helpText):
(WebCore::AccessibilityRenderObject::checkboxOrRadioRect):
(WebCore::AccessibilityRenderObject::titleUIElement):
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::accessKey):
(WebCore::AccessibilityRenderObject::setElementAttributeValue):
(WebCore::AccessibilityRenderObject::setValue):
(WebCore::AccessibilityRenderObject::activeDescendant):
(WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
(WebCore::AccessibilityRenderObject::correspondingLabelForControlElement):
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole):
(WebCore::AccessibilityRenderObject::setAccessibleName):
(WebCore::AccessibilityRenderObject::stringRoleForMSAA):
* bindings/gobject/WebKitDOMBinding.cpp:
(WebKit::createWrapper):
* bindings/js/JSClipboardCustom.cpp:
(WebCore::JSClipboard::setDragImage):
* bindings/js/JSElementCustom.cpp:
(WebCore::toJSNewlyCreated):
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline):
* bindings/v8/custom/V8ClipboardCustom.cpp:
(WebCore::V8Clipboard::setDragImageMethodCustom):
* bindings/v8/custom/V8ElementCustom.cpp:
(WebCore::wrap):
* bindings/v8/custom/V8NodeCustom.cpp:
(WebCore::wrap):
* dom/Document.cpp:
(WebCore::Document::importNode):
(WebCore::Document::recalcStyle):
(WebCore::Document::setFocusedNode):
(WebCore::Document::updateFocusAppearanceTimerFired):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
* dom/Element.cpp:
(WebCore::Element::offsetParent):
(WebCore::Element::boundsInRootViewSpace):
(WebCore::Element::getBoundingClientRect):
(WebCore::Element::recalcStyle):
(WebCore::Element::computeInheritedLanguage):
(WebCore::Element::lastElementChild):
* dom/LiveNodeList.cpp:
(WebCore::LiveNodeList::namedItem):
* dom/Node.cpp:
(WebCore::Node::dumpStatistics):
(WebCore::Node::normalize):
(WebCore::Node::rootEditableElement):
(WebCore::Node::isDefaultNamespace):
(WebCore::Node::ancestorElement):
(WebCore::appendAttributeDesc):
* dom/Position.cpp:
(WebCore::Position::element):
* dom/Range.cpp:
(WebCore::Range::getBorderAndTextQuads):
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::queryFirst):
(WebCore::SelectorDataList::execute):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::recalcStyle):
* dom/StaticHashSetNodeList.cpp:
(WebCore::StaticHashSetNodeList::namedItem):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi):
(WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
(WebCore::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
(WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
* editing/Editor.cpp:
(WebCore::Editor::applyEditingStyleToBodyElement):
* editing/FrameSelection.cpp:
(WebCore::removingNodeRemovesPosition):
* editing/IndentOutdentCommand.cpp:
(WebCore::IndentOutdentCommand::outdentParagraph):
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::entityMaskForText):
(WebCore::MarkupAccumulator::appendStartMarkup):
(WebCore::MarkupAccumulator::appendEndMarkup):
* editing/ModifySelectionListLevel.cpp:
(WebCore::IncreaseSelectionListLevelCommand::doApply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::haveSameTagName):
(WebCore::handleStyleSpansBeforeInsertion):
(WebCore::ReplaceSelectionCommand::doApply):
* editing/SplitTextNodeContainingElementCommand.cpp:
(WebCore::SplitTextNodeContainingElementCommand::doApply):
* editing/TextIterator.cpp:
(WebCore::TextIterator::advance):
* editing/htmlediting.cpp:
(WebCore::unsplittableElementForPosition):
(WebCore::enclosingTableCell):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::wrapWithNode):
(WebCore::createMarkupInternal):
(WebCore::createFragmentFromMarkupWithContext):
(WebCore::isPlainTextMarkup):
(WebCore::createFragmentFromText):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::insertAdjacentElement):
(WebCore::contextElementForInsertion):
* html/HTMLFormControlElement.cpp:
(WebCore::focusPostAttach):
(WebCore::updateFromElementCallback):
* html/HTMLFormElement.cpp:
(WebCore::submitElementFromEvent):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::updateDocNamedItem):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::updateSnapshotInfo):
* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::addRange):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::closestFormAncestor):
* html/shadow/MediaControlElementTypes.cpp:
(WebCore::toParentMediaElement):
* html/shadow/TextFieldDecorationElement.h:
(WebCore::toTextFieldDecorationElement):
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::createDigest):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForNode):
(WebCore::InspectorDOMAgent::didInvalidateStyleAttr):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::inlineStyleSheetText):
* mathml/MathMLElement.h:
(WebCore::toMathMLElement):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate):
* page/DragController.cpp:
(WebCore::elementUnderMouse):
(WebCore::DragController::startDrag):
* page/FocusController.cpp:
(WebCore::FocusController::advanceFocusInDocumentOrder):
* page/Frame.cpp:
(WebCore::Frame::searchForLabelsBeforeElement):
* page/FrameView.cpp:
(WebCore::FrameView::updateWidget):
* page/SpatialNavigation.cpp:
(WebCore::rectToAbsoluteCoordinates):
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::sendTransitionEvent):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::sendAnimationEvent):
* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::paintMediaFullscreenButton):
(WebCore::RenderThemeEfl::paintMediaMuteButton):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
* rendering/svg/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::calcViewport):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):
* svg/SVGUseElement.cpp:
(WebCore::isDisallowedElement):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::buildPendingResource):
* xml/XPathStep.cpp:
(WebCore::XPath::nodeMatchesBasicTest):
* xml/parser/XMLDocumentParserQt.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):
(WebCore::XMLDocumentParser::parseEndElement):

Source/WebKit/blackberry:

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):
(BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
(BlackBerry::WebKit::WebPage::setNodeFocus):
(BlackBerry::WebKit::WebPagePrivate::adjustFullScreenElementDimensionsIfNeeded):
* WebCoreSupport/EditorClientBlackBerry.cpp:
(WebCore::EditorClientBlackBerry::shouldSpellCheckFocusedField):
(WebCore::EditorClientBlackBerry::shouldChangeSelectedRange):
* WebKitSupport/BackingStoreClient.cpp:
(BlackBerry::WebKit::BackingStoreClient::absoluteRect):
* WebKitSupport/DOMSupport.cpp:
(BlackBerry::WebKit::DOMSupport::toTextControlElement):
(BlackBerry::WebKit::DOMSupport::selectionContainerElement):
* WebKitSupport/FatFingers.cpp:
(BlackBerry::WebKit::FatFingers::getRelevantInfoFromCachedHitTest):
(BlackBerry::WebKit::FatFingers::setSuccessfulFatFingersResult):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::focusedNodeChanged):
(BlackBerry::WebKit::InputHandler::willOpenPopupForNode):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::inputNodeOverridesTouch):
* WebKitSupport/TouchEventHandler.cpp:
(BlackBerry::WebKit::elementForTapHighlight):

Source/WebKit/chromium:

* src/WebDocument.cpp:
(WebKit::WebDocument::images):
* src/WebElement.cpp:
(WebKit::WebElement::operator PassRefPtr<Element>):
* src/WebPageSerializer.cpp:
(WebCore::retrieveResourcesForFrame):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setFocus):
(WebKit::WebViewImpl::clearFocusedNode):
(WebKit::WebViewImpl::scrollFocusedNodeIntoView):
(WebKit::WebViewImpl::scrollFocusedNodeIntoRect):

Source/WebKit/gtk:

* webkit/webkitwebview.cpp:
(webkit_web_view_query_tooltip):

Source/WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(applyAppleDictionaryApplicationQuirkNonInlinePart):
* WebView/WebHTMLRepresentation.mm:
(searchForLabelsBeforeElement):

Source/WebKit/qt:

* Api/qwebelement.cpp:
(QWebElement::firstChild):
(QWebElement::lastChild):
(QWebElement::nextSibling):
(QWebElement::previousSibling):
(QWebElementCollection::at):
(QWebElementCollection::toList):
* WebCoreSupport/QWebFrameAdapter.cpp:
(QWebHitTestResultPrivate::elementForInnerNode):

Source/WebKit/win:

* WebView.cpp:
(WebView::enterFullscreenForNode):

Source/WebKit2:

* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::elementBounds):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::containsAnyFormElements):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 859e3c21
2013-03-14 Abhishek Arya <inferno@chromium.org>
Replace static_casts with to* helper functions.
https://bugs.webkit.org/show_bug.cgi?id=112296
Reviewed by Kentaro Hara.
to* helper functions are preferred over static_cast calls since they
help to catch bad casts easily on the testing infrastructure.
* accessibility/AXObjectCache.cpp:
(WebCore::nodeHasRole):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::hasAttribute):
(WebCore::AccessibilityObject::getAttribute):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::anchorElement):
(WebCore::AccessibilityRenderObject::helpText):
(WebCore::AccessibilityRenderObject::checkboxOrRadioRect):
(WebCore::AccessibilityRenderObject::titleUIElement):
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::accessKey):
(WebCore::AccessibilityRenderObject::setElementAttributeValue):
(WebCore::AccessibilityRenderObject::setValue):
(WebCore::AccessibilityRenderObject::activeDescendant):
(WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
(WebCore::AccessibilityRenderObject::correspondingLabelForControlElement):
(WebCore::AccessibilityRenderObject::inheritsPresentationalRole):
(WebCore::AccessibilityRenderObject::setAccessibleName):
(WebCore::AccessibilityRenderObject::stringRoleForMSAA):
* bindings/gobject/WebKitDOMBinding.cpp:
(WebKit::createWrapper):
* bindings/js/JSClipboardCustom.cpp:
(WebCore::JSClipboard::setDragImage):
* bindings/js/JSElementCustom.cpp:
(WebCore::toJSNewlyCreated):
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline):
* bindings/v8/custom/V8ClipboardCustom.cpp:
(WebCore::V8Clipboard::setDragImageMethodCustom):
* bindings/v8/custom/V8ElementCustom.cpp:
(WebCore::wrap):
* bindings/v8/custom/V8NodeCustom.cpp:
(WebCore::wrap):
* dom/Document.cpp:
(WebCore::Document::importNode):
(WebCore::Document::recalcStyle):
(WebCore::Document::setFocusedNode):
(WebCore::Document::updateFocusAppearanceTimerFired):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
* dom/Element.cpp:
(WebCore::Element::offsetParent):
(WebCore::Element::boundsInRootViewSpace):
(WebCore::Element::getBoundingClientRect):
(WebCore::Element::recalcStyle):
(WebCore::Element::computeInheritedLanguage):
(WebCore::Element::lastElementChild):
* dom/LiveNodeList.cpp:
(WebCore::LiveNodeList::namedItem):
* dom/Node.cpp:
(WebCore::Node::dumpStatistics):
(WebCore::Node::normalize):
(WebCore::Node::rootEditableElement):
(WebCore::Node::isDefaultNamespace):
(WebCore::Node::ancestorElement):
(WebCore::appendAttributeDesc):
* dom/Position.cpp:
(WebCore::Position::element):
* dom/Range.cpp:
(WebCore::Range::getBorderAndTextQuads):
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::queryFirst):
(WebCore::SelectorDataList::execute):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::recalcStyle):
* dom/StaticHashSetNodeList.cpp:
(WebCore::StaticHashSetNodeList::namedItem):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi):
(WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
(WebCore::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
(WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
* editing/Editor.cpp:
(WebCore::Editor::applyEditingStyleToBodyElement):
* editing/FrameSelection.cpp:
(WebCore::removingNodeRemovesPosition):
* editing/IndentOutdentCommand.cpp:
(WebCore::IndentOutdentCommand::outdentParagraph):
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::entityMaskForText):
(WebCore::MarkupAccumulator::appendStartMarkup):
(WebCore::MarkupAccumulator::appendEndMarkup):
* editing/ModifySelectionListLevel.cpp:
(WebCore::IncreaseSelectionListLevelCommand::doApply):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::haveSameTagName):
(WebCore::handleStyleSpansBeforeInsertion):
(WebCore::ReplaceSelectionCommand::doApply):
* editing/SplitTextNodeContainingElementCommand.cpp:
(WebCore::SplitTextNodeContainingElementCommand::doApply):
* editing/TextIterator.cpp:
(WebCore::TextIterator::advance):
* editing/htmlediting.cpp:
(WebCore::unsplittableElementForPosition):
(WebCore::enclosingTableCell):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::wrapWithNode):
(WebCore::createMarkupInternal):
(WebCore::createFragmentFromMarkupWithContext):
(WebCore::isPlainTextMarkup):
(WebCore::createFragmentFromText):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::insertAdjacentElement):
(WebCore::contextElementForInsertion):
* html/HTMLFormControlElement.cpp:
(WebCore::focusPostAttach):
(WebCore::updateFromElementCallback):
* html/HTMLFormElement.cpp:
(WebCore::submitElementFromEvent):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::updateDocNamedItem):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::updateSnapshotInfo):
* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::addRange):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::closestFormAncestor):
* html/shadow/MediaControlElementTypes.cpp:
(WebCore::toParentMediaElement):
* html/shadow/TextFieldDecorationElement.h:
(WebCore::toTextFieldDecorationElement):
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::createDigest):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForNode):
(WebCore::InspectorDOMAgent::didInvalidateStyleAttr):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::inlineStyleSheetText):
* mathml/MathMLElement.h:
(WebCore::toMathMLElement):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate):
* page/DragController.cpp:
(WebCore::elementUnderMouse):
(WebCore::DragController::startDrag):
* page/FocusController.cpp:
(WebCore::FocusController::advanceFocusInDocumentOrder):
* page/Frame.cpp:
(WebCore::Frame::searchForLabelsBeforeElement):
* page/FrameView.cpp:
(WebCore::FrameView::updateWidget):
* page/SpatialNavigation.cpp:
(WebCore::rectToAbsoluteCoordinates):
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::sendTransitionEvent):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::sendAnimationEvent):
* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::paintMediaFullscreenButton):
(WebCore::RenderThemeEfl::paintMediaMuteButton):
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
* rendering/svg/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::calcViewport):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):
* svg/SVGUseElement.cpp:
(WebCore::isDisallowedElement):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::buildPendingResource):
* xml/XPathStep.cpp:
(WebCore::XPath::nodeMatchesBasicTest):
* xml/parser/XMLDocumentParserQt.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):
(WebCore::XMLDocumentParser::parseEndElement):
2013-03-14 Pavel Feldman <pfeldman@chromium.org>
Web Inspector: keep deprecated function stubs in InspectorFrontendHost.
......@@ -243,7 +243,7 @@ bool nodeHasRole(Node* node, const String& role)
if (!node || !node->isElementNode())
return false;
return equalIgnoringCase(static_cast<Element*>(node)->getAttribute(roleAttr), role);
return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role);
}
static PassRefPtr<AccessibilityObject> createFromRenderer(RenderObject* renderer)
......
......@@ -1320,7 +1320,7 @@ bool AccessibilityObject::hasAttribute(const QualifiedName& attribute) const
if (!elementNode->isElementNode())
return false;
Element* element = static_cast<Element*>(elementNode);
Element* element = toElement(elementNode);
return element->fastHasAttribute(attribute);
}
......@@ -1333,7 +1333,7 @@ const AtomicString& AccessibilityObject::getAttribute(const QualifiedName& attri
if (!elementNode->isElementNode())
return nullAtom;
Element* element = static_cast<Element*>(elementNode);
Element* element = toElement(elementNode);
return element->fastGetAttribute(attribute);
}
......
......@@ -573,7 +573,7 @@ Element* AccessibilityRenderObject::anchorElement() const
Node* node = currRenderer->node();
for ( ; node; node = node->parentNode()) {
if (node->hasTagName(aTag) || (node->renderer() && cache->getOrCreate(node->renderer())->isAnchor()))
return static_cast<Element*>(node);
return toElement(node);
}
return 0;
......@@ -595,12 +595,12 @@ String AccessibilityRenderObject::helpText() const
String description = accessibilityDescription();
for (RenderObject* curr = m_renderer; curr; curr = curr->parent()) {
if (curr->node() && curr->node()->isHTMLElement()) {
const AtomicString& summary = static_cast<Element*>(curr->node())->getAttribute(summaryAttr);
const AtomicString& summary = toElement(curr->node())->getAttribute(summaryAttr);
if (!summary.isEmpty())
return summary;
// The title attribute should be used as help text unless it is already being used as descriptive text.
const AtomicString& title = static_cast<Element*>(curr->node())->getAttribute(titleAttr);
const AtomicString& title = toElement(curr->node())->getAttribute(titleAttr);
if (!title.isEmpty() && description != title)
return title;
}
......@@ -817,7 +817,7 @@ LayoutRect AccessibilityRenderObject::checkboxOrRadioRect() const
if (!m_renderer)
return LayoutRect();
HTMLLabelElement* label = labelForElement(static_cast<Element*>(m_renderer->node()));
HTMLLabelElement* label = labelForElement(toElement(m_renderer->node()));
if (!label || !label->renderer())
return boundingBoxRect();
......@@ -1041,10 +1041,10 @@ AccessibilityObject* AccessibilityRenderObject::titleUIElement() const
if (isFieldset())
return axObjectCache()->getOrCreate(toRenderFieldset(m_renderer)->findLegend(RenderFieldset::IncludeFloatingOrOutOfFlow));
Node* element = m_renderer->node();
if (!element)
Node* node = m_renderer->node();
if (!node || !node->isElementNode())
return 0;
HTMLLabelElement* label = labelForElement(static_cast<Element*>(element));
HTMLLabelElement* label = labelForElement(toElement(node));
if (label && label->renderer())
return axObjectCache()->getOrCreate(label);
......@@ -1248,7 +1248,7 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
return false;
if (node && node->isElementNode()) {
Element* elt = static_cast<Element*>(node);
Element* elt = toElement(node);
const AtomicString& alt = elt->getAttribute(altAttr);
// don't ignore an image that has an alt tag
if (!alt.string().containsOnlyWhitespace())
......@@ -1405,7 +1405,7 @@ const AtomicString& AccessibilityRenderObject::accessKey() const
return nullAtom;
if (!node->isElementNode())
return nullAtom;
return static_cast<Element*>(node)->getAttribute(accesskeyAttr);
return toElement(node)->getAttribute(accesskeyAttr);
}
VisibleSelection AccessibilityRenderObject::selection() const
......@@ -1491,7 +1491,7 @@ void AccessibilityRenderObject::setElementAttributeValue(const QualifiedName& at
if (!node || !node->isElementNode())
return;
Element* element = static_cast<Element*>(node);
Element* element = toElement(node);
element->setAttribute(attributeName, (value) ? "true" : "false");
}
......@@ -1627,7 +1627,7 @@ void AccessibilityRenderObject::setValue(const String& string)
{
if (!m_renderer || !m_renderer->node() || !m_renderer->node()->isElementNode())
return;
Element* element = static_cast<Element*>(m_renderer->node());
Element* element = toElement(m_renderer->node());
if (!m_renderer->isBoxModelObject())
return;
......@@ -2268,7 +2268,7 @@ AccessibilityObject* AccessibilityRenderObject::activeDescendant() const
if (m_renderer->node() && !m_renderer->node()->isElementNode())
return 0;
Element* element = static_cast<Element*>(m_renderer->node());
Element* element = toElement(m_renderer->node());
const AtomicString& activeDescendantAttrStr = element->getAttribute(aria_activedescendantAttr);
if (activeDescendantAttrStr.isNull() || activeDescendantAttrStr.isEmpty())
......@@ -2321,7 +2321,7 @@ void AccessibilityRenderObject::handleAriaExpandedChanged()
void AccessibilityRenderObject::handleActiveDescendantChanged()
{
Element* element = static_cast<Element*>(renderer()->node());
Element* element = toElement(renderer()->node());
if (!element)
return;
Document* doc = renderer()->document();
......@@ -2362,7 +2362,7 @@ AccessibilityObject* AccessibilityRenderObject::correspondingLabelForControlElem
Node* node = m_renderer->node();
if (node && node->isHTMLElement()) {
HTMLLabelElement* label = labelForElement(static_cast<Element*>(node));
HTMLLabelElement* label = labelForElement(toElement(node));
if (label)
return axObjectCache()->getOrCreate(label);
}
......@@ -2632,7 +2632,7 @@ bool AccessibilityRenderObject::inheritsPresentationalRole() const
// If native tag of the parent element matches an acceptable name, then return
// based on its presentational status.
if (possibleParentTagNames->contains(static_cast<Element*>(elementNode)->tagQName()))
if (possibleParentTagNames->contains(toElement(elementNode)->tagQName()))
return parent->roleValue() == PresentationalRole;
}
......@@ -3158,7 +3158,7 @@ void AccessibilityRenderObject::setAccessibleName(const AtomicString& name)
domNode = m_renderer->node();
if (domNode && domNode->isElementNode())
static_cast<Element*>(domNode)->setAttribute(aria_labelAttr, name);
toElement(domNode)->setAttribute(aria_labelAttr, name);
}
static bool isLinkable(const AccessibilityRenderObject& object)
......@@ -3281,7 +3281,7 @@ String AccessibilityRenderObject::stringRoleForMSAA() const
if (!node || !node->isElementNode())
return String();
Element* element = static_cast<Element*>(node);
Element* element = toElement(node);
if (!shouldReturnTagNameAsRoleForMSAA(*element))
return String();
......
......@@ -59,7 +59,7 @@ static gpointer createWrapper(Node* node)
if (node->isHTMLElement())
wrappedNode = createHTMLElementWrapper(toHTMLElement(node));
else
wrappedNode = wrapElement(static_cast<Element*>(node));
wrappedNode = wrapElement(toElement(node));
break;
default:
wrappedNode = wrapNode(node);
......
......@@ -103,7 +103,7 @@ JSValue JSClipboard::setDragImage(ExecState* exec)
if (!node->isElementNode())
return throwError(exec, createSyntaxError(exec, "setDragImageFromElement: Invalid first argument"));
if (static_cast<Element*>(node)->hasLocalName(imgTag) && !node->inDocument())
if (toElement(node)->hasLocalName(imgTag) && !node->inDocument())
clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
else
clipboard->setDragImageElement(node, IntPoint(x, y));
......
......@@ -63,7 +63,7 @@ JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Eleme
wrapper = createJSHTMLWrapper(exec, globalObject, toHTMLElement(element));
#if ENABLE(SVG)
else if (element->isSVGElement())
wrapper = createJSSVGWrapper(exec, globalObject, static_cast<SVGElement*>(element));
wrapper = createJSSVGWrapper(exec, globalObject, toSVGElement(element));
#endif
else
wrapper = CREATE_DOM_WRAPPER(exec, globalObject, Element, element);
......
......@@ -218,7 +218,7 @@ static ALWAYS_INLINE JSValue createWrapperInline(ExecState* exec, JSDOMGlobalObj
wrapper = createJSHTMLWrapper(exec, globalObject, toHTMLElement(node));
#if ENABLE(SVG)
else if (node->isSVGElement())
wrapper = createJSSVGWrapper(exec, globalObject, static_cast<SVGElement*>(node));
wrapper = createJSSVGWrapper(exec, globalObject, toSVGElement(node));
#endif
else
wrapper = CREATE_DOM_WRAPPER(exec, globalObject, Element, node);
......
......@@ -97,7 +97,7 @@ v8::Handle<v8::Value> V8Clipboard::setDragImageMethodCustom(const v8::Arguments&
if (!node || !node->isElementNode())
return throwTypeError("setDragImageFromElement: Invalid first argument", args.GetIsolate());
if (static_cast<Element*>(node)->hasLocalName(HTMLNames::imgTag) && !node->inDocument())
if (toElement(node)->hasLocalName(HTMLNames::imgTag) && !node->inDocument())
clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
else
clipboard->setDragImageElement(node, IntPoint(x, y));
......
......@@ -48,9 +48,9 @@ v8::Handle<v8::Object> wrap(Element* impl, v8::Handle<v8::Object> creationContex
return wrap(toHTMLElement(impl), creationContext, isolate);
#if ENABLE(SVG)
if (impl->isSVGElement())
return wrap(static_cast<SVGElement*>(impl), creationContext, isolate);
return wrap(toSVGElement(impl), creationContext, isolate);
#endif
return V8Element::createWrapper(static_cast<Element*>(impl), creationContext, isolate);
return V8Element::createWrapper(impl, creationContext, isolate);
}
}
......@@ -131,7 +131,7 @@ v8::Handle<v8::Object> wrap(Node* impl, v8::Handle<v8::Object> creationContext,
return wrap(toHTMLElement(impl), creationContext, isolate);
#if ENABLE(SVG)
if (impl->isSVGElement())
return wrap(static_cast<SVGElement*>(impl), creationContext, isolate);
return wrap(toSVGElement(impl), creationContext, isolate);
#endif
return V8Element::createWrapper(toElement(impl), creationContext, isolate);
case Node::ATTRIBUTE_NODE:
......
......@@ -942,7 +942,7 @@ PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCo
case COMMENT_NODE:
return createComment(importedNode->nodeValue());
case ELEMENT_NODE: {
Element* oldElement = static_cast<Element*>(importedNode);
Element* oldElement = toElement(importedNode);
// FIXME: The following check might be unnecessary. Is it possible that
// oldElement has mismatched prefix/namespace?
if (!hasValidNamespaceForElements(oldElement->tagQName())) {
......@@ -1831,7 +1831,7 @@ void Document::recalcStyle(StyleChange change)
for (Node* n = firstChild(); n; n = n->nextSibling()) {
if (!n->isElementNode())
continue;
Element* element = static_cast<Element*>(n);
Element* element = toElement(n);
if (change >= Inherit || element->childNeedsStyleRecalc() || element->needsStyleRecalc())
element->recalcStyle(change);
}
......@@ -3336,7 +3336,7 @@ bool Document::setFocusedNode(PassRefPtr<Node> prpNewFocusedNode, FocusDirection
// Dispatch a change event for text fields or textareas that have been edited
if (oldFocusedNode->isElementNode()) {
Element* element = static_cast<Element*>(oldFocusedNode.get());
Element* element = toElement(oldFocusedNode.get());
if (element->wasChangedSinceLastFormControlChangeEvent())
element->dispatchFormControlChangeEvent();
}
......@@ -4721,7 +4721,7 @@ void Document::updateFocusAppearanceTimerFired(Timer<Document>*)
updateLayout();
Element* element = static_cast<Element*>(node);
Element* element = toElement(node);
if (element->isFocusable())
element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
}
......
......@@ -298,7 +298,7 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS
|| (n->isSVGElement() && n->hasTagName(SVGNames::styleTag))
#endif
) {
Element* e = static_cast<Element*>(n);
Element* e = toElement(n);
AtomicString title = e->getAttribute(titleAttr);
bool enabledViaScript = false;
if (e->hasLocalName(linkTag)) {
......
......@@ -541,7 +541,7 @@ Element* Element::offsetParent()
document()->updateLayoutIgnorePendingStylesheets();
if (RenderObject* rend = renderer())
if (RenderObject* offsetParent = rend->offsetParent())
return static_cast<Element*>(offsetParent->node());
return toElement(offsetParent->node());
return 0;
}
......@@ -670,7 +670,7 @@ IntRect Element::boundsInRootViewSpace()
#if ENABLE(SVG)
if (isSVGElement() && renderer()) {
// Get the bounding rectangle from the SVG model.
SVGElement* svgElement = static_cast<SVGElement*>(this);
SVGElement* svgElement = toSVGElement(this);
FloatRect localRect;
if (svgElement->getBoundingBox(localRect))
quads.append(renderer()->localToAbsoluteQuad(localRect));
......@@ -718,7 +718,7 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect()
#if ENABLE(SVG)
if (isSVGElement() && renderer() && !renderer()->isSVGRoot()) {
// Get the bounding rectangle from the SVG model.
SVGElement* svgElement = static_cast<SVGElement*>(this);
SVGElement* svgElement = toSVGElement(this);
FloatRect localRect;
if (svgElement->getBoundingBox(localRect))
quads.append(renderer()->localToAbsoluteQuad(localRect));
......@@ -1439,7 +1439,7 @@ void Element::recalcStyle(StyleChange change)
}
if (!n->isElementNode())
continue;
Element* element = static_cast<Element*>(n);
Element* element = toElement(n);
bool childRulesChanged = element->needsStyleRecalc() && element->styleChangeType() == FullStyleChange;
if ((forceCheckOfNextElementSibling || forceCheckOfAnyElementSibling))
element->setNeedsStyleRecalc();
......@@ -2190,7 +2190,7 @@ AtomicString Element::computeInheritedLanguage() const
// The language property is inherited, so we iterate over the parents to find the first language.
do {
if (n->isElementNode()) {
if (const ElementData* elementData = static_cast<const Element*>(n)->elementData()) {
if (const ElementData* elementData = toElement(n)->elementData()) {
// Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml1/#C_7
if (const Attribute* attribute = elementData->getAttributeItem(XMLNames::langAttr))
value = attribute->value();
......@@ -2302,7 +2302,7 @@ Element* Element::lastElementChild() const
Node* n = lastChild();
while (n && !n->isElementNode())
n = n->previousSibling();
return static_cast<Element*>(n);
return toElement(n);
}
unsigned Element::childElementCount() const
......
......@@ -120,7 +120,7 @@ Node* LiveNodeList::namedItem(const AtomicString& elementId) const
for (unsigned i = 0; i < length; i++) {
Node* node = item(i);
// FIXME: This should probably be using getIdAttribute instead of idForStyleResolution.
if (node->hasID() && static_cast<Element*>(node)->idForStyleResolution() == elementId)
if (node->hasID() && toElement(node)->idForStyleResolution() == elementId)
return node;
}
......
......@@ -201,7 +201,7 @@ void Node::dumpStatistics()
++elementNodes;
// Tag stats
Element* element = static_cast<Element*>(node);
Element* element = toElement(node);
HashMap<String, size_t>::AddResult result = perTagCount.add(element->tagName(), 1);
if (!result.isNewEntry)
result.iterator->value++;
......@@ -589,7 +589,7 @@ void Node::normalize()
while (node) {
NodeType type = node->nodeType();
if (type == ELEMENT_NODE)
static_cast<Element*>(node.get())->normalizeAttributes();
toElement(node.get())->normalizeAttributes();
if (node == this)
break;
......@@ -1318,7 +1318,7 @@ Element* Node::rootEditableElement() const
Element* result = 0;
for (Node* n = const_cast<Node*>(this); n && n->rendererIsEditable(); n = n->parentNode()) {
if (n->isElementNode())
result = static_cast<Element*>(n);
result = toElement(n);
if (n->hasTagName(bodyTag))
break;
}
......@@ -1472,7 +1472,7 @@ bool Node::isDefaultNamespace(const AtomicString& namespaceURIMaybeEmpty) const
switch (nodeType()) {
case ELEMENT_NODE: {
const Element* elem = static_cast<const Element*>(this);
const Element* elem = toElement(this);
if (elem->prefix().isNull())
return elem->namespaceURI() == namespaceURI;
......@@ -1717,7 +1717,7 @@ Element* Node::ancestorElement() const
// In theory, there can be EntityReference nodes between elements, but this is currently not supported.
for (ContainerNode* n = parentNode(); n; n = n->parentNode()) {
if (n->isElementNode())
return static_cast<Element*>(n);
return toElement(n);
}
return 0;
}
......@@ -1868,7 +1868,7 @@ static void appendAttributeDesc(const Node* node, StringBuilder& stringBuilder,
if (!node->isElementNode())
return;
String attr = static_cast<const Element*>(node)->getAttribute(name);
String attr = toElement(node)->getAttribute(name);
if (attr.isEmpty())
return;
......
......@@ -300,7 +300,7 @@ Element* Position::element() const
Node* n = anchorNode();
while (n && !n->isElementNode())
n = n->parentNode();
return static_cast<Element*>(n);
return toElement(n);
}
PassRefPtr<CSSComputedStyleDeclaration> Position::computedStyle() const
......
......@@ -1918,7 +1918,7 @@ void Range::getBorderAndTextQuads(Vector<FloatQuad>& quads) const
for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next(node)) {
if (node->isElementNode()) {
if (!nodeSet.contains(node->parentNode())) {
if (RenderBoxModelObject* renderBoxModelObject = static_cast<Element*>(node)->renderBoxModelObject()) {
if (RenderBoxModelObject* renderBoxModelObject = toElement(node)->renderBoxModelObject()) {
Vector<FloatQuad> elementQuads;
renderBoxModelObject->absoluteQuads(elementQuads);
m_ownerDocument->adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(elementQuads, renderBoxModelObject);
......
......@@ -95,7 +95,7 @@ PassRefPtr<Element> SelectorDataList::queryFirst(Node* rootNode) const
return 0;
ASSERT(result.size() == 1);
ASSERT(result.first()->isElementNode());
return static_cast<Element*>(result.first().get());
return toElement(result.first().get());
}
bool SelectorDataList::canUseIdLookup(Node* rootNode) const
......@@ -140,7 +140,7 @@ void SelectorDataList::execute(Node* rootNode, Vector<RefPtr<Node> >& matchedEle
Node* n = rootNode->firstChild();
while (n) {
if (n->isElementNode()) {
Element* element = static_cast<Element*>(n);
Element* element = toElement(n);
for (unsigned i = 0; i < selectorCount; ++i) {
if (selectorMatches(m_selectors[i], element, rootNode)) {
matchedElements.append(element);
......
......@@ -140,7 +140,7 @@ void ShadowRoot::recalcStyle(StyleChange change)
for (Node* child = firstChild(); child; child = child->nextSibling()) {
if (child->isElementNode())
static_cast<Element*>(child)->recalcStyle(change);
toElement(child)->recalcStyle(change);
else if (child->isTextNode())
toText(child)->recalcTextStyle(change);
}
......
......@@ -69,7 +69,7 @@ Node* StaticHashSetNodeList::namedItem(const AtomicString& elementId) const
ListHashSet<RefPtr<Node> >::const_iterator end = m_nodes.end();