Generate toHTMLFooElement() to clean up static_cast<>
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Nov 2013 04:45:49 +0000 (04:45 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Nov 2013 04:45:49 +0000 (04:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124571

Reviewed by Ryosuke Niwa.

Though there are a lot of clean up commits before, there are still
use of static_cast<HTMLFooElement*>. To clean up them, we need to generate
toHTMLDetails|Meta|Summary|TableCaptionElement().

Additionally, other static_cast<> are removed as well.

No new tests, no behavior changes.

* html/HTMLDetailsElement.h:
* html/HTMLMediaElement.cpp:
(HTMLMediaElement::selectNextSourceChild):
* html/HTMLMetaElement.h:
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::isDisabledFormControl):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::updateWidgetCallback):
* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::detailsElement):
* html/HTMLSummaryElement.h:
* html/HTMLTableCaptionElement.h:
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::caption):
* html/HTMLTagNames.in:
* html/MediaDocument.cpp:
(WebCore::MediaDocumentParser::createDocumentStructure):
* html/shadow/DetailsMarkerControl.cpp:
(WebCore::DetailsMarkerControl::summaryElement):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::handleFallbackContent):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::dispatchPendingBeforeLoadEvent):
* page/DragController.cpp:
(WebCore::DragController::canProcessDrag):
* page/Frame.cpp:
(WebCore::Frame::searchForLabelsBeforeElement):
* page/SpatialNavigation.cpp:
(WebCore::frameOwnerElement):

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLDetailsElement.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMetaElement.h
Source/WebCore/html/HTMLObjectElement.cpp
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLSummaryElement.cpp
Source/WebCore/html/HTMLSummaryElement.h
Source/WebCore/html/HTMLTableCaptionElement.h
Source/WebCore/html/HTMLTableElement.cpp
Source/WebCore/html/HTMLTagNames.in
Source/WebCore/html/MediaDocument.cpp
Source/WebCore/html/shadow/DetailsMarkerControl.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/SpatialNavigation.cpp

index 6b5a7d9..e911776 100644 (file)
@@ -1,3 +1,50 @@
+2013-11-20  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Generate toHTMLFooElement() to clean up static_cast<>
+        https://bugs.webkit.org/show_bug.cgi?id=124571
+
+        Reviewed by Ryosuke Niwa.
+
+        Though there are a lot of clean up commits before, there are still
+        use of static_cast<HTMLFooElement*>. To clean up them, we need to generate
+        toHTMLDetails|Meta|Summary|TableCaptionElement().
+
+        Additionally, other static_cast<> are removed as well.
+
+        No new tests, no behavior changes.
+
+        * html/HTMLDetailsElement.h:
+        * html/HTMLMediaElement.cpp:
+        (HTMLMediaElement::selectNextSourceChild):
+        * html/HTMLMetaElement.h:
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk):
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::isDisabledFormControl):
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::updateWidgetCallback):
+        * html/HTMLSummaryElement.cpp:
+        (WebCore::HTMLSummaryElement::detailsElement):
+        * html/HTMLSummaryElement.h:
+        * html/HTMLTableCaptionElement.h:
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::caption):
+        * html/HTMLTagNames.in:
+        * html/MediaDocument.cpp:
+        (WebCore::MediaDocumentParser::createDocumentStructure):
+        * html/shadow/DetailsMarkerControl.cpp:
+        (WebCore::DetailsMarkerControl::summaryElement):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::handleFallbackContent):
+        * loader/ImageLoader.cpp:
+        (WebCore::ImageLoader::dispatchPendingBeforeLoadEvent):
+        * page/DragController.cpp:
+        (WebCore::DragController::canProcessDrag):
+        * page/Frame.cpp:
+        (WebCore::Frame::searchForLabelsBeforeElement):
+        * page/SpatialNavigation.cpp:
+        (WebCore::frameOwnerElement):
+
 2013-11-20  Ryosuke Niwa  <rniwa@webkit.org>
 
         Clear TemplateContentDocumentFragment::m_host when HTMLTemplateElement is destroyed
index 61b03d4..c1428e6 100644 (file)
@@ -44,6 +44,8 @@ private:
     bool m_isOpen;
 };
 
+NODE_TYPE_CASTS(HTMLDetailsElement)
+
 } // namespace WebCore
 
 #endif // HTMLDetailsElement_h
index d114310..a0d9b53 100644 (file)
@@ -3514,7 +3514,7 @@ URL HTMLMediaElement::selectNextSourceChild(ContentType* contentType, String* ke
         if (node.parentNode() != this)
             continue;
 
-        source = static_cast<HTMLSourceElement*>(&node);
+        source = toHTMLSourceElement(&node);
 
         // If candidate does not have a src attribute, or if its src attribute's value is the empty string ... jump down to the failed step below
         mediaURL = source->getNonEmptyURLAttribute(srcAttr);
index f97119e..7e40de9 100644 (file)
@@ -44,6 +44,8 @@ private:
     void process();
 };
 
