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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159416 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 06282dcd
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.
......
......@@ -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;
}
......
......@@ -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.
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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())
......
......@@ -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();
......
......@@ -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);
}
}
......
......@@ -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;
}
......
......@@ -92,6 +92,8 @@ private:
virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const;
};
NODE_TYPE_CASTS(HTMLBodyElement)
} //namespace
#endif
......@@ -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
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -86,7 +86,7 @@ void HTMLImageLoader::notifyFinished(CachedResource*)
}
if (loadError && isHTMLObjectElement(element.get()))
static_cast<HTMLObjectElement*>(element.get())->renderFallbackContent();
toHTMLObjectElement(element.get())->renderFallbackContent();
}
}
......@@ -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
......@@ -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;
}
......
......@@ -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()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment