Clean up static_cast<HTMLFoo*> usage
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Nov 2013 11:48:06 +0000 (11:48 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Nov 2013 11:48:06 +0000 (11:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124480

Reviewed by Tim Horton.

Though there are toHTMLFoo(), some places are still using static_cast<>.
Additionally, toHTMLBodyElement() is supported from now.

No new tests, no behavior changes.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isRequired):
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::isDataTable):
* bindings/js/JSHTMLFrameSetElementCustom.cpp:
(WebCore::JSHTMLFrameSetElement::nameGetter):
* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginInstance):
* dom/Document.cpp:
(WebCore::Document::openSearchDescriptionURL):
(WebCore::Document::iconURLs):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::setTextAlignmentForChangedBaseWritingDirection):
* html/HTMLBodyElement.h:
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::bgColor):
(WebCore::HTMLDocument::setBgColor):
(WebCore::HTMLDocument::fgColor):
(WebCore::HTMLDocument::setFgColor):
(WebCore::HTMLDocument::alinkColor):
(WebCore::HTMLDocument::setAlinkColor):
(WebCore::HTMLDocument::linkColor):
(WebCore::HTMLDocument::setLinkColor):
(WebCore::HTMLDocument::vlinkColor):
(WebCore::HTMLDocument::setVlinkColor):
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::rendererIsNeeded):
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::updateAncestorDisabledState):
(WebCore::HTMLFormControlElement::enclosingFormControlElement):
* html/HTMLFormElement.cpp:
(WebCore::submitElementFromEvent):
* html/HTMLImageLoader.cpp:
(WebCore::HTMLImageLoader::notifyFinished):
* html/HTMLLegendElement.cpp:
(WebCore::HTMLLegendElement::virtualForm):
* html/RadioNodeList.cpp:
(WebCore::RadioNodeList::checkElementMatchesRadioNodeListFilter):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForNode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159416 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityTable.cpp
Source/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp
Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentStyleSheetCollection.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/html/HTMLBodyElement.h
Source/WebCore/html/HTMLDocument.cpp
Source/WebCore/html/HTMLEmbedElement.cpp
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLImageLoader.cpp
Source/WebCore/html/HTMLLegendElement.cpp
Source/WebCore/html/RadioNodeList.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp

index 41a0ee6..75cb50a 100644 (file)
@@ -1,3 +1,60 @@
+2013-11-18  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Clean up static_cast<HTMLFoo*> usage
+        https://bugs.webkit.org/show_bug.cgi?id=124480
+
+        Reviewed by Tim Horton.
+
+        Though there are toHTMLFoo(), some places are still using static_cast<>.
+        Additionally, toHTMLBodyElement() is supported from now.
+
+        No new tests, no behavior changes.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::isRequired):
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::isDataTable):
+        * bindings/js/JSHTMLFrameSetElementCustom.cpp:
+        (WebCore::JSHTMLFrameSetElement::nameGetter):
+        * bindings/js/JSPluginElementFunctions.cpp:
+        (WebCore::pluginInstance):
+        * dom/Document.cpp:
+        (WebCore::Document::openSearchDescriptionURL):
+        (WebCore::Document::iconURLs):
+        * dom/DocumentStyleSheetCollection.cpp:
+        (WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::setTextAlignmentForChangedBaseWritingDirection):
+        * html/HTMLBodyElement.h:
+        * html/HTMLDocument.cpp:
+        (WebCore::HTMLDocument::bgColor):
+        (WebCore::HTMLDocument::setBgColor):
+        (WebCore::HTMLDocument::fgColor):
+        (WebCore::HTMLDocument::setFgColor):
+        (WebCore::HTMLDocument::alinkColor):
+        (WebCore::HTMLDocument::setAlinkColor):
+        (WebCore::HTMLDocument::linkColor):
+        (WebCore::HTMLDocument::setLinkColor):
+        (WebCore::HTMLDocument::vlinkColor):
+        (WebCore::HTMLDocument::setVlinkColor):
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::rendererIsNeeded):
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::updateAncestorDisabledState):
+        (WebCore::HTMLFormControlElement::enclosingFormControlElement):
+        * html/HTMLFormElement.cpp:
+        (WebCore::submitElementFromEvent):
+        * html/HTMLImageLoader.cpp:
+        (WebCore::HTMLImageLoader::notifyFinished):
+        * html/HTMLLegendElement.cpp:
+        (WebCore::HTMLLegendElement::virtualForm):
+        * html/RadioNodeList.cpp:
+        (WebCore::RadioNodeList::checkElementMatchesRadioNodeListFilter):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForNode):
+
 2013-11-18  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Update GObject DOM symbols file after r158760.
