Title: [145562] trunk/Source
Revision
145562
Author
infe...@chromium.org
Date
2013-03-12 10:44:37 -0700 (Tue, 12 Mar 2013)

Log Message

Replace static_casts with to* functions.
https://bugs.webkit.org/show_bug.cgi?id=112072

Reviewed by Philip Rogers.

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

Source/WebCore:

* accessibility/AccessibilityMenuList.cpp:
(WebCore::AccessibilityMenuList::canSetFocusAttribute):
* bindings/objc/DOM.mm:
(kitClass):
* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::prepareListenerObject):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
* editing/ApplyStyleCommand.cpp:
(WebCore::isLegacyAppleStyleSpan):
(WebCore::isEmptyFontTag):
(WebCore::ApplyStyleCommand::applyBlockStyle):
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isMailPasteAsQuotationNode):
(WebCore::haveSameTagName):
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
(WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
* history/CachedPage.cpp:
(WebCore::CachedPage::restore):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::suggestions):
* html/HTMLTableRowsCollection.cpp:
(WebCore::isInHead):
(WebCore::isInBody):
(WebCore::isInFoot):
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::innerPatchNode):
* page/PageSerializer.cpp:
(WebCore::SerializerMarkupAccumulator::appendCustomAttributes):
* plugins/PluginView.cpp:
(WebCore::PluginView::getValue):
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::paintContents):
(WebCore::RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::name):
* rendering/RenderMedia.cpp:
(WebCore::RenderMedia::mediaElement):
* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::autosaveName):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::textFormControlElement):
(WebCore::updateUserModifyProperty):
* rendering/mathml/RenderMathMLFenced.cpp:
(WebCore::RenderMathMLFenced::updateFromElement):
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::updateFromElement):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):
(WebCore::XMLDocumentParser::endElementNs):

Source/WebKit/chromium:

* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::focusedNodeChanged):
* src/ContextMenuClientImpl.cpp:
(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
* src/DOMUtilitiesPrivate.cpp:
(WebCore::toHTMLElement):
* src/WebSearchableFormData.cpp:
(HTMLNames::IsSelectInDefaultState):

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _enterFullscreenForNode:WebCore::]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145561 => 145562)


--- trunk/Source/WebCore/ChangeLog	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/ChangeLog	2013-03-12 17:44:37 UTC (rev 145562)
@@ -1,3 +1,66 @@
+2013-03-12  Abhishek Arya  <infe...@chromium.org>
+
+        Replace static_casts with to* functions.
+        https://bugs.webkit.org/show_bug.cgi?id=112072
+
+        Reviewed by Philip Rogers.
+
+        to* functions are preferred over static_cast calls since they
+        help to catch bad casts easily on the testing infrastructure.
+
+        * accessibility/AccessibilityMenuList.cpp:
+        (WebCore::AccessibilityMenuList::canSetFocusAttribute):
+        * bindings/objc/DOM.mm:
+        (kitClass):
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::prepareListenerObject):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOne):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::isLegacyAppleStyleSpan):
+        (WebCore::isEmptyFontTag):
+        (WebCore::ApplyStyleCommand::applyBlockStyle):
+        * editing/FormatBlockCommand.cpp:
+        (WebCore::isElementForFormatBlock):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::isMailPasteAsQuotationNode):
+        (WebCore::haveSameTagName):
+        (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+        (WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::restore):
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::suggestions):
+        * html/HTMLTableRowsCollection.cpp:
+        (WebCore::isInHead):
+        (WebCore::isInBody):
+        (WebCore::isInFoot):
+        * inspector/DOMPatchSupport.cpp:
+        (WebCore::DOMPatchSupport::innerPatchNode):
+        * page/PageSerializer.cpp:
+        (WebCore::SerializerMarkupAccumulator::appendCustomAttributes):
+        * plugins/PluginView.cpp:
+        (WebCore::PluginView::getValue):
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::paintContents):
+        (WebCore::RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::name):
+        * rendering/RenderMedia.cpp:
+        (WebCore::RenderMedia::mediaElement):
+        * rendering/RenderSearchField.cpp:
+        (WebCore::RenderSearchField::autosaveName):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::textFormControlElement):
+        (WebCore::updateUserModifyProperty):
+        * rendering/mathml/RenderMathMLFenced.cpp:
+        (WebCore::RenderMathMLFenced::updateFromElement):
+        * rendering/mathml/RenderMathMLFraction.cpp:
+        (WebCore::RenderMathMLFraction::updateFromElement):
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::XMLDocumentParser):
+        (WebCore::XMLDocumentParser::endElementNs):
+
 2013-03-12  Zan Dobersek  <zdober...@igalia.com>
 
         [GTK] Remove HILDON_CPPFLAGS and HILDON_CFLAGS references from GNUmakefiles

