Replace static_casts with to* helper functions.
authorinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2013 16:08:06 +0000 (16:08 +0000)
committerinferno@chromium.org <inferno@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2013 16:08:06 +0000 (16:08 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@145818 268f45cc-cd09-0410-ab3c-d52691b4dbfc

88 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/bindings/gobject/WebKitDOMBinding.cpp
Source/WebCore/bindings/js/JSClipboardCustom.cpp
Source/WebCore/bindings/js/JSElementCustom.cpp
Source/WebCore/bindings/js/JSNodeCustom.cpp
Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp
Source/WebCore/bindings/v8/custom/V8ElementCustom.cpp
Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentStyleSheetCollection.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/LiveNodeList.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Position.cpp
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/SelectorQuery.cpp
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/StaticHashSetNodeList.cpp
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/IndentOutdentCommand.cpp
Source/WebCore/editing/MarkupAccumulator.cpp
Source/WebCore/editing/ModifySelectionListLevel.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/SplitTextNodeContainingElementCommand.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/editing/markup.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLObjectElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLViewSourceDocument.cpp
Source/WebCore/html/parser/HTMLTreeBuilder.cpp
Source/WebCore/html/shadow/MediaControlElementTypes.cpp
Source/WebCore/html/shadow/TextFieldDecorationElement.h
Source/WebCore/inspector/DOMPatchSupport.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/mathml/MathMLElement.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/SpatialNavigation.cpp
Source/WebCore/page/animation/ImplicitAnimation.cpp
Source/WebCore/page/animation/KeyframeAnimation.cpp
Source/WebCore/platform/efl/RenderThemeEfl.cpp
Source/WebCore/rendering/FilterEffectRenderer.cpp
Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/xml/XPathStep.cpp
Source/WebCore/xml/parser/XMLDocumentParserQt.cpp
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp
Source/WebKit/blackberry/WebKitSupport/BackingStoreClient.cpp
Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
Source/WebKit/blackberry/WebKitSupport/FatFingers.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebDocument.cpp
Source/WebKit/chromium/src/WebElement.cpp
Source/WebKit/chromium/src/WebPageSerializer.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
Source/WebKit/qt/Api/qwebelement.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp

index 464fc4a..fdcaedc 100644 (file)
@@ -1,3 +1,181 @@
+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.
index ee95c49..3c5e4d4 100644 (file)
@@ -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)
index d3290f2..79b9bb9 100644 (file)
@@ -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);
 }
     
index e5f0589..56ae5df 100644 (file)
@@ -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();
 
index a8a8114..d4db6f6 100644 (file)
@@ -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);
index e36c603..f37dcb9 100644 (file)
@@ -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));
index 2c5fe2a..021f0a6 100644 (file)
@@ -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);
index 0f74aa5..7124be4 100644 (file)
@@ -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);
index c65aa17..6271d95 100644 (file)
@@ -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));
index 4f27114..dbefd4d 100644 (file)
@@ -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);
 }
 
 }
index e0df2b2..d3180fa 100644 (file)
@@ -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:
index 014bc72..45d7a0b 100644 (file)
@@ -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);
 }
index 3ac1f5e..232b5e2 100644 (file)
@@ -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)) {
index 2eb9d40..e436cbc 100644 (file)
@@ -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
index 4d9543e..9897e5c 100644 (file)
@@ -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;
     }
 
index e0f9632..30d13e6 100644 (file)
@@ -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;
 
index 3ef9b55..9c25209 100644 (file)
@@ -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
index a389d8a..3e56cb0 100644 (file)
@@ -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);
index b9379f9..f335621 100644 (file)
@@ -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);
index 1143ba3..542edcf 100644 (file)
@@ -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);
     }
index ad4a9a4..b6de99e 100644 (file)
@@ -69,7 +69,7 @@ Node* StaticHashSetNodeList::namedItem(const AtomicString& elementId) const
     ListHashSet<RefPtr<Node> >::const_iterator end = m_nodes.end();
     for ( ; it != end ; ++it) {
         Node* node = (*it).get();
-        if (static_cast<Element*>(node)->getIdAttribute() == elementId)
+        if (toElement(node)->getIdAttribute() == elementId)
             return node;
     }
 
index c26cd9f..62f3662 100644 (file)
@@ -484,7 +484,7 @@ HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool b
     // Split every ancestor through highest ancestor with embedding.
     Node* n = node;
     while (true) {
-        Element* parent = static_cast<Element*>(n->parentNode());
+        Element* parent = toElement(n->parentNode());
         if (before ? n->previousSibling() : n->nextSibling())
             splitElement(parent, before ? n : n->nextSibling());
         if (parent == highestAncestorWithUnicodeBidi)
@@ -1032,7 +1032,7 @@ void ApplyStyleCommand::pushDownInlineStyleAroundNode(EditingStyle* style, Node*
         NodeVector currentChildren;
         getChildNodes(current.get(), currentChildren);
         RefPtr<StyledElement> styledElement;
-        if (current->isStyledElement() && isStyledInlineElementToRemove(static_cast<Element*>(current.get()))) {
+        if (current->isStyledElement() && isStyledInlineElementToRemove(toElement(current.get()))) {
             styledElement = static_cast<StyledElement*>(current.get());
             elementsToPushDown.append(styledElement);
         }
@@ -1269,8 +1269,8 @@ bool ApplyStyleCommand::mergeStartWithPreviousIfIdentical(const Position& start,
     Node* previousSibling = startNode->previousSibling();
 
     if (previousSibling && areIdenticalElements(startNode, previousSibling)) {
-        Element* previousElement = static_cast<Element*>(previousSibling);
-        Element* element = static_cast<Element*>(startNode);
+        Element* previousElement = toElement(previousSibling);
+        Element* element = toElement(startNode);
         Node* startChild = element->firstChild();
         ASSERT(startChild);
         mergeIdenticalElements(previousElement, element);
@@ -1348,14 +1348,14 @@ void ApplyStyleCommand::surroundNodeRangeWithElement(PassRefPtr<Node> passedStar
     RefPtr<Node> nextSibling = element->nextSibling();
     RefPtr<Node> previousSibling = element->previousSibling();
     if (nextSibling && nextSibling->isElementNode() && nextSibling->rendererIsEditable()
-        && areIdenticalElements(element.get(), static_cast<Element*>(nextSibling.get())))
-        mergeIdenticalElements(element.get(), static_cast<Element*>(nextSibling.get()));
+        && areIdenticalElements(element.get(), toElement(nextSibling.get())))
+        mergeIdenticalElements(element.get(), toElement(nextSibling.get()));
 
     if (previousSibling && previousSibling->isElementNode() && previousSibling->rendererIsEditable()) {
         Node* mergedElement = previousSibling->nextSibling();
         if (mergedElement->isElementNode() && mergedElement->rendererIsEditable()
-            && areIdenticalElements(static_cast<Element*>(previousSibling.get()), static_cast<Element*>(mergedElement)))
-            mergeIdenticalElements(static_cast<Element*>(previousSibling.get()), static_cast<Element*>(mergedElement));
+            && areIdenticalElements(toElement(previousSibling.get()), toElement(mergedElement)))
+            mergeIdenticalElements(toElement(previousSibling.get()), toElement(mergedElement));
     }
 
     // FIXME: We should probably call updateStartEnd if the start or end was in the node
index 2b5dbd2..b5b5a03 100644 (file)
@@ -2721,7 +2721,7 @@ void Editor::applyEditingStyleToBodyElement() const
     RefPtr<NodeList> list = m_frame->document()->getElementsByTagName("body");
     unsigned len = list->length();
     for (unsigned i = 0; i < len; i++)
-        applyEditingStyleToElement(static_cast<Element*>(list->item(i)));
+        applyEditingStyleToElement(toElement(list->item(i)));
 }
 
 void Editor::applyEditingStyleToElement(Element* element) const
index 18de1d8..f02683a 100644 (file)
@@ -354,7 +354,7 @@ static bool removingNodeRemovesPosition(Node* node, const Position& position)
     if (!node->isElementNode())
         return false;
 
-    Element* element = static_cast<Element*>(node);
+    Element* element = toElement(node);
     return element->containsIncludingShadowDOM(position.anchorNode());
 }
 
index 5eb1894..7523056 100644 (file)
@@ -158,7 +158,7 @@ void IndentOutdentCommand::outdentParagraph()
                 if (splitPointParent->hasTagName(blockquoteTag)
                     && !splitPoint->hasTagName(blockquoteTag)
                     && splitPointParent->parentNode()->rendererIsEditable()) // We can't outdent if there is no place to go!
-                    splitElement(static_cast<Element*>(splitPointParent), splitPoint);
+                    splitElement(toElement(splitPointParent), splitPoint);
             }
         }
 