index 14f9f38..8f4f02e 100644 (file)
@@ -734,7 +734,7 @@ bool AccessibilityNodeObject::isRequired() const
 
     Node* n = this->node();
     if (n && (n->isElementNode() && toElement(n)->isFormControlElement()))
-        return static_cast<HTMLFormControlElement*>(n)->isRequired();
+        return toHTMLFormControlElement(n)->isRequired();
 
     return false;
 }
index 8680b08..99dd9ae 100644 (file)
@@ -184,7 +184,7 @@ bool AccessibilityTable::isDataTable() const
             
             validCellCount++;
             
-            HTMLTableCellElement* cellElement = static_cast<HTMLTableCellElement*>(cell->element());
+            HTMLTableCellElement* cellElement = toHTMLTableCellElement(cell->element());
             
             bool isTHCell = cellElement->hasTagName(thTag);
             // If the first row is comprised of all <th> tags, assume it is a data table.
index 613fd20..f89c85b 100644 (file)
@@ -51,7 +51,7 @@ JSValue JSHTMLFrameSetElement::nameGetter(ExecState* exec, JSValue slotBase, Pro
 {
     HTMLElement& element = jsCast<JSHTMLElement*>(asObject(slotBase))->impl();
     Node* frameElement = element.children()->namedItem(propertyNameToAtomicString(propertyName));
-    if (Document* document = static_cast<HTMLFrameElement*>(frameElement)->contentDocument()) {
+    if (Document* document = toHTMLFrameElement(frameElement)->contentDocument()) {
         if (JSDOMWindowShell* window = toJSDOMWindowShell(document->frame(), currentWorld(exec)))
             return window;
     }
index a73380b..85a9dab 100644 (file)
@@ -45,7 +45,7 @@ Instance* pluginInstance(HTMLElement& element)
     // The plugin element holds an owning reference, so we don't have to.
     if (!isPluginElement(element))
         return 0;
-    Instance* instance = static_cast<HTMLPlugInElement&>(element).getInstance().get();
+    Instance* instance = toHTMLPlugInElement(element).getInstance().get();
     if (!instance || !instance->rootObject())
         return 0;
     return instance;
index 9df381a..b984e33 100644 (file)
@@ -4137,7 +4137,7 @@ URL Document::openSearchDescriptionURL()
     for (unsigned i = 0; Node* child = children->item(i); i++) {
         if (!child->hasTagName(linkTag))
             continue;
-        HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(child);
+        HTMLLinkElement* linkElement = toHTMLLinkElement(child);
         if (!equalIgnoringCase(linkElement->type(), openSearchMIMEType) || !equalIgnoringCase(linkElement->rel(), openSearchRelation))
             continue;
         if (linkElement->href().isEmpty())
@@ -4433,7 +4433,7 @@ const Vector<IconURL>& Document::iconURLs(int iconTypesMask)
         Node* child = children->item(i);
         if (!child->hasTagName(linkTag))
             continue;
-        HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(child);
+        HTMLLinkElement* linkElement = toHTMLLinkElement(child);
         if (!(linkElement->iconType() & iconTypesMask))
             continue;
         if (linkElement->href().isEmpty())
index 887c212..b0ad073 100644 (file)
@@ -287,7 +287,7 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS
             bool enabledViaScript = false;
             if (e->hasTagName(linkTag)) {
                 // <LINK> element
-                HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(n);
+                HTMLLinkElement* linkElement = toHTMLLinkElement(n);
                 if (linkElement->isDisabled())
                     continue;
                 enabledViaScript = linkElement->isEnabledViaScript();
index a1e1a4e..723b8c9 100644 (file)
@@ -633,7 +633,7 @@ void ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuild
         }
 
         if (isHeaderElement(node.get())) {
-            if (HTMLElement* headerElement = static_cast<HTMLElement*>(highestEnclosingNodeOfType(positionInParentBeforeNode(node.get()), isHeaderElement)))
+            if (HTMLElement* headerElement = toHTMLElement(highestEnclosingNodeOfType(positionInParentBeforeNode(node.get()), isHeaderElement)))
                 moveNodeOutOfAncestor(node, headerElement);
         }
     }
index 2f75dc4..404edc1 100644 (file)
@@ -161,11 +161,11 @@ void Editor::setTextAlignmentForChangedBaseWritingDirection(WritingDirection dir
 
     Element* focusedElement = frame()->document()->focusedElement();
     if (focusedElement && (focusedElement->hasTagName(textareaTag) || (focusedElement->hasTagName(inputTag) &&
-        (static_cast<HTMLInputElement*>(focusedElement)->isTextField() ||
-         static_cast<HTMLInputElement*>(focusedElement)->isSearchField())))) {
+        (toHTMLInputElement(focusedElement)->isTextField() ||
+         toHTMLInputElement(focusedElement)->isSearchField())))) {
         if (direction == NaturalWritingDirection)
             return;
-        static_cast<HTMLElement*>(focusedElement)->setAttribute(alignAttr, newValue);
+        toHTMLElement(focusedElement)->setAttribute(alignAttr, newValue);
         frame()->document()->updateStyleIfNeeded();
         return;
     }
index 298e8c7..6ecb60e 100644 (file)
@@ -92,6 +92,8 @@ private:
     virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const;
 };
 
+NODE_TYPE_CASTS(HTMLBodyElement)
+
 } //namespace
 
 #endif