+NODE_TYPE_CASTS(HTMLMetaElement)
+
 } // namespace WebCore
 
 #endif
index ae5a465..07f59a1 100644 (file)
@@ -243,9 +243,8 @@ bool HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk()
     RefPtr<NodeList> metaElements = document().getElementsByTagName(HTMLNames::metaTag.localName());
     unsigned length = metaElements->length();
     for (unsigned i = 0; i < length; ++i) {
-        ASSERT_WITH_SECURITY_IMPLICATION(metaElements->item(i)->isHTMLElement());
-        HTMLMetaElement* metaElement = static_cast<HTMLMetaElement*>(metaElements->item(i));
-        if (equalIgnoringCase(metaElement->name(), "generator") && metaElement->content().startsWith("Mac OS X Server Web Services Server", false))
+        HTMLMetaElement& metaElement = toHTMLMetaElement(*metaElements->item(i));
+        if (equalIgnoringCase(metaElement.name(), "generator") && metaElement.content().startsWith("Mac OS X Server Web Services Server", false))
             return true;
     }
     
index 3e77c6a..f2b3624 100644 (file)
@@ -344,8 +344,8 @@ bool HTMLOptionElement::isDisabledFormControl() const
     if (!parentNode() || !parentNode()->isHTMLElement())
         return false;
 
-    HTMLElement* parentElement = static_cast<HTMLElement*>(parentNode());
-    return isHTMLOptGroupElement(parentElement) && parentElement->isDisabledFormControl();
+    HTMLElement& parentElement = toHTMLElement(*parentNode());
+    return isHTMLOptGroupElement(parentElement) && parentElement.isDisabledFormControl();
 }
 
 Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode& insertionPoint)
index 5476eb5..2438dfe 100644 (file)
@@ -324,7 +324,7 @@ PassRefPtr<RenderStyle> HTMLPlugInImageElement::customStyleForRenderer()
 
 void HTMLPlugInImageElement::updateWidgetCallback(Node* n, unsigned)
 {
-    static_cast<HTMLPlugInImageElement*>(n)->updateWidgetIfNecessary();
+    toHTMLPlugInImageElement(n)->updateWidgetIfNecessary();
 }
 
 void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image)
index de8598e..ba19d33 100644 (file)
@@ -88,7 +88,7 @@ HTMLDetailsElement* HTMLSummaryElement::detailsElement() const
     Node* mayDetails = NodeRenderingTraversal::parent(this);
     if (!mayDetails || !mayDetails->hasTagName(detailsTag))
         return 0;
-    return static_cast<HTMLDetailsElement*>(mayDetails);
+    return toHTMLDetailsElement(mayDetails);
 }
 
 bool HTMLSummaryElement::isMainSummary() const
index 26a11d8..2ccd9fa 100644 (file)
@@ -46,6 +46,8 @@ private:
     bool supportsFocus() const OVERRIDE;
 };
 
+NODE_TYPE_CASTS(HTMLSummaryElement)
+
 }
 
 #endif // HTMLSummaryElement_h
index 42013de..3b2afb5 100644 (file)
@@ -41,6 +41,8 @@ private:
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet&) OVERRIDE;
 };
 
+NODE_TYPE_CASTS(HTMLTableCaptionElement)
+
 } // namespace
 
 #endif
index 65f6122..61297f0 100644 (file)
@@ -71,7 +71,7 @@ HTMLTableCaptionElement* HTMLTableElement::caption() const
 {
     for (Node* child = firstChild(); child; child = child->nextSibling()) {
         if (child->hasTagName(captionTag))
-            return static_cast<HTMLTableCaptionElement*>(child);
+            return toHTMLTableCaptionElement(child);
     }
     return 0;
 }
index 3894034..b8f2e53 100644 (file)
@@ -24,7 +24,7 @@ body generateTypeHelpers
 br interfaceName=HTMLBRElement
 button constructorNeedsFormElement
 canvas generateTypeHelpers
-caption interfaceName=HTMLTableCaptionElement
+caption interfaceName=HTMLTableCaptionElement, generateTypeHelpers
 center interfaceName=HTMLElement
 cite interfaceName=HTMLElement
 code interfaceName=HTMLElement
@@ -35,7 +35,7 @@ webkitShadowContent interfaceName=HTMLElement, noConstructor
 datalist interfaceName=HTMLDataListElement, conditional=DATALIST_ELEMENT, generateTypeHelpers
 dd interfaceName=HTMLElement
 del interfaceName=HTMLModElement
-details conditional=DETAILS_ELEMENT
+details conditional=DETAILS_ELEMENT, generateTypeHelpers 
 dfn interfaceName=HTMLElement
 dir interfaceName=HTMLDirectoryElement
 div
@@ -82,7 +82,7 @@ map generateTypeHelpers
 mark interfaceName=HTMLElement
 marquee
 menu