Modified: trunk/Source/WebCore/accessibility/AccessibilityMenuList.cpp (145561 => 145562)


--- trunk/Source/WebCore/accessibility/AccessibilityMenuList.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/accessibility/AccessibilityMenuList.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -92,7 +92,7 @@
     if (!node())
         return false;
 
-    return static_cast<Element*>(node())->isEnabledFormControl();
+    return toElement(node())->isEnabledFormControl();
 }
 
 void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)

Modified: trunk/Source/WebCore/bindings/objc/DOM.mm (145561 => 145562)


--- trunk/Source/WebCore/bindings/objc/DOM.mm	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/bindings/objc/DOM.mm	2013-03-12 17:44:37 UTC (rev 145562)
@@ -295,7 +295,7 @@
     switch (impl->nodeType()) {
         case WebCore::Node::ELEMENT_NODE:
             if (impl->isHTMLElement())
-                return WebCore::elementClass(static_cast<WebCore::HTMLElement*>(impl)->tagQName(), [DOMHTMLElement class]);
+                return WebCore::elementClass(toHTMLElement(impl)->tagQName(), [DOMHTMLElement class]);
 #if ENABLE(SVG_DOM_OBJC_BINDINGS)
             if (impl->isSVGElement())
                 return WebCore::elementClass(static_cast<WebCore::SVGElement*>(impl)->tagQName(), [DOMSVGElement class]);

Modified: trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp (145561 => 145562)


--- trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -177,7 +177,7 @@
 
     HTMLFormElement* formElement = 0;
     if (m_node && m_node->isHTMLElement())
-        formElement = static_cast<HTMLElement*>(m_node)->form();
+        formElement = toHTMLElement(m_node)->form();
 
     v8::Handle<v8::Object> nodeWrapper = toObjectWrapper<Node>(m_node, isolate);
     v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(formElement, isolate);

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (145561 => 145562)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -656,7 +656,7 @@
                     break;
 #if ENABLE(PROGRESS_ELEMENT)
                 if (element->hasTagName(progressTag)) {
-                    HTMLProgressElement* progress = static_cast<HTMLProgressElement*>(element);
+                    HTMLProgressElement* progress = toHTMLProgressElement(element);
                     if (progress && !progress->isDeterminate())
                         return true;
                     break;

Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.cpp (145561 => 145562)


--- trunk/Source/WebCore/editing/ApplyStyleCommand.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -67,7 +67,7 @@
     if (!node || !node->isHTMLElement())
         return false;
 
-    const HTMLElement* elem = static_cast<const HTMLElement*>(node);
+    const HTMLElement* elem = toHTMLElement(node);
     return elem->hasLocalName(spanAttr) && elem->getAttribute(classAttr) == styleSpanClassString();
 }
 
@@ -106,7 +106,7 @@
     if (!element || !element->hasTagName(fontTag))
         return false;
 
-    return hasNoAttributeOrOnlyStyleAttribute(static_cast<const HTMLElement*>(element), shouldStyleAttributeBeEmpty);
+    return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(element), shouldStyleAttributeBeEmpty);
 }
 
 static PassRefPtr<Element> createFontElement(Document* document)
@@ -290,8 +290,8 @@
         nextParagraphStart = endOfParagraph(paragraphStart).next();
     }
     
-    startRange = TextIterator::rangeFromLocationAndLength(static_cast<Element*>(scope), startIndex, 0, true);
-    endRange = TextIterator::rangeFromLocationAndLength(static_cast<Element*>(scope), endIndex, 0, true);
+    startRange = TextIterator::rangeFromLocationAndLength(toContainerNode(scope), startIndex, 0, true);
+    endRange = TextIterator::rangeFromLocationAndLength(toContainerNode(scope), endIndex, 0, true);
     if (startRange && endRange)
         updateStartEnd(startRange->startPosition(), endRange->startPosition());
 }