index 5ef3732..7483803 100644 (file)
@@ -161,7 +161,7 @@ bool HTMLDocument::hasFocus()
 String HTMLDocument::bgColor()
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (!bodyElement)
         return String();
@@ -171,7 +171,7 @@ String HTMLDocument::bgColor()
 void HTMLDocument::setBgColor(const String& value)
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (bodyElement)
         bodyElement->setBgColor(value);
@@ -180,7 +180,7 @@ void HTMLDocument::setBgColor(const String& value)
 String HTMLDocument::fgColor()
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (!bodyElement)
         return String();
@@ -190,7 +190,7 @@ String HTMLDocument::fgColor()
 void HTMLDocument::setFgColor(const String& value)
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (bodyElement)
         bodyElement->setText(value);
@@ -199,7 +199,7 @@ void HTMLDocument::setFgColor(const String& value)
 String HTMLDocument::alinkColor()
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (!bodyElement)
         return String();
@@ -209,7 +209,7 @@ String HTMLDocument::alinkColor()
 void HTMLDocument::setAlinkColor(const String& value)
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (bodyElement) {
         // This check is a bit silly, but some benchmarks like to set the
@@ -223,7 +223,7 @@ void HTMLDocument::setAlinkColor(const String& value)
 String HTMLDocument::linkColor()
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (!bodyElement)
         return String();
@@ -233,7 +233,7 @@ String HTMLDocument::linkColor()
 void HTMLDocument::setLinkColor(const String& value)
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (bodyElement) {
         // This check is a bit silly, but some benchmarks like to set the
@@ -247,7 +247,7 @@ void HTMLDocument::setLinkColor(const String& value)
 String HTMLDocument::vlinkColor()
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (!bodyElement)
         return String();
@@ -257,7 +257,7 @@ String HTMLDocument::vlinkColor()
 void HTMLDocument::setVlinkColor(const String& value)
 {
     HTMLElement* b = body();
-    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0;
+    HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? toHTMLBodyElement(b) : 0;
 
     if (bodyElement) {
         // This check is a bit silly, but some benchmarks like to set the
index 23c4c3b..9816888 100644 (file)
@@ -186,7 +186,7 @@ bool HTMLEmbedElement::rendererIsNeeded(const RenderStyle& style)
     if (p && p->hasTagName(objectTag)) {
         if (!p->renderer())
             return false;
-        if (!static_cast<HTMLObjectElement*>(p)->useFallbackContent()) {
+        if (!toHTMLObjectElement(p)->useFallbackContent()) {
             ASSERT(!p->renderer()->isEmbeddedObject());
             return false;
         }
index 4ccc541..5ded9c3 100644 (file)
@@ -107,7 +107,7 @@ void HTMLFormControlElement::updateAncestorDisabledState() const
         if (!legendAncestor && ancestor->hasTagName(legendTag))
             legendAncestor = ancestor;
         if (ancestor->hasTagName(fieldsetTag)) {
-            fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor);
+            fieldSetAncestor = toHTMLFieldSetElement(ancestor);
             break;
         }
     }
@@ -473,7 +473,7 @@ HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node
 {
     for (; node; node = node->parentNode()) {
         if (node->isElementNode() && toElement(node)->isFormControlElement())
-            return static_cast<HTMLFormControlElement*>(node);
+            return toHTMLFormControlElement(node);
     }
     return 0;
 }
index 8f2c7c1..3ec01b7 100644 (file)
@@ -194,7 +194,7 @@ static inline HTMLFormControlElement* submitElementFromEvent(const Event* event)
 {
     for (Node* node = event->target()->toNode(); node; node = node->parentNode()) {
         if (node->isElementNode() && toElement(node)->isFormControlElement())
-            return static_cast<HTMLFormControlElement*>(node);
+            return toHTMLFormControlElement(node);
     }
     return 0;
 }
index 7c0e6cb..4743dcb 100644 (file)
@@ -86,7 +86,7 @@ void HTMLImageLoader::notifyFinished(CachedResource*)
     }
 
     if (loadError && isHTMLObjectElement(element.get()))
-        static_cast<HTMLObjectElement*>(element.get())->renderFallbackContent();
+        toHTMLObjectElement(element.get())->renderFallbackContent();
 }
 
 }
index bd1aca2..5973bc2 100644 (file)
@@ -82,7 +82,7 @@ HTMLFormElement* HTMLLegendElement::virtualForm() const
     if (!fieldset || !fieldset->hasTagName(fieldsetTag))
         return 0;
 
-    return static_cast<HTMLFieldSetElement*>(fieldset)->form();
+    return toHTMLFieldSetElement(fieldset)->form();
 }
     
 } // namespace