@@ -179,7 +179,7 @@ void IndentOutdentCommand::outdentParagraph()
     else {
         // We split the blockquote at where we start outdenting.
         Node* highestInlineNode = highestEnclosingNodeOfType(visibleStartOfParagraph.deepEquivalent(), isInline, CannotCrossEditingBoundary, enclosingBlockFlow);
-        splitElement(static_cast<Element*>(enclosingNode), (highestInlineNode) ? highestInlineNode : visibleStartOfParagraph.deepEquivalent().deprecatedNode());
+        splitElement(toElement(enclosingNode), (highestInlineNode) ? highestInlineNode : visibleStartOfParagraph.deepEquivalent().deprecatedNode());
     }
     RefPtr<Node> placeholder = createBreakElement(document());
     insertNodeBefore(placeholder, splitBlockquoteNode);
index 05811ea..a8571c7 100644 (file)
@@ -315,7 +315,7 @@ EntityMask MarkupAccumulator::entityMaskForText(Text* text) const
 {
     const QualifiedName* parentName = 0;
     if (text->parentElement())
-        parentName = &static_cast<Element*>(text->parentElement())->tagQName();
+        parentName = &(text->parentElement())->tagQName();
 
     if (parentName && (*parentName == scriptTag || *parentName == styleTag || *parentName == xmpTag))
         return EntityMaskInCDATA;
@@ -512,7 +512,7 @@ void MarkupAccumulator::appendStartMarkup(StringBuilder& result, const Node* nod
         appendProcessingInstruction(result, static_cast<const ProcessingInstruction*>(node)->target(), static_cast<const ProcessingInstruction*>(node)->data());
         break;
     case Node::ELEMENT_NODE:
-        appendElement(result, static_cast<Element*>(const_cast<Node*>(node)), namespaces);
+        appendElement(result, toElement(const_cast<Node*>(node)), namespaces);
         break;
     case Node::CDATA_SECTION_NODE:
         appendCDATASection(result, static_cast<const CDATASection*>(node)->data());
@@ -562,7 +562,7 @@ void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node* node)
 
     result.append('<');
     result.append('/');
-    result.append(static_cast<const Element*>(node)->nodeNamePreservingCase());
+    result.append(toElement(node)->nodeNamePreservingCase());
     result.append('>');
 }
 
index 596c048..be6181c 100644 (file)
@@ -178,7 +178,7 @@ void IncreaseSelectionListLevelCommand::doApply()
     Node* previousItem = startListChild->renderer()->previousSibling()->node();
     if (isListElement(previousItem)) {
         // move nodes up into preceding list
-        appendSiblingNodeRange(startListChild, endListChild, static_cast<Element*>(previousItem));
+        appendSiblingNodeRange(startListChild, endListChild, toElement(previousItem));
         m_listElement = previousItem;
     } else {
         // create a sublist for the preceding element and move nodes there
index 7805a01..f04baf1 100644 (file)
@@ -444,7 +444,7 @@ static bool isHeaderElement(const Node* a)
 
 static bool haveSameTagName(Node* a, Node* b)
 {
-    return a && b && a->isElementNode() && b->isElementNode() && toElement(a)->tagName() == static_cast<Element*>(b)->tagName();
+    return a && b && a->isElementNode() && b->isElementNode() && toElement(a)->tagName() == toElement(b)->tagName();
 }
 
 bool ReplaceSelectionCommand::shouldMerge(const VisiblePosition& source, const VisiblePosition& destination)
@@ -736,7 +736,7 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
 
     // FIXME: This string comparison is a naive way of comparing two styles.
     // We should be taking the diff and check that the diff is empty.
-    if (styleText != static_cast<Element*>(wrappingStyleSpan)->getAttribute(styleAttr))
+    if (styleText != toElement(wrappingStyleSpan)->getAttribute(styleAttr))
         return false;
 
     fragment.removeNodePreservingChildren(wrappingStyleSpan);
@@ -1211,7 +1211,7 @@ void ReplaceSelectionCommand::doApply()
         mergeEndIfNeeded();
 
     if (Node* mailBlockquote = enclosingNodeOfType(positionAtStartOfInsertedContent().deepEquivalent(), isMailPasteAsQuotationNode))
-        removeNodeAttribute(static_cast<Element*>(mailBlockquote), classAttr);
+        removeNodeAttribute(toElement(mailBlockquote), classAttr);
 
     if (shouldPerformSmartReplace())
         addSpacesForSmartReplace();
index 7b9fd2a..ef1476a 100644 (file)
@@ -57,7 +57,7 @@ void SplitTextNodeContainingElementCommand::doApply()
         Node* firstChild = parent->firstChild();
         if (!firstChild || !firstChild->isElementNode())
             return;
-        parent = static_cast<Element*>(firstChild);
+        parent = toElement(firstChild);
     }
 
     splitElement(parent, m_text);
index da76ad4..0094910 100644 (file)
@@ -408,10 +408,10 @@ void TextIterator::advance()
                     m_handledNode = handleTextNode();
                 else if (renderer && (renderer->isImage() || renderer->isWidget() ||
                          (renderer->node() && renderer->node()->isElementNode() &&
-                          (static_cast<Element*>(renderer->node())->isFormControlElement()
-                          || static_cast<Element*>(renderer->node())->hasTagName(legendTag)
-                          || static_cast<Element*>(renderer->node())->hasTagName(meterTag)
-                          || static_cast<Element*>(renderer->node())->hasTagName(progressTag)))))
+                          (toElement(renderer->node())->isFormControlElement()
+                          || toElement(renderer->node())->hasTagName(legendTag)
+                          || toElement(renderer->node())->hasTagName(meterTag)
+                          || toElement(renderer->node())->hasTagName(progressTag)))))
                     m_handledNode = handleReplacedElement();
                 else
                     m_handledNode = handleNonTextNode();