Modified: trunk/Source/WebCore/editing/FormatBlockCommand.cpp (145561 => 145562)


--- trunk/Source/WebCore/editing/FormatBlockCommand.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/editing/FormatBlockCommand.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -42,7 +42,7 @@
 static bool isElementForFormatBlock(const QualifiedName& tagName);
 static inline bool isElementForFormatBlock(Node* node)
 {
-    return node->isElementNode() && isElementForFormatBlock(static_cast<Element*>(node)->tagQName());
+    return node->isElementNode() && isElementForFormatBlock(toElement(node)->tagQName());
 }
 
 FormatBlockCommand::FormatBlockCommand(Document* document, const QualifiedName& tagName) 

Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (145561 => 145562)


--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -426,7 +426,7 @@
 
 static bool isMailPasteAsQuotationNode(const Node* node)
 {
-    return node && node->hasTagName(blockquoteTag) && node->isElementNode() && static_cast<const Element*>(node)->getAttribute(classAttr) == ApplePasteAsQuotation;
+    return node && node->hasTagName(blockquoteTag) && node->isElementNode() && toElement(node)->getAttribute(classAttr) == ApplePasteAsQuotation;
 }
 
 static bool isHeaderElement(const Node* a)
@@ -444,7 +444,7 @@
 
 static bool haveSameTagName(Node* a, Node* b)
 {
-    return a && b && a->isElementNode() && b->isElementNode() && static_cast<Element*>(a)->tagName() == static_cast<Element*>(b)->tagName();
+    return a && b && a->isElementNode() && b->isElementNode() && toElement(a)->tagName() == static_cast<Element*>(b)->tagName();
 }
 
 bool ReplaceSelectionCommand::shouldMerge(const VisiblePosition& source, const VisiblePosition& destination)