index d614169..ad7dc76 100644 (file)
@@ -87,9 +87,9 @@ bool RadioNodeList::checkElementMatchesRadioNodeListFilter(Element* testElement)
     if (isHTMLFormElement(ownerNode())) {
         HTMLFormElement* formElement = 0;
         if (testElement->hasTagName(objectTag))
-            formElement = static_cast<HTMLObjectElement*>(testElement)->form();
+            formElement = toHTMLObjectElement(testElement)->form();
         else
-            formElement = static_cast<HTMLFormControlElement*>(testElement)->form();
+            formElement = toHTMLFormControlElement(testElement)->form();
         if (!formElement || formElement != &ownerNode())
             return false;
     }
index d3c2a03..bf52ecc 100644 (file)
@@ -1308,7 +1308,7 @@ PassRefPtr<TypeBuilder::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node* n
         Element* element = toElement(node);
         value->setAttributes(buildArrayForElementAttributes(element));
         if (node->isFrameOwnerElement()) {
-            HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(node);
+            HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(node);
             Frame* frame = frameOwner->contentFrame();
             if (frame)
                 value->setFrameId(m_pageAgent->frameId(frame));
@@ -1325,7 +1325,7 @@ PassRefPtr<TypeBuilder::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node* n
 
 #if ENABLE(TEMPLATE_ELEMENT)
         if (element->hasTagName(HTMLNames::templateTag))
-            value->setTemplateContent(buildObjectForNode(static_cast<HTMLTemplateElement*>(element)->content(), 0, nodesMap));
+            value->setTemplateContent(buildObjectForNode(toHTMLTemplateElement(element)->content(), 0, nodesMap));
 #endif
 
     } else if (node->isDocumentNode()) {