-meta
+meta generateTypeHelpers
 meter interfaceName=HTMLMeterElement, conditional=METER_ELEMENT, generateTypeHelpers
 nav interfaceName=HTMLElement
 nobr interfaceName=HTMLElement
@@ -115,7 +115,7 @@ strike interfaceName=HTMLElement
 strong interfaceName=HTMLElement
 style constructorNeedsCreatedByParser, generateTypeHelpers
 sub interfaceName=HTMLElement
-summary interfaceName=HTMLSummaryElement, JSInterfaceName=HTMLElement, conditional=DETAILS_ELEMENT
+summary interfaceName=HTMLSummaryElement, JSInterfaceName=HTMLElement, conditional=DETAILS_ELEMENT, generateTypeHelpers
 sup interfaceName=HTMLElement
 table generateTypeHelpers
 tbody interfaceName=HTMLTableSectionElement
index 83078cb..678cf41 100644 (file)
@@ -93,11 +93,11 @@ void MediaDocumentParser::createDocumentStructure()
     m_mediaElement->setAttribute(nameAttr, "media");
 
     RefPtr<Element> sourceElement = document()->createElement(sourceTag, false);
-    HTMLSourceElement* source = static_cast<HTMLSourceElement*>(sourceElement.get());
-    source->setSrc(document()->url());
+    HTMLSourceElement& source = toHTMLSourceElement(*sourceElement);
+    source.setSrc(document()->url());
 
     if (DocumentLoader* loader = document()->loader())
-        source->setType(loader->responseMIMEType());
+        source.setType(loader->responseMIMEType());
 
     m_mediaElement->appendChild(sourceElement, IGNORE_EXCEPTION);
     body->appendChild(mediaElement, IGNORE_EXCEPTION);
index 47be010..527a4d6 100644 (file)
@@ -63,9 +63,7 @@ const AtomicString& DetailsMarkerControl::shadowPseudoId() const
 
 HTMLSummaryElement* DetailsMarkerControl::summaryElement()
 {
-    Element* element = shadowHost();
-    ASSERT_WITH_SECURITY_IMPLICATION(!element || element->hasTagName(summaryTag));
-    return static_cast<HTMLSummaryElement*>(element);
+    return toHTMLSummaryElement(shadowHost());
 }
 
 }
index 4eeb1d0..f3474c3 100644 (file)
@@ -986,7 +986,7 @@ void FrameLoader::handleFallbackContent()
     HTMLFrameOwnerElement* owner = m_frame.ownerElement();
     if (!owner || !owner->hasTagName(objectTag))
         return;
-    static_cast<HTMLObjectElement*>(owner)->renderFallbackContent();
+    toHTMLObjectElement(owner)->renderFallbackContent();
 }
 
 void FrameLoader::provisionalLoadStarted()
index 011bcda..b53b88a 100644 (file)
@@ -417,7 +417,7 @@ void ImageLoader::dispatchPendingBeforeLoadEvent()
     m_hasPendingLoadEvent = false;
     
     if (isHTMLObjectElement(m_element))
-        static_cast<HTMLObjectElement*>(m_element)->renderFallbackContent();
+        toHTMLObjectElement(m_element)->renderFallbackContent();
 
     // Only consider updating the protection ref-count of the Element immediately before returning
     // from this function as doing so might result in the destruction of this ImageLoader.
index 7eb249d..4c28957 100644 (file)
@@ -552,8 +552,7 @@ bool DragController::canProcessDrag(DragData& dragData)
         return true;
 
     if (result.innerNonSharedNode()->isPluginElement()) {
-        HTMLPlugInElement* plugin = static_cast<HTMLPlugInElement*>(result.innerNonSharedNode());
-        if (!plugin->canProcessDrag() && !result.innerNonSharedNode()->rendererIsEditable())
+        if (!toHTMLPlugInElement(result.innerNonSharedNode())->canProcessDrag() && !result.innerNonSharedNode()->rendererIsEditable())
             return false;
     } else if (!result.innerNonSharedNode()->rendererIsEditable())
         return false;
index 6241ee3..d23ba5f 100644 (file)
@@ -386,7 +386,7 @@ String Frame::searchForLabelsBeforeElement(const Vector<String>& labels, Element
             break;
 
         if (n->hasTagName(tdTag) && !startingTableCell) {
-            startingTableCell = static_cast<HTMLTableCellElement*>(n);
+            startingTableCell = toHTMLTableCellElement(n);
         } else if (n->hasTagName(trTag) && startingTableCell) {
             String result = searchForLabelsAboveCell(regExp.get(), startingTableCell, resultDistance);
             if (!result.isEmpty()) {
index 53f7c37..da37c4b 100644 (file)
@@ -758,7 +758,7 @@ LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement* area, FocusDir
 
 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate)
 {
-    return candidate.isFrameOwnerElement() ? static_cast<HTMLFrameOwnerElement*>(candidate.visibleNode) : 0;
+    return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.visibleNode) : nullptr;
 };
 
 } // namespace WebCore