index e85edc6..2aaa730 100644 (file)
@@ -199,7 +199,7 @@ Element* unsplittableElementForPosition(const Position& p)
 {
     // Since enclosingNodeOfType won't search beyond the highest root editable node,
     // this code works even if the closest table cell was outside of the root editable node.
-    Element* enclosingCell = static_cast<Element*>(enclosingNodeOfType(p, &isTableCell));
+    Element* enclosingCell = toElement(enclosingNodeOfType(p, &isTableCell));
     if (enclosingCell)
         return enclosingCell;
 
@@ -671,7 +671,7 @@ Node* highestNodeToRemoveInPruning(Node* node)
 
 Node* enclosingTableCell(const Position& p)
 {
-    return static_cast<Element*>(enclosingNodeOfType(p, isTableCell));
+    return toElement(enclosingNodeOfType(p, isTableCell));
 }
 
 Node* enclosingAnchorElement(const Position& p)
index 6a3b2a0..3ffdaae 100644 (file)
@@ -171,7 +171,7 @@ void StyledMarkupAccumulator::wrapWithNode(Node* node, bool convertBlocksToInlin
 {
     StringBuilder markup;
     if (node->isElementNode())
-        appendElement(markup, static_cast<Element*>(node), convertBlocksToInlines && isBlock(const_cast<Node*>(node)), rangeFullySelectsNode);
+        appendElement(markup, toElement(node), convertBlocksToInlines && isBlock(const_cast<Node*>(node)), rangeFullySelectsNode);
     else
         appendStartMarkup(markup, node, 0);
     m_reversedPrecedingMarkup.append(markup.toString());
@@ -604,8 +604,8 @@ static String createMarkupInternal(Document* document, const Range* range, const
                 // Bring the background attribute over, but not as an attribute because a background attribute on a div
                 // appears to have no effect.
                 if ((!fullySelectedRootStyle || !fullySelectedRootStyle->style() || !fullySelectedRootStyle->style()->getPropertyCSSValue(CSSPropertyBackgroundImage))
-                    && static_cast<Element*>(fullySelectedRoot)->hasAttribute(backgroundAttr))
-                    fullySelectedRootStyle->style()->setProperty(CSSPropertyBackgroundImage, "url('" + static_cast<Element*>(fullySelectedRoot)->getAttribute(backgroundAttr) + "')");
+                    && toElement(fullySelectedRoot)->hasAttribute(backgroundAttr))
+                    fullySelectedRootStyle->style()->setProperty(CSSPropertyBackgroundImage, "url('" + toElement(fullySelectedRoot)->getAttribute(backgroundAttr) + "')");
 
                 if (fullySelectedRootStyle->style()) {
                     // Reset the CSS properties to avoid an assertion error in addStyleMarkup().
@@ -760,7 +760,7 @@ PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document* docum
     if (specialCommonAncestor)
         fragment->appendChild(specialCommonAncestor, ASSERT_NO_EXCEPTION);
     else
-        fragment->takeAllChildrenFrom(static_cast<ContainerNode*>(commonAncestor));
+        fragment->takeAllChildrenFrom(toContainerNode(commonAncestor));
 
     trimFragment(fragment.get(), nodeBeforeContext.get(), nodeAfterContext.get());
 
@@ -826,7 +826,7 @@ static void fillContainerFromString(ContainerNode* paragraph, const String& stri
 
 bool isPlainTextMarkup(Node *node)
 {
-    if (!node->isElementNode() || !node->hasTagName(divTag) || static_cast<Element*>(node)->hasAttributes())
+    if (!node->isElementNode() || !node->hasTagName(divTag) || toElement(node)->hasAttributes())
         return false;
     
     if (node->childNodeCount() == 1 && (node->firstChild()->isTextNode() || (node->firstChild()->firstChild())))
@@ -876,7 +876,7 @@ PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String
 
     // Break string into paragraphs. Extra line breaks turn into empty paragraphs.
     Node* blockNode = enclosingBlock(context->firstNode());
-    Element* block = static_cast<Element*>(blockNode);
+    Element* block = toElement(blockNode);
     bool useClonesOfEnclosingBlock = blockNode
         && blockNode->isElementNode()
         && !block->hasTagName(bodyTag)
index da7ac43..ac88213 100644 (file)
@@ -563,7 +563,7 @@ Element* HTMLElement::insertAdjacentElement(const String& where, Element* newChi
 
     Node* returnValue = insertAdjacent(where, newChild, ec);
     ASSERT_WITH_SECURITY_IMPLICATION(!returnValue || returnValue->isElementNode());
-    return static_cast<Element*>(returnValue); 
+    return toElement(returnValue); 
 }
 
 // Step 3 of http://www.whatwg.org/specs/web-apps/current-work/multipage/apis-in-html-documents.html#insertadjacenthtml()
@@ -576,7 +576,7 @@ static Element* contextElementForInsertion(const String& where, Element* element
             return 0;
         }
         ASSERT_WITH_SECURITY_IMPLICATION(!parent || parent->isElementNode());
-        return static_cast<Element*>(parent);
+        return toElement(parent);
     }
     if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "beforeEnd"))
         return element;
index 5156b1d..e60b743 100644 (file)
@@ -204,7 +204,7 @@ static bool shouldAutofocus(HTMLFormControlElement* element)
 
 static void focusPostAttach(Node* element, unsigned)
 { 
-    static_cast<Element*>(element)->focus(); 
+    toElement(element)->focus(); 
     element->deref(); 
 }
 
@@ -294,7 +294,7 @@ bool HTMLFormControlElement::isRequired() const
 static void updateFromElementCallback(Node* node, unsigned)
 {
     ASSERT_ARG(node, node->isElementNode());
-    ASSERT_ARG(node, static_cast<Element*>(node)->isFormControlElement());
+    ASSERT_ARG(node, toElement(node)->isFormControlElement());
     if (RenderObject* renderer = node->renderer())
         renderer->updateFromElement();
 }
index ceb12d1..77fdbfb 100644 (file)
@@ -208,7 +208,7 @@ static inline HTMLFormControlElement* submitElementFromEvent(const Event* event)
     Node* targetNode = event->target()->toNode();
     if (!targetNode || !targetNode->isElementNode())
         return 0;
-    Element* targetElement = static_cast<Element*>(targetNode);
+    Element* targetElement = toElement(targetNode);
     if (!targetElement->isFormControlElement())
         return 0;
     return static_cast<HTMLFormControlElement*>(targetElement);
index ecb0297..cd72a03 100644 (file)
@@ -430,7 +430,7 @@ void HTMLObjectElement::updateDocNamedItem()
     Node* child = firstChild();
     while (child && isNamedItem) {
         if (child->isElementNode()) {
-            Element* element = static_cast<Element*>(child);
+            Element* element = toElement(child);
             // FIXME: Use of isRecognizedTagName is almost certainly wrong here.
             if (isRecognizedTagName(element->tagQName()) && !element->hasTagName(paramTag))
                 isNamedItem = false;
index a1fac0c..8f76389 100644 (file)
@@ -336,7 +336,7 @@ void HTMLPlugInImageElement::updateSnapshotInfo()
     if (!root)
         return;
 
-    Element* shadowContainer = static_cast<Element*>(root->firstChild());
+    Element* shadowContainer = toElement(root->firstChild());
     shadowContainer->setAttribute(classAttr, classNameForShadowRoot(this, m_isPrimarySnapshottedPlugIn));
 }
 
index 6948031..e5cd64b 100644 (file)
@@ -278,7 +278,7 @@ int HTMLViewSourceDocument::addRange(const String& source, int start, int end, c
     }
     addText(text, className);
     if (!className.isEmpty() && m_current != m_tbody)
-        m_current = static_cast<Element*>(m_current->parentNode());
+        m_current = toElement(m_current->parentNode());
     return end;
 }
 
index a81a207..953329b 100644 (file)
@@ -142,7 +142,7 @@ static HTMLFormElement* closestFormAncestor(Element* element)
         ContainerNode* parent = element->parentNode();
         if (!parent || !parent->isElementNode())
             return 0;
-        element = static_cast<Element*>(parent);
+        element = toElement(parent);
     }
     return 0;
 }
index 9a990a2..1ed679c 100644 (file)
@@ -60,7 +60,7 @@ HTMLMediaElement* toParentMediaElement(Node* node)
     Node* mediaNode = node->shadowHost();
     if (!mediaNode)
         mediaNode = node;
-    if (!mediaNode || !mediaNode->isElementNode() || !static_cast<Element*>(mediaNode)->isMediaElement())
+    if (!mediaNode || !mediaNode->isElementNode() || !toElement(mediaNode)->isMediaElement())
         return 0;
 
     return static_cast<HTMLMediaElement*>(mediaNode);
index 221e679..a2ca8ad 100644 (file)
@@ -96,7 +96,7 @@ inline TextFieldDecorationElement* toTextFieldDecorationElement(Node* node)
 {
     ASSERT(node);
     ASSERT_WITH_SECURITY_IMPLICATION(node->isElementNode());
-    ASSERT_WITH_SECURITY_IMPLICATION(static_cast<Element*>(node)->isTextFieldDecoration());
+    ASSERT_WITH_SECURITY_IMPLICATION(toElement(node)->isTextFieldDecoration());
     return static_cast<TextFieldDecorationElement*>(node);
 }
 
index 3dadc28..886a4ef 100644 (file)
@@ -417,7 +417,7 @@ PassOwnPtr<DOMPatchSupport::Digest> DOMPatchSupport::createDigest(Node* node, Un
             child = child->nextSibling();
             digest->m_children.append(childInfo.release());
         }
-        Element* element = static_cast<Element*>(node);
+        Element* element = toElement(node);
 
         if (element->hasAttributesWithoutUpdate()) {
             size_t numAttrs = element->attributeCount();
index 1090fe5..501649e 100644 (file)
@@ -1328,7 +1328,7 @@ PassRefPtr<TypeBuilder::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node* n
     }
 
     if (node->isElementNode()) {
-        Element* element = static_cast<Element*>(node);
+        Element* element = toElement(node);
         value->setAttributes(buildArrayForElementAttributes(element));
         if (node->isFrameOwnerElement()) {
             HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(node);
@@ -1654,7 +1654,7 @@ void InspectorDOMAgent::didInvalidateStyleAttr(Node* node)
 
     if (!m_revalidateStyleAttrTask)
         m_revalidateStyleAttrTask = adoptPtr(new RevalidateStyleAttributeTask(this));
-    m_revalidateStyleAttrTask->scheduleFor(static_cast<Element*>(node));
+    m_revalidateStyleAttrTask->scheduleFor(toElement(node));
 }
 
 void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root)
index da0585f..dcd430c 100644 (file)
@@ -1370,7 +1370,7 @@ bool InspectorStyleSheet::inlineStyleSheetText(String* result) const
     Node* ownerNode = m_pageStyleSheet->ownerNode();
     if (!ownerNode || ownerNode->nodeType() != Node::ELEMENT_NODE)
         return false;
-    Element* ownerElement = static_cast<Element*>(ownerNode);
+    Element* ownerElement = toElement(ownerNode);
 
     if (!ownerElement->hasTagName(HTMLNames::styleTag)
 #if ENABLE(SVG)
index 3fca697..47032aa 100644 (file)
@@ -54,7 +54,7 @@ private:
 
 inline MathMLElement* toMathMLElement(Node* node)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || (node->isElementNode() && static_cast<Element*>(node)->isMathMLElement()));
+    ASSERT_WITH_SECURITY_IMPLICATION(!node || (node->isElementNode() && toElement(node)->isMathMLElement()));
     return static_cast<MathMLElement*>(node);
 }
 