@@ -486,7 +486,7 @@
         if (inlineStyle) {
             if (element->isHTMLElement()) {
                 Vector<QualifiedName> attributes;
-                HTMLElement* htmlElement = static_cast<HTMLElement*>(element);
+                HTMLElement* htmlElement = toHTMLElement(element);
 
                 if (newInlineStyle->conflictsWithImplicitStyleOfElement(htmlElement)) {
                     // e.g. <b style="font-weight: normal;"> is converted to <span style="font-weight: normal;">
@@ -625,8 +625,8 @@
         if (!node->isHTMLElement())
             continue;
 
-        if (isProhibitedParagraphChild(static_cast<const HTMLElement*>(node.get())->localName())) {
-            if (HTMLElement* paragraphElement = static_cast<HTMLElement*>(enclosingNodeWithTag(positionInParentBeforeNode(node.get()), pTag)))
+        if (isProhibitedParagraphChild(toHTMLElement(node.get())->localName())) {
+            if (HTMLElement* paragraphElement = toHTMLElement(enclosingNodeWithTag(positionInParentBeforeNode(node.get()), pTag)))
                 moveNodeOutOfAncestor(node, paragraphElement);
         }
 

Modified: trunk/Source/WebCore/history/CachedPage.cpp (145561 => 145562)


--- trunk/Source/WebCore/history/CachedPage.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/history/CachedPage.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -83,7 +83,7 @@
     Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document();
     if (Node* node = focusedDocument->focusedNode()) {
         if (node->isElementNode())
-            static_cast<Element*>(node)->updateFocusAppearance(true);
+            toElement(node)->updateFocusAppearance(true);
     }
 
     if (m_needStyleRecalcForVisitedLinks) {

Modified: trunk/Source/WebCore/html/ColorInputType.cpp (145561 => 145562)


--- trunk/Source/WebCore/html/ColorInputType.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/html/ColorInputType.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -233,7 +233,7 @@
     HTMLDataListElement* dataList = element()->dataList();
     if (dataList) {
         RefPtr<HTMLCollection> options = dataList->options();
-        for (unsigned i = 0; HTMLOptionElement* option = static_cast<HTMLOptionElement*>(options->item(i)); i++) {
+        for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(options->item(i)); i++) {
             if (!element()->isValidValue(option->value()))
                 continue;
             Color color(option->value());

Modified: trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp (145561 => 145562)


--- trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -39,17 +39,17 @@
 
 static bool isInHead(Element* row)
 {
-    return row->parentNode() && static_cast<Element*>(row->parentNode())->hasLocalName(theadTag);
+    return row->parentNode() && toElement(row->parentNode())->hasLocalName(theadTag);
 }
 
 static bool isInBody(Element* row)
 {
-    return row->parentNode() && static_cast<Element*>(row->parentNode())->hasLocalName(tbodyTag);
+    return row->parentNode() && toElement(row->parentNode())->hasLocalName(tbodyTag);
 }
 
 static bool isInFoot(Element* row)
 {
-    return row->parentNode() && static_cast<Element*>(row->parentNode())->hasLocalName(tfootTag);
+    return row->parentNode() && toElement(row->parentNode())->hasLocalName(tfootTag);
 }
 
 HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement* table, HTMLTableRowElement* previous)

Modified: trunk/Source/WebCore/inspector/DOMPatchSupport.cpp (145561 => 145562)


--- trunk/Source/WebCore/inspector/DOMPatchSupport.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/inspector/DOMPatchSupport.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -170,8 +170,8 @@
         return true;
 
     // Patch attributes
-    Element* oldElement = static_cast<Element*>(oldNode);
-    Element* newElement = static_cast<Element*>(newNode);
+    Element* oldElement = toElement(oldNode);
+    Element* newElement = toElement(newNode);
     if (oldDigest->m_attrsSHA1 != newDigest->m_attrsSHA1) {
         // FIXME: Create a function in Element for removing all properties. Take in account whether did/willModifyAttribute are important.
         if (oldElement->hasAttributesWithoutUpdate()) {

Modified: trunk/Source/WebCore/page/PageSerializer.cpp (145561 => 145562)


--- trunk/Source/WebCore/page/PageSerializer.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/page/PageSerializer.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -150,7 +150,7 @@
     if (!element->isFrameOwnerElement())
         return;
 
-    HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(element);
+    HTMLFrameOwnerElement* frameOwner = toFrameOwnerElement(element);
     Frame* frame = frameOwner->contentFrame();
     if (!frame)
         return;

Modified: trunk/Source/WebCore/plugins/PluginView.cpp (145561 => 145562)


--- trunk/Source/WebCore/plugins/PluginView.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/plugins/PluginView.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -1374,7 +1374,7 @@
         NPObject* pluginScriptObject = 0;
 
         if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
-            pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
+            pluginScriptObject = m_element->getNPObject();
 
         // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
         if (pluginScriptObject)

Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp (145561 => 145562)


--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -171,11 +171,11 @@
 
 void RenderEmbeddedObject::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    Element* element = static_cast<Element*>(node());
+    Element* element = toElement(node());
     if (!element || !element->isPluginElement())
         return;
 
-    HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(element);
+    HTMLPlugInElement* plugInElement = toHTMLPlugInElement(element);
     if (plugInElement->displayState() > HTMLPlugInElement::DisplayingSnapshot) {
         RenderPart::paintContents(paintInfo, paintOffset);
         return;
@@ -184,7 +184,7 @@
     if (!plugInElement->isPlugInImageElement())
         return;
 
-    Image* snapshot = static_cast<HTMLPlugInImageElement*>(plugInElement)->snapshotImage();
+    Image* snapshot = toHTMLPlugInImageElement(plugInElement)->snapshotImage();
     if (snapshot)
         paintSnapshotImage(paintInfo, paintOffset, snapshot);
 }
@@ -417,7 +417,7 @@
         return;
     
     MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
-    HTMLPlugInElement* element = static_cast<HTMLPlugInElement*>(node());
+    HTMLPlugInElement* element = toHTMLPlugInElement(node());
     if (event->type() == eventNames().mousedownEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
         m_mouseDownWasInUnavailablePluginIndicator = isInUnavailablePluginIndicator(mouseEvent);
         if (m_mouseDownWasInUnavailablePluginIndicator) {

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (145561 => 145562)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -276,11 +276,11 @@
     if (Node* node = renderer()->node()) {
         if (node->isElementNode()) {
             name.append(' ');
-            name.append(static_cast<Element*>(node)->tagName());
+            name.append(toElement(node)->tagName());
         }
         if (node->hasID()) {
             name.appendLiteral(" id=\'");
-            name.append(static_cast<Element*>(node)->getIdAttribute());
+            name.append(toElement(node)->getIdAttribute());
             name.append('\'');
         }
 

Modified: trunk/Source/WebCore/rendering/RenderMedia.cpp (145561 => 145562)


--- trunk/Source/WebCore/rendering/RenderMedia.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/rendering/RenderMedia.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -53,7 +53,7 @@
 
 HTMLMediaElement* RenderMedia::mediaElement() const
 { 
-    return static_cast<HTMLMediaElement*>(node()); 
+    return toMediaElement(node()); 
 }
 
 void RenderMedia::layout()

Modified: trunk/Source/WebCore/rendering/RenderSearchField.cpp (145561 => 145562)


--- trunk/Source/WebCore/rendering/RenderSearchField.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/rendering/RenderSearchField.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -199,7 +199,7 @@
 
 const AtomicString& RenderSearchField::autosaveName() const
 {
-    return static_cast<Element*>(node())->getAttribute(autosaveAttr);
+    return toElement(node())->getAttribute(autosaveAttr);
 }
 
 // PopupMenuClient methods

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (145561 => 145562)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -48,7 +48,7 @@
 
 HTMLTextFormControlElement* RenderTextControl::textFormControlElement() const
 {
-    return static_cast<HTMLTextFormControlElement*>(node());
+    return toHTMLTextFormControlElement(node());
 }
 
 HTMLElement* RenderTextControl::innerTextElement() const
@@ -80,9 +80,9 @@
     bool isReadOnlyControl = false;
 
     if (node->isElementNode()) {
-        Element* element = static_cast<Element*>(node);
+        Element* element = toElement(node);
         isEnabled = element->isEnabledFormControl();
-        isReadOnlyControl = element->isTextFormControl() && static_cast<HTMLTextFormControlElement*>(element)->readOnly();
+        isReadOnlyControl = element->isTextFormControl() && toHTMLTextFormControlElement(element)->readOnly();
     }
 
     style->setUserModify((isReadOnlyControl || !isEnabled) ? READ_ONLY : READ_WRITE_PLAINTEXT_ONLY);

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp (145561 => 145562)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -55,7 +55,7 @@
 
 void RenderMathMLFenced::updateFromElement()
 {
-    Element* fenced = static_cast<Element*>(node());
+    Element* fenced = toElement(node());
  
     // FIXME: Handle open/close values with more than one character (they should be treated like text).
     AtomicString openValue = fenced->getAttribute(MathMLNames::openAttr);

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (145561 => 145562)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -63,7 +63,7 @@
     if (isEmpty()) 
         return;
     
-    Element* fraction = static_cast<Element*>(node());
+    Element* fraction = toElement(node());
     
     RenderObject* numeratorWrapper = firstChild();
     RenderObject* denominatorWrapper = numeratorWrapper->nextSibling();

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (145561 => 145562)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -599,7 +599,7 @@
         ContainerNode* n = parentElement->parentNode();
         if (!n || !n->isElementNode())
             break;
-        parentElement = static_cast<Element*>(n);
+        parentElement = toElement(n);
     }
 
     if (elemStack.isEmpty())
@@ -863,7 +863,7 @@
     if (hackAroundLibXMLEntityParsingBug() && context()->depth <= depthTriggeringEntityExpansion())
         setDepthTriggeringEntityExpansion(-1);
 
-    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;
@@ -874,7 +874,7 @@
         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.

Modified: trunk/Source/WebKit/chromium/ChangeLog (145561 => 145562)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-03-12 17:44:37 UTC (rev 145562)
@@ -1,3 +1,22 @@
+2013-03-12  Abhishek Arya  <infe...@chromium.org>
+
+        Replace static_casts with to* functions.
+        https://bugs.webkit.org/show_bug.cgi?id=112072
+
+        Reviewed by Philip Rogers.
+
+        to* functions are preferred over static_cast calls since they
+        help to catch bad casts easily on the testing infrastructure.
+
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::focusedNodeChanged):
+        * src/ContextMenuClientImpl.cpp:
+        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
+        * src/DOMUtilitiesPrivate.cpp:
+        (WebCore::toHTMLElement):
+        * src/WebSearchableFormData.cpp:
+        (HTMLNames::IsSelectInDefaultState):
+
 2013-03-11  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r145462.

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (145561 => 145562)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -231,7 +231,7 @@
         // WebCore::Node.
         HitTestResult hitTest(IntPoint(0, 0));
         // This cast must be valid because of the isLink() check.
-        hitTest.setURLElement(static_cast<Element*>(node));
+        hitTest.setURLElement(toElement(node));
         if (hitTest.isLiveLink())
             focusURL = hitTest.absoluteLinkURL();
     }

Modified: trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp (145561 => 145562)


--- trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -226,7 +226,7 @@
         // We know that if absoluteMediaURL() is not empty, then this
         // is a media element.
         HTMLMediaElement* mediaElement =
-            static_cast<HTMLMediaElement*>(r.innerNonSharedNode());
+            toMediaElement(r.innerNonSharedNode());
         if (mediaElement->hasTagName(HTMLNames::videoTag))
             data.mediaType = WebContextMenuData::MediaTypeVideo;
         else if (mediaElement->hasTagName(HTMLNames::audioTag))
@@ -266,7 +266,7 @@
                 if (plugin->plugin()->supportsPaginatedPrint())
                     data.mediaFlags |= WebContextMenuData::MediaCanPrint;
 
-                HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(r.innerNonSharedNode());
+                HTMLPlugInImageElement* pluginElement = toHTMLPlugInImageElement(r.innerNonSharedNode());
                 data.srcURL = pluginElement->document()->completeURL(pluginElement->url());
                 data.mediaFlags |= WebContextMenuData::MediaCanSave;
 

Modified: trunk/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp (145561 => 145562)


--- trunk/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebKit/chromium/src/DOMUtilitiesPrivate.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -47,7 +47,7 @@
 HTMLNodeType* toHTMLElement(Node* node, const QualifiedName& name)
 {
     if (node->isHTMLElement()
-        && static_cast<HTMLElement*>(node)->hasTagName(name)) {
+        && toHTMLElement(node)->hasTagName(name)) {
         return static_cast<HTMLNodeType*>(node);
     }
     return 0;

Modified: trunk/Source/WebKit/chromium/src/WebSearchableFormData.cpp (145561 => 145562)


--- trunk/Source/WebKit/chromium/src/WebSearchableFormData.cpp	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebKit/chromium/src/WebSearchableFormData.cpp	2013-03-12 17:44:37 UTC (rev 145562)
@@ -106,7 +106,7 @@
         for (Vector<HTMLElement*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) {
             if (!(*i)->hasLocalName(HTMLNames::optionTag))
                 continue;
-            HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(*i);
+            HTMLOptionElement* optionElement = toHTMLOptionElement(*i);
             if (optionElement->selected() != optionElement->hasAttribute(selectedAttr))
                 return false;
         }
@@ -119,7 +119,7 @@
     for (Vector<HTMLElement*>::const_iterator i(listItems.begin()); i != listItems.end(); ++i) {
         if (!(*i)->hasLocalName(HTMLNames::optionTag))
             continue;
-        HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(*i);
+        HTMLOptionElement* optionElement = toHTMLOptionElement(*i);
         if (optionElement->hasAttribute(selectedAttr)) {
             // The page specified the option to select.
             initialSelected = optionElement;

Modified: trunk/Source/WebKit/mac/ChangeLog (145561 => 145562)


--- trunk/Source/WebKit/mac/ChangeLog	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-03-12 17:44:37 UTC (rev 145562)
@@ -1,3 +1,16 @@
+2013-03-12  Abhishek Arya  <infe...@chromium.org>
+
+        Replace static_casts with to* functions.
+        https://bugs.webkit.org/show_bug.cgi?id=112072
+
+        Reviewed by Philip Rogers.
+
+        to* functions are preferred over static_cast calls since they
+        help to catch bad casts easily on the testing infrastructure.
+
+        * WebView/WebView.mm:
+        (-[WebView _enterFullscreenForNode:WebCore::]):
+
 2013-03-11  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r145462.

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (145561 => 145562)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2013-03-12 17:42:28 UTC (rev 145561)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2013-03-12 17:44:37 UTC (rev 145562)
@@ -6466,7 +6466,7 @@
 - (void)_enterFullscreenForNode:(WebCore::Node*)node
 {
     ASSERT(node->hasTagName(WebCore::HTMLNames::videoTag));
-    HTMLMediaElement* videoElement = static_cast<HTMLMediaElement*>(node);
+    HTMLMediaElement* videoElement = toMediaElement(node);
 
     if (_private->fullscreenController) {
         if ([_private->fullscreenController mediaElement] == videoElement) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to