index 9c5b13c..5667c0b 100644 (file)
@@ -799,7 +799,7 @@ void ContextMenuController::populate()
     if (!node)
         return;
 #if PLATFORM(GTK)
-    if (!m_hitTestResult.isContentEditable() && (node->isElementNode() && static_cast<Element*>(node)->isFormControlElement()))
+    if (!m_hitTestResult.isContentEditable() && (node->isElementNode() && toElement(node)->isFormControlElement()))
         return;
 #endif
     Frame* frame = node->document()->frame();
index ccc4cf6..0404594 100644 (file)
@@ -307,7 +307,7 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint&
     if (n)
         n = n->deprecatedShadowAncestorNode();
 
-    return static_cast<Element*>(n);
+    return toElement(n);
 }
 
 bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction actionMask, DragSession& dragSession)
@@ -785,7 +785,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
 
     Node* node = state.m_dragSrc.get();
 
-    Image* image = getImage(static_cast<Element*>(node));
+    Image* image = node->isElementNode() ? getImage(toElement(node)) : 0;
     if (state.m_dragType == DragSourceActionSelection) {
         if (!clipboard->hasData()) {
             if (enclosingTextFormControl(src->selection()->start()))
@@ -809,7 +809,7 @@ bool DragController::startDrag(Frame* src, const DragState& state, DragOperation
         // We shouldn't be starting a drag for an image that can't provide an extension.
         // This is an early detection for problems encountered later upon drop.
         ASSERT(!image->filenameExtension().isEmpty());
-        Element* element = static_cast<Element*>(node);
+        Element* element = toElement(node);
         if (!clipboard->hasData()) {
             m_draggingImageURL = imageURL;
             prepareClipboardForImageDrag(src, clipboard, element, linkURL, imageURL, hitTestResult.altDisplayString());
index e811ea1..1355bb7 100644 (file)
@@ -353,7 +353,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
             frame->selection()->setSelection(newSelection);
     }
 
-    static_cast<Element*>(node.get())->focus(false, direction);
+    toElement(node.get())->focus(false, direction);
     return true;
 }
 
index 2e8d1be..7e70fb5 100644 (file)
@@ -422,7 +422,7 @@ String Frame::searchForLabelsBeforeElement(const Vector<String>& labels, Element
     Node* n;
     for (n = NodeTraversal::previous(element); n && lengthSearched < charsSearchedThreshold; n = NodeTraversal::previous(n)) {
         if (n->hasTagName(formTag)
-            || (n->isHTMLElement() && static_cast<Element*>(n)->isFormControlElement()))
+            || (n->isHTMLElement() && toElement(n)->isFormControlElement()))
         {
             // We hit another form element or the start of the form - bail out
             break;
index 664be07..24371bc 100644 (file)
@@ -2519,7 +2519,7 @@ void FrameView::scrollToAnchor()
 void FrameView::updateWidget(RenderObject* object)
 {
     ASSERT(!object->node() || object->node()->isElementNode());
-    Element* ownerElement = static_cast<Element*>(object->node());
+    Element* ownerElement = toElement(object->node());
     // The object may have already been destroyed (thus node cleared),
     // but FrameView holds a manual ref, so it won't have been deleted.
     ASSERT(m_widgetUpdateSet->contains(object));
index 6007fc7..d10d19d 100644 (file)
@@ -506,7 +506,7 @@ static LayoutRect rectToAbsoluteCoordinates(Frame* initialFrame, const LayoutRec
 {
     LayoutRect rect = initialRect;
     for (Frame* frame = initialFrame; frame; frame = frame->tree()->parent()) {
-        if (Element* element = static_cast<Element*>(frame->ownerElement())) {
+        if (Element* element = frame->ownerElement()) {
             do {
                 rect.move(element->offsetLeft(), element->offsetTop());
             } while ((element = element->offsetParent()));
index 78176b8..37a2f72 100644 (file)
@@ -163,7 +163,7 @@ bool ImplicitAnimation::sendTransitionEvent(const AtomicString& eventType, doubl
             // Dispatch the event
             RefPtr<Element> element = 0;
             if (m_object->node() && m_object->node()->isElementNode())
-                element = static_cast<Element*>(m_object->node());
+                element = toElement(m_object->node());
 
             ASSERT(!element || (element->document() && !element->document()->inPageCache()));
             if (!element)
index 2d97f7b..0425a52 100644 (file)
@@ -52,7 +52,7 @@ KeyframeAnimation::KeyframeAnimation(const Animation* animation, RenderObject* r
 {
     // Get the keyframe RenderStyles
     if (m_object && m_object->node() && m_object->node()->isElementNode())
-        m_object->document()->styleResolver()->keyframeStylesForAnimation(static_cast<Element*>(m_object->node()), unanimatedStyle, m_keyframes);
+        m_object->document()->styleResolver()->keyframeStylesForAnimation(toElement(m_object->node()), unanimatedStyle, m_keyframes);
 
     // Update the m_transformFunctionListValid flag based on whether the function lists in the keyframes match.
     validateTransformFunctionList();
@@ -312,7 +312,7 @@ bool KeyframeAnimation::sendAnimationEvent(const AtomicString& eventType, double
         // Dispatch the event
         RefPtr<Element> element;
         if (m_object->node() && m_object->node()->isElementNode())
-            element = static_cast<Element*>(m_object->node());
+            element = toElement(m_object->node());
 
         ASSERT(!element || (element->document() && !element->document()->inPageCache()));
         if (!element)
index 3df39f5..958fe95 100644 (file)
@@ -1093,7 +1093,7 @@ bool RenderThemeEfl::paintMediaFullscreenButton(RenderObject* object, const Pain
     Node* mediaNode = object->node() ? object->node()->shadowHost() : 0;
     if (!mediaNode)
         mediaNode = object->node();
-    if (!mediaNode || !mediaNode->isElementNode() || !static_cast<Element*>(mediaNode)->isMediaElement())
+    if (!mediaNode || !mediaNode->isElementNode() || !toElement(mediaNode)->isMediaElement())
         return false;
 
     HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode);
@@ -1108,7 +1108,7 @@ bool RenderThemeEfl::paintMediaMuteButton(RenderObject* object, const PaintInfo&
     Node* mediaNode = object->node() ? object->node()->shadowHost() : 0;
     if (!mediaNode)
         mediaNode = object->node();
-    if (!mediaNode || !mediaNode->isElementNode() || !static_cast<Element*>(mediaNode)->isMediaElement())
+    if (!mediaNode || !mediaNode->isElementNode() || !toElement(mediaNode)->isMediaElement())
         return false;
 
     HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode);
index aa460b8..2de91c4 100644 (file)
@@ -162,7 +162,7 @@ PassRefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(RenderObject
         if (!node->isSVGElement())
             continue;
 
-        SVGElement* element = static_cast<SVGElement*>(node);
+        SVGElement* element = toSVGElement(node);
         if (!element->isFilterEffect())
             continue;
 
index c5a8b3b..7e7f1cc 100644 (file)
@@ -58,7 +58,7 @@ void RenderSVGViewportContainer::applyViewportClip(PaintInfo& paintInfo)
 
 void RenderSVGViewportContainer::calcViewport()
 {
-    SVGElement* element = static_cast<SVGElement*>(node());
+    SVGElement* element = toSVGElement(node());
     if (!element->hasTagName(SVGNames::svgTag))
         return;
     SVGSVGElement* svg = toSVGSVGElement(element);
index 577cea3..f6ec8b3 100644 (file)
@@ -793,7 +793,7 @@ Element* SVGSVGElement::getElementById(const AtomicString& id) const
         if (!node->isElementNode())
             continue;
 
-        Element* element = static_cast<Element*>(node);
+        Element* element = toElement(node);
         if (element->getIdAttribute() == id)
             return element;
     }
index f40ab3b..e331a95 100644 (file)
@@ -349,7 +349,7 @@ static bool isDisallowedElement(Node* node)
     if (!node->isSVGElement())
         return true;
 
-    Element* element = static_cast<Element*>(node);
+    Element* element = toElement(node);
 
     DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, allowedElementTags, ());
     if (allowedElementTags.isEmpty()) {
index 74bd95b..38f151f 100644 (file)
@@ -165,7 +165,7 @@ void SVGSMILElement::buildPendingResource()
     String href = getAttribute(XLinkNames::hrefAttr);
     Element* target;
     if (href.isEmpty())
-        target = parentNode() && parentNode()->isElementNode() ? static_cast<Element*>(parentNode()) : 0;
+        target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : 0;
     else
         target = SVGURIReference::targetElementFromIRIString(href, document(), &id);
     SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(target) : 0;
index 594d490..154dcd8 100644 (file)
@@ -195,12 +195,12 @@ static inline bool nodeMatchesBasicTest(Node* node, Step::Axis axis, const Step:
             if (node->document()->isHTMLDocument()) {
                 if (node->isHTMLElement()) {
                     // Paths without namespaces should match HTML elements in HTML documents despite those having an XHTML namespace. Names are compared case-insensitively.
-                    return equalIgnoringCase(static_cast<Element*>(node)->localName(), name) && (namespaceURI.isNull() || namespaceURI == node->namespaceURI());
+                    return equalIgnoringCase(toElement(node)->localName(), name) && (namespaceURI.isNull() || namespaceURI == node->namespaceURI());
                 }
                 // An expression without any prefix shouldn't match no-namespace nodes (because HTML5 says so).
-                return static_cast<Element*>(node)->hasLocalName(name) && namespaceURI == node->namespaceURI() && !namespaceURI.isNull();
+                return toElement(node)->hasLocalName(name) && namespaceURI == node->namespaceURI() && !namespaceURI.isNull();
             }
-            return static_cast<Element*>(node)->hasLocalName(name) && namespaceURI == node->namespaceURI();
+            return toElement(node)->hasLocalName(name) && namespaceURI == node->namespaceURI();
         }
     }
     ASSERT_NOT_REACHED();
index 91f06d4..a60ef1d 100644 (file)
@@ -138,7 +138,7 @@ XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent
         Node* n = parentElement->parentNode();
         if (!n || !n->isElementNode())
             break;
-        parentElement = static_cast<Element*>(n);
+        parentElement = toElement(n);
     }
 
     if (elemStack.isEmpty())
@@ -510,7 +510,7 @@ void XMLDocumentParser::parseEndElement()
     RefPtr<ContainerNode> n = m_currentNode;
     n->finishParsingChildren();
 
-    if (!scriptingContentIsAllowed(m_scriptingPermission) && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {
+    if (!scriptingContentIsAllowed(m_scriptingPermission) && n->isElementNode() && toScriptElement(toElement(n.get()))) {
         popCurrentNode();
         n->remove(IGNORE_EXCEPTION);
         return;
@@ -522,7 +522,7 @@ void XMLDocumentParser::parseEndElement()
         return;
     }
 
-    Element* element = static_cast<Element*>(n.get());
+    Element* element = toElement(n.get());
 
     // The element's parent may have already been removed from document.
     // Parsing continues in this case, but scripts aren't executed.
index 30e961f..9b89375 100644 (file)
@@ -2279,7 +2279,7 @@ Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy
     if (Node* linkNode = node->enclosingLinkEventParentOrSelf()) {
         KURL href;
         if (linkNode->isLink() && linkNode->hasAttributes()) {
-            if (const Attribute* attribute = static_cast<Element*>(linkNode)->getAttributeItem(HTMLNames::hrefAttr))
+            if (const Attribute* attribute = toElement(linkNode)->getAttributeItem(HTMLNames::hrefAttr))
                 href = linkNode->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(attribute->value()));
         }
 
@@ -2343,7 +2343,7 @@ Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy
     bool canStartSelection = node->canStartSelection();
 
     if (node->isElementNode()) {
-        Element* element = static_cast<Element*>(node->deprecatedShadowAncestorNode());
+        Element* element = toElement(node->deprecatedShadowAncestorNode());
 
         if (DOMSupport::isTextBasedContentEditableElement(element)) {
             if (!canStartSelection) {
@@ -2378,7 +2378,7 @@ Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy
     // Walk up the node tree looking for our custom webworks context attribute.
     while (node) {
         if (node->isElementNode()) {
-            Element* element = static_cast<Element*>(node->deprecatedShadowAncestorNode());
+            Element* element = toElement(node->deprecatedShadowAncestorNode());
             String webWorksContext(DOMSupport::webWorksContext(element));
             if (!webWorksContext.stripWhiteSpace().isEmpty()) {
                 context.setFlag(Platform::WebContext::IsWebWorksContext);
@@ -4028,7 +4028,7 @@ bool WebPagePrivate::handleMouseEvent(PlatformMouseEvent& mouseEvent)
             // element painted in its focus state on repaint.
             ASSERT_WITH_SECURITY_IMPLICATION(node->isElementNode());
             if (node->isElementNode()) {
-                Element* element = static_cast<Element*>(node);
+                Element* element = toElement(node);
                 element->focus();
             }
         } else
@@ -5041,7 +5041,7 @@ bool WebPage::setNodeFocus(const WebDOMNode& node, bool on)
             if (on) {
                 page->focusController()->setFocusedNode(nodeImpl, doc->frame());
                 if (nodeImpl->isElementNode())
-                    static_cast<Element*>(nodeImpl)->updateFocusAppearance(true);
+                    toElement(nodeImpl)->updateFocusAppearance(true);
                 d->m_inputHandler->didNodeOpenPopup(nodeImpl);
             } else if (doc->focusedNode() == nodeImpl) // && !on
                 page->focusController()->setFocusedNode(0, doc->frame());
@@ -5901,7 +5901,7 @@ void WebPagePrivate::adjustFullScreenElementDimensionsIfNeeded()
         return;
 
     ASSERT(m_fullscreenNode->isElementNode());
-    ASSERT(static_cast<Element*>(m_fullscreenNode.get())->isMediaElement());
+    ASSERT(toElement(m_fullscreenNode.get())->isMediaElement());
 
     Document* document = m_fullscreenNode->document();
     RenderStyle* fullScreenStyle = document->fullScreenRenderer()->style();
index 6c004cb..5f6b37c 100644 (file)
@@ -1,3 +1,37 @@
+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.
+
+        * 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):
+
 2013-03-14  Alberto Garcia  <agarcia@igalia.com>
 
         [BlackBerry] InRegionScrollableArea: fix call to visibleContentRect()
index 920842e..e3f0b5a 100644 (file)
@@ -104,7 +104,7 @@ bool EditorClientBlackBerry::shouldSpellCheckFocusedField()
 
     // If the field does not support autocomplete, do not do spellchecking.
     if (node->isElementNode()) {
-        const Element* element = static_cast<const Element*>(node);
+        const Element* element = toElement(node);
         if (element->hasTagName(HTMLNames::inputTag) && !DOMSupport::elementSupportsAutocomplete(element))
             return false;
     }
@@ -188,7 +188,7 @@ bool EditorClientBlackBerry::shouldChangeSelectedRange(Range* fromRange, Range*
         if (Node* focusedNode = frame->document()->focusedNode()) {
             if (focusedNode->hasTagName(HTMLNames::selectTag))
                 return false;
-            if (focusedNode->isElementNode() && DOMSupport::isPopupInputField(static_cast<Element*>(focusedNode)))
+            if (focusedNode->isElementNode() && DOMSupport::isPopupInputField(toElement(focusedNode)))
                 return false;
         }
 
index 14e9d78..850c817 100644 (file)
@@ -80,7 +80,7 @@ IntRect BackingStoreClient::absoluteRect() const
     // FIXME: Speed it up!
     Frame* frame = m_frame;
     while (frame) {
-        if (Element* element = static_cast<Element*>(frame->ownerElement())) {
+        if (Element* element = toElement(frame->ownerElement())) {
             do {
                 rect.move(element->offsetLeft(), element->offsetTop());
             } while ((element = element->offsetParent()));
index 4a56f1a..56300a7 100644 (file)
@@ -152,7 +152,7 @@ HTMLTextFormControlElement* toTextControlElement(Node* node)
     if (!(node && node->isElementNode()))
         return 0;
 
-    Element* element = static_cast<Element*>(node);
+    Element* element = toElement(node);
     if (!element->isFormControlElement())
         return 0;
 
@@ -618,7 +618,7 @@ Element* selectionContainerElement(const VisibleSelection& selection)
     if (startContainer->isInShadowTree())
         element = startContainer->shadowHost();
     else if (startContainer->isElementNode())
-        element = static_cast<Element*>(startContainer);
+        element = toElement(startContainer);
     else
         element = startContainer->parentElement();
 
index 9ac978e..77d56c0 100644 (file)
@@ -484,7 +484,7 @@ void FatFingers::getRelevantInfoFromCachedHitTest(Element*& elementUnderPoint, E
     while (node && !node->isElementNode())
         node = node->parentNode();
 
-    elementUnderPoint = static_cast<Element*>(node);
+    elementUnderPoint = toElement(node);
     clickableElementUnderPoint = result.URLElement();
 }
 
@@ -498,7 +498,7 @@ void FatFingers::setSuccessfulFatFingersResult(FatFingersResult& result, Node* b
     bool isTextInputElement = false;
     if (m_targetType == ClickableElement) {
         ASSERT_WITH_SECURITY_IMPLICATION(bestNode->isElementNode());
-        Element* bestElement = static_cast<Element*>(bestNode);
+        Element* bestElement = toElement(bestNode);
         isTextInputElement = DOMSupport::isTextInputElement(bestElement);
     }
     result.m_isTextInput = isTextInputElement;
index a6707aa..eadfb4b 100644 (file)
@@ -431,7 +431,7 @@ void InputHandler::focusedNodeChanged()
     }
 
     if (node && node->isElementNode()) {
-        Element* element = static_cast<Element*>(node);
+        Element* element = toElement(node);
         if (DOMSupport::isElementTypePlugin(element)) {
             setPluginFocused(element);
             return;
@@ -1861,7 +1861,7 @@ bool InputHandler::willOpenPopupForNode(Node* node)
     }
 
     if (node->isElementNode()) {
-        Element* element = static_cast<Element*>(node);
+        Element* element = toElement(node);
         if (DOMSupport::isPopupInputField(element))
             return true;
     }
index f151347..98caa6a 100644 (file)
@@ -1108,7 +1108,7 @@ bool SelectionHandler::inputNodeOverridesTouch() const
 
     // TODO consider caching this in InputHandler so it is only calculated once per focus.
     DEFINE_STATIC_LOCAL(QualifiedName, selectionTouchOverrideAttr, (nullAtom, "data-blackberry-end-selection-on-touch", nullAtom));
-    Element* element = static_cast<Element*>(focusedNode);
+    Element* element = toElement(focusedNode);
     return DOMSupport::elementAttributeState(element, selectionTouchOverrideAttr) == DOMSupport::On;
 }
 
index e26a2ec..2e72a18 100644 (file)
@@ -203,7 +203,7 @@ static Element* elementForTapHighlight(Element* elementUnderFatFinger)
 
     // FatFingers class selector ensure only anchor with valid href attr value get here.
     // It includes empty hrefs.
-    Element* highlightCandidateElement = static_cast<Element*>(linkNode);
+    Element* highlightCandidateElement = toElement(linkNode);
 
     if (!isArea)
         return highlightCandidateElement;
index e67edca..626062d 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
+        * 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):
+
 2013-03-14  Marja Hölttä  <marja@chromium.org>
 
         [V8] Store main world and non-main world templates separately.
index 09a62d2..e3a2d4a 100644 (file)
@@ -154,7 +154,7 @@ void WebDocument::images(WebVector<WebElement>& results)
     for (size_t i = 0; i < sourceLength; ++i) {
         Node* node = images->item(i);
         if (node && node->isHTMLElement())
-            temp.append(WebElement(static_cast<Element*>(node)));
+            temp.append(WebElement(toElement(node)));
     }
     results.assign(temp);
 }
index 6c19575..2524ad8 100644 (file)
@@ -165,7 +165,7 @@ WebElement& WebElement::operator=(const PassRefPtr<Element>& elem)
 
 WebElement::operator PassRefPtr<Element>() const
 {
-    return static_cast<Element*>(m_private.get());
+    return toElement(m_private.get());
 }
 
 } // namespace WebKit
index 6b4a4cb..cf09564 100644 (file)
@@ -170,7 +170,7 @@ void retrieveResourcesForFrame(Frame* frame,
         // We are only interested in HTML resources.
         if (!node->isElementNode())
             continue;
-        retrieveResourcesForElement(static_cast<Element*>(node),
+        retrieveResourcesForElement(toElement(node),
                                     visitedFrames, framesToVisit,
                                     frameURLs, resourceURLs);
     }
index 4861f0a..640aa6b 100644 (file)
@@ -2090,7 +2090,7 @@ void WebViewImpl::setFocus(bool enable)
                 // If the selection was cleared while the WebView was not
                 // focused, then the focus element shows with a focus ring but
                 // no caret and does respond to keyboard inputs.
-                Element* element = static_cast<Element*>(focusedNode);
+                Element* element = toElement(focusedNode);
                 if (element->isTextFormControl())
                     element->updateFocusAppearance(true);
                 else if (focusedNode->isContentEditable()) {
@@ -2744,7 +2744,7 @@ void WebViewImpl::clearFocusedNode()
     // keystrokes get eaten as a result.
     if (oldFocusedNode->isContentEditable()
         || (oldFocusedNode->isElementNode()
-            && static_cast<Element*>(oldFocusedNode.get())->isTextFormControl())) {
+            && toElement(oldFocusedNode.get())->isTextFormControl())) {
         frame->selection()->clear();
     }
 }
@@ -2753,7 +2753,7 @@ void WebViewImpl::scrollFocusedNodeIntoView()
 {
     Node* focusedNode = focusedWebCoreNode();
     if (focusedNode && focusedNode->isElementNode()) {
-        Element* elementNode = static_cast<Element*>(focusedNode);
+        Element* elementNode = toElement(focusedNode);
         elementNode->scrollIntoViewIfNeeded(true);
     }
 }
@@ -2766,7 +2766,7 @@ void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect)
         return;
 
     if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) {
-        Element* elementNode = static_cast<Element*>(focusedNode);
+        Element* elementNode = toElement(focusedNode);
         frame->view()->scrollElementToRect(elementNode, IntRect(rect.x, rect.y, rect.width, rect.height));
         return;
     }
index 13051df..909ab18 100644 (file)
@@ -1,3 +1,16 @@
+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.
+
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_query_tooltip):
+
 2013-03-13  Tomas Popela  <tpopela@redhat.com>
 
         [GTK][Introspection] Fix of gtk doc annotation warnings
index 3d52d2d..6403ad7 100644 (file)
@@ -1603,7 +1603,7 @@ static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y,
 
         for (Node* titleNode = node; titleNode; titleNode = titleNode->parentNode()) {
             if (titleNode->isElementNode()) {
-                String title = static_cast<Element*>(titleNode)->title();
+                String title = toElement(titleNode)->title();
                 if (!title.isEmpty()) {
                     if (FrameView* view = coreFrame->view()) {
                         GdkRectangle area = view->contentsToWindow(node->pixelSnappedBoundingBox());
index 793fc62..307c8e3 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (applyAppleDictionaryApplicationQuirkNonInlinePart):
+        * WebView/WebHTMLRepresentation.mm:
+        (searchForLabelsBeforeElement):
+
 2013-03-14  Alice Liu  <alice.liu@apple.com>
 
         Add to HistoryItem a way to know if its underlying CachedPage has expired.
index 2f7b587..76718d0 100644 (file)
@@ -184,7 +184,7 @@ static void applyAppleDictionaryApplicationQuirkNonInlinePart(WebFrameLoaderClie
     if (!head)
         return;
     for (Node* c = head->firstChild(); c; c = c->nextSibling()) {
-        if (c->hasTagName(scriptTag) && static_cast<Element*>(c)->getAttribute(srcAttr) == "MainPageJavaScript.js") {
+        if (c->hasTagName(scriptTag) && toElement(c)->getAttribute(srcAttr) == "MainPageJavaScript.js") {
             document->setFrameElementsShouldIgnoreScrolling(true);
             return;
         }
index 8751b93..ec95afd 100644 (file)
@@ -443,7 +443,7 @@ static NSString* searchForLabelsBeforeElement(Frame* frame, NSArray* labels, Ele
          n = NodeTraversal::previous(n))
     {
         if (n->hasTagName(formTag)
-            || (n->isHTMLElement() && static_cast<Element*>(n)->isFormControlElement()))
+            || (n->isHTMLElement() && toElement(n)->isFormControlElement()))
         {
             // We hit another form element or the start of the form - bail out
             break;
index 8e8385c..bcede99 100644 (file)
@@ -616,7 +616,7 @@ QWebElement QWebElement::firstChild() const
     for (Node* child = m_element->firstChild(); child; child = child->nextSibling()) {
         if (!child->isElementNode())
             continue;
-        Element* e = static_cast<Element*>(child);
+        Element* e = toElement(child);
         return QWebElement(e);
     }
     return QWebElement();
@@ -634,7 +634,7 @@ QWebElement QWebElement::lastChild() const
     for (Node* child = m_element->lastChild(); child; child = child->previousSibling()) {
         if (!child->isElementNode())
             continue;
-        Element* e = static_cast<Element*>(child);
+        Element* e = toElement(child);
         return QWebElement(e);
     }
     return QWebElement();
@@ -652,7 +652,7 @@ QWebElement QWebElement::nextSibling() const
     for (Node* sib = m_element->nextSibling(); sib; sib = sib->nextSibling()) {
         if (!sib->isElementNode())
             continue;
-        Element* e = static_cast<Element*>(sib);
+        Element* e = toElement(sib);
         return QWebElement(e);
     }
     return QWebElement();
@@ -670,7 +670,7 @@ QWebElement QWebElement::previousSibling() const
     for (Node* sib = m_element->previousSibling(); sib; sib = sib->previousSibling()) {
         if (!sib->isElementNode())
             continue;
-        Element* e = static_cast<Element*>(sib);
+        Element* e = toElement(sib);
         return QWebElement(e);
     }
     return QWebElement();
@@ -1648,7 +1648,7 @@ QWebElement QWebElementCollection::at(int i) const
     if (!d)
         return QWebElement();
     Node* n = d->m_result->item(i);
-    return QWebElement(static_cast<Element*>(n));
+    return QWebElement(toElement(n));
 }
 
 /*!
@@ -1683,7 +1683,7 @@ QList<QWebElement> QWebElementCollection::toList() const
     Node* n = d->m_result->item(i);
     while (n) {
         if (n->isElementNode())
-            elements.append(QWebElement(static_cast<Element*>(n)));
+            elements.append(QWebElement(toElement(n)));
         n = d->m_result->item(++i);
     }
     return elements;
index 5cbca2d..a802856 100644 (file)
@@ -1,3 +1,23 @@
+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.
+
+        * Api/qwebelement.cpp:
+        (QWebElement::firstChild):
+        (QWebElement::lastChild):
+        (QWebElement::nextSibling):
+        (QWebElement::previousSibling):
+        (QWebElementCollection::at):
+        (QWebElementCollection::toList):
+        * WebCoreSupport/QWebFrameAdapter.cpp:
+        (QWebHitTestResultPrivate::elementForInnerNode):
+
 2013-03-14  Simon Hausmann  <simon.hausmann@digia.com>
 
         [Qt] Improve the handling of mock geolocation, device orientation and motion clients
index f590f5a..84a2e52 100644 (file)
@@ -918,7 +918,7 @@ QWebElement QWebHitTestResultPrivate::elementForInnerNode() const
 {
     if (!innerNonSharedNode || !innerNonSharedNode->isElementNode())
         return QWebElement();
-    return QWebElement(static_cast<Element*>(innerNonSharedNode));
+    return QWebElement(toElement(innerNonSharedNode));
 }
 
 // ======================================================
index e682b62..14db108 100644 (file)
@@ -1,3 +1,16 @@
+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.
+
+        * WebView.cpp:
+        (WebView::enterFullscreenForNode):
+
 2013-03-13  Nate Chapin  <japhet@chromium.org>
 
         Expose symbols for internals
index d621411..62f5f16 100644 (file)
@@ -6197,7 +6197,7 @@ void WebView::enterFullscreenForNode(Node* node)
         return;
 
 #if ENABLE(VIDEO)
-    if (!static_cast<Element*>(node)->isMediaElement())
+    if (!toElement(node)->isMediaElement())
         return;
     HTMLMediaElement* videoElement = static_cast<HTMLMediaElement*>(node);
 
index 5d0a399..22140e9 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::InjectedBundleNodeHandle::elementBounds):
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::containsAnyFormElements):
+
 2013-03-14  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         [EFL][WK2] Add an API for adding and removing user style sheets from a page group
index 1295359..ca60351 100644 (file)
@@ -110,7 +110,7 @@ IntRect InjectedBundleNodeHandle::elementBounds() const
     if (!m_node->isElementNode())
         return IntRect();
 
-    return static_cast<Element*>(m_node.get())->boundsInRootViewSpace();
+    return toElement(m_node.get())->boundsInRootViewSpace();
 }
     
 IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) const
index 62557b4..c16d436 100644 (file)
@@ -571,7 +571,7 @@ bool WebFrame::containsAnyFormElements() const
     for (Node* node = document->documentElement(); node; node = NodeTraversal::next(node)) {
         if (!node->isElementNode())
             continue;
-        if (static_cast<Element*>(node)->hasTagName(HTMLNames::formTag))
+        if (toElement(node)->hasTagName(HTMLNames::formTag))
             return true;
     }
     return false;