Stop using legacy NODE_TYPE_CASTS() macro for HTML Elements
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Sep 2014 01:32:34 +0000 (01:32 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Sep 2014 01:32:34 +0000 (01:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137137

Reviewed by Benjamin Poulain.

Source/WebCore:

Stop using legacy NODE_TYPE_CASTS() macro for HTML Elements and use the
new SPECIALIZE_TYPE_TRAITS_*() macro instead so that is<>() /
downcast<>() works for those types.

No new tests, no behavior change.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::labelForElement):
(WebCore::AccessibilityNodeObject::text):
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::isDataTable):
* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetName):
(webkitAccessibleGetDescription):
* bindings/gobject/WebKitDOMPrivate.cpp:
(WebKit::wrap):
* bindings/js/JSElementCustom.cpp:
(WebCore::toJSNewlyCreated):
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline):
* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginInstance):
(WebCore::pluginScriptObjectFromPluginViewBase):
(WebCore::pluginScriptObject):
(WebCore::pluginElementCustomPut):
(WebCore::isPluginElement): Deleted.
* bindings/objc/DOM.mm:
(kitClass):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::matchAllRules):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::locateCousinList):
(WebCore::elementHasDirectionAuto):
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown):
(WebCore::SelectorCompiler::makeElementStyleUniqueIfNecessaryAndTestIsPlaceholderShown):
(WebCore::SelectorCompiler::isPlaceholderShown):
* dom/ContainerNodeAlgorithms.cpp:
(WebCore::assertConnectedSubrameCountIsConsistent):
(WebCore::collectFrameOwners):
(WebCore::disconnectSubframes):
* dom/Document.cpp:
(WebCore::Document::adoptNode):
(WebCore::Document::setBody):
(WebCore::Document::iconURLs):
(WebCore::Document::dispatchFullScreenChangeOrErrorEvent):
(WebCore::Document::updateHoverActiveState):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
* dom/Range.cpp:
(WebCore::Range::createContextualFragment):
* dom/make_names.pl:
(printTypeHelpers):
* editing/ApplyStyleCommand.cpp:
(WebCore::isLegacyAppleStyleSpan):
(WebCore::isStyleSpanOrSpanWithOnlyStyleAttribute):
(WebCore::isSpanWithoutAttributesOrUnstyledStyleSpan):
(WebCore::isEmptyFontTag):
(WebCore::ApplyStyleCommand::applyBlockStyle):
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
(WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi):
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
(WebCore::ApplyStyleCommand::removeConflictingInlineStyleFromRun):
(WebCore::ApplyStyleCommand::highestAncestorWithConflictingInlineStyle):
(WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
(WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
(WebCore::ApplyStyleCommand::removeInlineStyle):
(WebCore::ApplyStyleCommand::shouldSplitTextElement):
(WebCore::ApplyStyleCommand::applyInlineStyleChange):
* editing/DeleteButtonController.cpp:
(WebCore::enclosingDeletableElement):
* editing/Editor.cpp:
(WebCore::Editor::selectionForCommand):
(WebCore::Editor::setBaseWritingDirection):
(WebCore::findFirstMarkable):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll):
(WebCore::scanForForm):
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::mergeWithNeighboringLists):
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::elementCannotHaveEndTag):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
(WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
(WebCore::ReplaceSelectionCommand::handleStyleSpans):
(WebCore::ReplaceSelectionCommand::doApply):
(WebCore::ReplaceSelectionCommand::insertAsListItems):
* editing/TextIterator.cpp:
(WebCore::shouldEmitNewlinesBeforeAndAfterNode):
(WebCore::shouldEmitExtraNewlineForNode):
* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_addTableCellForElement):
(HTMLConverter::_processElement):
* editing/htmlediting.cpp:
(WebCore::enclosingList):
(WebCore::embeddedSublist):
(WebCore::appendedSublist):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::setTextAlignmentForChangedBaseWritingDirection):
* editing/mac/EditorMac.mm:
(WebCore::maybeCopyNodeAttributesToFragment):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendElement):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::BaseChooserOnlyDateAndTimeInputType::updateAppearance):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::shadowColorSwatch):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::insertedInto):
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::namedItem):
(WebCore::HTMLCollection::updateNamedElementCache):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::matchesReadWritePseudoClass):
(WebCore::HTMLElement::setOuterHTML):
(WebCore::elementAffectsDirectionality):
(WebCore::HTMLElement::directionality):
(WebCore::HTMLElement::dirAttributeChanged):
* html/HTMLElement.h:
(WebCore::isHTMLElement):
(WebCore::Node::hasTagName):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::getNamedElements):
* html/HTMLFrameElementBase.h:
(WebCore::isHTMLFrameElementBase):
* html/HTMLFrameOwnerElement.h:
(WebCore::isHTMLFrameOwnerElement):
* html/HTMLMediaElement.h:
(WebCore::isHTMLMediaElement):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::isDisabledFormControl):
* html/HTMLPlugInElement.h:
(WebCore::isHTMLPlugInElement):
* html/HTMLPlugInImageElement.cpp:
(WebCore::addPlugInsFromNodeListMatchingPlugInOrigin):
* html/HTMLPlugInImageElement.h:
(WebCore::isHTMLPlugInImageElement):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::setOption):
(WebCore::HTMLSelectElement::setLength):
(WebCore::HTMLSelectElement::recalcListItems):
* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::insertedInto):
(WebCore::HTMLSourceElement::removedFrom):
* html/HTMLTableCellElement.cpp:
(WebCore::HTMLTableCellElement::cellAbove):
* html/HTMLTableCellElement.h:
(WebCore::isHTMLTableCellElement):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::tHead):
(WebCore::HTMLTableElement::tFoot):
(WebCore::HTMLTableElement::lastBody):
* html/HTMLTableRowElement.cpp:
(WebCore::HTMLTableRowElement::rowIndex):
* html/HTMLTableRowsCollection.cpp:
(WebCore::isInSection):
* html/HTMLTableSectionElement.h:
(WebCore::isHTMLTableSectionElement):
* html/HTMLTagNames.in:
* html/HTMLTextFormControlElement.cpp:
(WebCore::enclosingTextFormControl):
* html/HTMLTextFormControlElement.h:
(WebCore::isHTMLTextFormControlElement):
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::removedFrom):
(WebCore::HTMLTrackElement::mediaElement):
* html/LabelableElement.h:
(WebCore::isLabelableElement):
* html/RangeInputType.cpp:
(WebCore::RangeInputType::sliderTrackElement):
* html/shadow/MediaControlElementTypes.cpp:
(WebCore::parentMediaElement):
(WebCore::mediaControlElementType):
* html/shadow/TextControlInnerElements.h:
(WebCore::isTextControlInnerTextElement):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForNode):
* inspector/InspectorNodeFinder.cpp:
(WebCore::InspectorNodeFinder::searchUsingDOMTreeTraversal):
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::loadSubframe):
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::isPhrasingContent):
(WebCore::MathMLElement::isFlowContent):
(WebCore::MathMLElement::childShouldCreateRenderer):
* mathml/mathtags.in:
* page/DragController.cpp:
(WebCore::DragController::canProcessDrag):
* page/EventHandler.cpp:
(WebCore::targetIsFrame):
* page/FocusController.cpp:
(WebCore::hasCustomFocusLogic):
(WebCore::FocusController::findFocusableElementDescendingDownIntoFrameDocument):
(WebCore::FocusController::advanceFocusInDocumentOrder):
* page/Frame.cpp:
(WebCore::Frame::searchForLabelsBeforeElement):
* page/FrameView.cpp:
(WebCore::FrameView::init):
(WebCore::FrameView::addEmbeddedObjectToUpdate):
(WebCore::FrameView::updateEmbeddedObject):
* page/PageSerializer.cpp:
(WebCore::isCharsetSpecifyingNode):
(WebCore::SerializerMarkupAccumulator::appendCustomAttributes):
* page/SpatialNavigation.cpp:
(WebCore::frameOwnerElement):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absolutePDFURL):
(WebCore::HitTestResult::mediaElement):
* rendering/RenderBlockFlow.cpp:
(WebCore::resizeTextPermitted):
* rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::paintContents):
(WebCore::RenderEmbeddedObject::layout):
(WebCore::RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible):
(WebCore::RenderLayer::updateSnapOffsets):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::isRestartedPlugin):
* rendering/RenderMedia.h:
(WebCore::RenderMedia::mediaElement):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::offsetParent):
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::plugInImageElement):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::parseColSpanFromDOM):
(WebCore::RenderTableCell::parseRowSpanFromDOM):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::textFormControlElement):
* rendering/RenderThemeGtk.cpp:
(WebCore::getMediaElementFromRenderObject):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintSearchFieldCancelButton):
(WebCore::RenderThemeMac::paintSnapshottedPluginOverlay):
* rendering/RenderTreeAsText.cpp:
(WebCore::isEmptyOrUnstyledAppleStyleSpan):
* rendering/RenderWidget.h:
(WebCore::RenderWidget::frameOwnerElement):
* testing/Internals.cpp:
(WebCore::Internals::visiblePlaceholder):
(WebCore::Internals::simulateAudioInterruption):
(WebCore::Internals::isPluginSnapshotted):
* xml/XPathStep.cpp:
(WebCore::XPath::nodeMatchesBasicTest):

Source/WebKit/win:

Use is<>() / downcast<>() where appropriate.

* DOMHTMLClasses.cpp:
(DOMHTMLElement::idName):
(DOMHTMLElement::innerText):
(DOMHTMLElement::setInnerText):

Source/WebKit2:

Use is<>() / downcast<>() where appropriate.

* WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:
(WebKit::PDFPluginTextAnnotation::value):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::initializePlugin):
(WebKit::PluginView::pluginSnapshotTimerFired):
(WebKit::PluginView::pluginDidReceiveUserInteraction):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::performActionOnElement):

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

97 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityTable.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp
Source/WebCore/bindings/js/JSElementCustom.cpp
Source/WebCore/bindings/js/JSNodeCustom.cpp
Source/WebCore/bindings/js/JSPluginElementFunctions.cpp
Source/WebCore/bindings/objc/DOM.mm
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/cssjit/SelectorCompiler.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentStyleSheetCollection.cpp
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/make_names.pl
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/DeleteButtonController.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/InsertListCommand.cpp
Source/WebCore/editing/MarkupAccumulator.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/editing/markup.cpp
Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/HTMLBodyElement.cpp
Source/WebCore/html/HTMLCollection.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLFrameElementBase.h
Source/WebCore/html/HTMLFrameOwnerElement.h
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLPlugInElement.h
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/HTMLSourceElement.cpp
Source/WebCore/html/HTMLTableCellElement.cpp
Source/WebCore/html/HTMLTableCellElement.h
Source/WebCore/html/HTMLTableElement.cpp
Source/WebCore/html/HTMLTableRowElement.cpp
Source/WebCore/html/HTMLTableRowsCollection.cpp
Source/WebCore/html/HTMLTableSectionElement.h
Source/WebCore/html/HTMLTagNames.in
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.h
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/LabelableElement.h
Source/WebCore/html/RangeInputType.cpp
Source/WebCore/html/shadow/MediaControlElementTypes.cpp
Source/WebCore/html/shadow/TextControlInnerElements.h
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorNodeFinder.cpp
Source/WebCore/loader/SubframeLoader.cpp
Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
Source/WebCore/mathml/MathMLElement.cpp
Source/WebCore/mathml/mathtags.in
Source/WebCore/page/DragController.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/page/SpatialNavigation.cpp
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderEmbeddedObject.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderMedia.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTextControl.cpp
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/RenderWidget.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/xml/XPathStep.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMHTMLClasses.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index 13952b9..a3481c0 100644 (file)
@@ -1,3 +1,262 @@
+2014-09-26  Christophe Dumez  <cdumez@apple.com>
+
+        Stop using legacy NODE_TYPE_CASTS() macro for HTML Elements
+        https://bugs.webkit.org/show_bug.cgi?id=137137
+
+        Reviewed by Benjamin Poulain.
+
+        Stop using legacy NODE_TYPE_CASTS() macro for HTML Elements and use the
+        new SPECIALIZE_TYPE_TRAITS_*() macro instead so that is<>() /
+        downcast<>() works for those types.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::labelForElement):
+        (WebCore::AccessibilityNodeObject::text):
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::isDataTable):
+        * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
+        (webkitAccessibleGetName):
+        (webkitAccessibleGetDescription):
+        * bindings/gobject/WebKitDOMPrivate.cpp:
+        (WebKit::wrap):
+        * bindings/js/JSElementCustom.cpp:
+        (WebCore::toJSNewlyCreated):
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::createWrapperInline):
+        * bindings/js/JSPluginElementFunctions.cpp:
+        (WebCore::pluginInstance):
+        (WebCore::pluginScriptObjectFromPluginViewBase):
+        (WebCore::pluginScriptObject):
+        (WebCore::pluginElementCustomPut):
+        (WebCore::isPluginElement): Deleted.
+        * bindings/objc/DOM.mm:
+        (kitClass):
+        * css/ElementRuleCollector.cpp:
+        (WebCore::ElementRuleCollector::matchAllRules):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOne):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::locateCousinList):
+        (WebCore::elementHasDirectionAuto):
+        * cssjit/SelectorCompiler.cpp:
+        (WebCore::SelectorCompiler::makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown):
+        (WebCore::SelectorCompiler::makeElementStyleUniqueIfNecessaryAndTestIsPlaceholderShown):
+        (WebCore::SelectorCompiler::isPlaceholderShown):
+        * dom/ContainerNodeAlgorithms.cpp:
+        (WebCore::assertConnectedSubrameCountIsConsistent):
+        (WebCore::collectFrameOwners):
+        (WebCore::disconnectSubframes):
+        * dom/Document.cpp:
+        (WebCore::Document::adoptNode):
+        (WebCore::Document::setBody):
+        (WebCore::Document::iconURLs):
+        (WebCore::Document::dispatchFullScreenChangeOrErrorEvent):
+        (WebCore::Document::updateHoverActiveState):
+        * dom/DocumentStyleSheetCollection.cpp:
+        (WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
+        * dom/Range.cpp:
+        (WebCore::Range::createContextualFragment):
+        * dom/make_names.pl:
+        (printTypeHelpers):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::isLegacyAppleStyleSpan):
+        (WebCore::isStyleSpanOrSpanWithOnlyStyleAttribute):
+        (WebCore::isSpanWithoutAttributesOrUnstyledStyleSpan):
+        (WebCore::isEmptyFontTag):
+        (WebCore::ApplyStyleCommand::applyBlockStyle):
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
+        (WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi):
+        (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
+        (WebCore::ApplyStyleCommand::removeConflictingInlineStyleFromRun):
+        (WebCore::ApplyStyleCommand::highestAncestorWithConflictingInlineStyle):
+        (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
+        (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
+        (WebCore::ApplyStyleCommand::removeInlineStyle):
+        (WebCore::ApplyStyleCommand::shouldSplitTextElement):
+        (WebCore::ApplyStyleCommand::applyInlineStyleChange):
+        * editing/DeleteButtonController.cpp:
+        (WebCore::enclosingDeletableElement):
+        * editing/Editor.cpp:
+        (WebCore::Editor::selectionForCommand):
+        (WebCore::Editor::setBaseWritingDirection):
+        (WebCore::findFirstMarkable):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::selectAll):
+        (WebCore::scanForForm):
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::mergeWithNeighboringLists):
+        * editing/MarkupAccumulator.cpp:
+        (WebCore::MarkupAccumulator::elementCannotHaveEndTag):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
+        (WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
+        (WebCore::ReplaceSelectionCommand::handleStyleSpans):
+        (WebCore::ReplaceSelectionCommand::doApply):
+        (WebCore::ReplaceSelectionCommand::insertAsListItems):
+        * editing/TextIterator.cpp:
+        (WebCore::shouldEmitNewlinesBeforeAndAfterNode):
+        (WebCore::shouldEmitExtraNewlineForNode):
+        * editing/cocoa/HTMLConverter.mm:
+        (HTMLConverter::_addTableCellForElement):
+        (HTMLConverter::_processElement):
+        * editing/htmlediting.cpp:
+        (WebCore::enclosingList):
+        (WebCore::embeddedSublist):
+        (WebCore::appendedSublist):
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::setTextAlignmentForChangedBaseWritingDirection):
+        * editing/mac/EditorMac.mm:
+        (WebCore::maybeCopyNodeAttributesToFragment):
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::appendElement):
+        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
+        (WebCore::BaseChooserOnlyDateAndTimeInputType::updateAppearance):
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::shadowColorSwatch):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::insertedInto):
+        * html/HTMLCollection.cpp:
+        (WebCore::HTMLCollection::namedItem):
+        (WebCore::HTMLCollection::updateNamedElementCache):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::matchesReadWritePseudoClass):
+        (WebCore::HTMLElement::setOuterHTML):
+        (WebCore::elementAffectsDirectionality):
+        (WebCore::HTMLElement::directionality):
+        (WebCore::HTMLElement::dirAttributeChanged):
+        * html/HTMLElement.h:
+        (WebCore::isHTMLElement):
+        (WebCore::Node::hasTagName):
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::getNamedElements):
+        * html/HTMLFrameElementBase.h:
+        (WebCore::isHTMLFrameElementBase):
+        * html/HTMLFrameOwnerElement.h:
+        (WebCore::isHTMLFrameOwnerElement):
+        * html/HTMLMediaElement.h:
+        (WebCore::isHTMLMediaElement):
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::isDisabledFormControl):
+        * html/HTMLPlugInElement.h:
+        (WebCore::isHTMLPlugInElement):
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::addPlugInsFromNodeListMatchingPlugInOrigin):
+        * html/HTMLPlugInImageElement.h:
+        (WebCore::isHTMLPlugInImageElement):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::setOption):
+        (WebCore::HTMLSelectElement::setLength):
+        (WebCore::HTMLSelectElement::recalcListItems):
+        * html/HTMLSourceElement.cpp:
+        (WebCore::HTMLSourceElement::insertedInto):
+        (WebCore::HTMLSourceElement::removedFrom):
+        * html/HTMLTableCellElement.cpp:
+        (WebCore::HTMLTableCellElement::cellAbove):
+        * html/HTMLTableCellElement.h:
+        (WebCore::isHTMLTableCellElement):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::tHead):
+        (WebCore::HTMLTableElement::tFoot):
+        (WebCore::HTMLTableElement::lastBody):
+        * html/HTMLTableRowElement.cpp:
+        (WebCore::HTMLTableRowElement::rowIndex):
+        * html/HTMLTableRowsCollection.cpp:
+        (WebCore::isInSection):
+        * html/HTMLTableSectionElement.h:
+        (WebCore::isHTMLTableSectionElement):
+        * html/HTMLTagNames.in:
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::enclosingTextFormControl):
+        * html/HTMLTextFormControlElement.h:
+        (WebCore::isHTMLTextFormControlElement):
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::removedFrom):
+        (WebCore::HTMLTrackElement::mediaElement):
+        * html/LabelableElement.h:
+        (WebCore::isLabelableElement):
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::sliderTrackElement):
+        * html/shadow/MediaControlElementTypes.cpp:
+        (WebCore::parentMediaElement):
+        (WebCore::mediaControlElementType):
+        * html/shadow/TextControlInnerElements.h:
+        (WebCore::isTextControlInnerTextElement):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForNode):
+        * inspector/InspectorNodeFinder.cpp:
+        (WebCore::InspectorNodeFinder::searchUsingDOMTreeTraversal):
+        * loader/SubframeLoader.cpp:
+        (WebCore::SubframeLoader::loadSubframe):
+        * loader/archive/cf/LegacyWebArchive.cpp:
+        (WebCore::LegacyWebArchive::create):
+        * mathml/MathMLElement.cpp:
+        (WebCore::MathMLElement::isPhrasingContent):
+        (WebCore::MathMLElement::isFlowContent):
+        (WebCore::MathMLElement::childShouldCreateRenderer):
+        * mathml/mathtags.in:
+        * page/DragController.cpp:
+        (WebCore::DragController::canProcessDrag):
+        * page/EventHandler.cpp:
+        (WebCore::targetIsFrame):
+        * page/FocusController.cpp:
+        (WebCore::hasCustomFocusLogic):
+        (WebCore::FocusController::findFocusableElementDescendingDownIntoFrameDocument):
+        (WebCore::FocusController::advanceFocusInDocumentOrder):
+        * page/Frame.cpp:
+        (WebCore::Frame::searchForLabelsBeforeElement):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::init):
+        (WebCore::FrameView::addEmbeddedObjectToUpdate):
+        (WebCore::FrameView::updateEmbeddedObject):
+        * page/PageSerializer.cpp:
+        (WebCore::isCharsetSpecifyingNode):
+        (WebCore::SerializerMarkupAccumulator::appendCustomAttributes):
+        * page/SpatialNavigation.cpp:
+        (WebCore::frameOwnerElement):
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::absolutePDFURL):
+        (WebCore::HitTestResult::mediaElement):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::resizeTextPermitted):
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::paintContents):
+        (WebCore::RenderEmbeddedObject::layout):
+        (WebCore::RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollRectToVisible):
+        (WebCore::RenderLayer::updateSnapOffsets):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateConfiguration):
+        (WebCore::isRestartedPlugin):
+        * rendering/RenderMedia.h:
+        (WebCore::RenderMedia::mediaElement):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::offsetParent):
+        * rendering/RenderSnapshottedPlugIn.cpp:
+        (WebCore::RenderSnapshottedPlugIn::plugInImageElement):
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::parseColSpanFromDOM):
+        (WebCore::RenderTableCell::parseRowSpanFromDOM):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::textFormControlElement):
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::getMediaElementFromRenderObject):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintSearchFieldCancelButton):
+        (WebCore::RenderThemeMac::paintSnapshottedPluginOverlay):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::isEmptyOrUnstyledAppleStyleSpan):
+        * rendering/RenderWidget.h:
+        (WebCore::RenderWidget::frameOwnerElement):
+        * testing/Internals.cpp:
+        (WebCore::Internals::visiblePlaceholder):
+        (WebCore::Internals::simulateAudioInterruption):
+        (WebCore::Internals::isPluginSnapshotted):
+        * xml/XPathStep.cpp:
+        (WebCore::XPath::nodeMatchesBasicTest):
+
 2014-09-26  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Automatic Inspection should continue once all breakpoints are loaded
index d74c120..cf80b7b 100644 (file)
@@ -1159,7 +1159,7 @@ bool AccessibilityNodeObject::isGenericFocusableElement() const
 
 HTMLLabelElement* AccessibilityNodeObject::labelForElement(Element* element) const
 {
-    if (!element->isHTMLElement() || !toHTMLElement(element)->isLabelable())
+    if (!is<HTMLElement>(element) || !downcast<HTMLElement>(element)->isLabelable())
         return nullptr;
 
     const AtomicString& id = element->getIdAttribute();
@@ -1750,8 +1750,8 @@ String AccessibilityNodeObject::text() const
     if (!node)
         return String();
 
-    if (isNativeTextControl() && isHTMLTextFormControlElement(*node))
-        return toHTMLTextFormControlElement(*node).value();
+    if (isNativeTextControl() && is<HTMLTextFormControlElement>(*node))
+        return downcast<HTMLTextFormControlElement>(*node).value();
 
     if (!node->isElementNode())
         return String();
index 6b7e6cf..828874f 100644 (file)
@@ -218,10 +218,10 @@ bool AccessibilityTable::isDataTable() const
                 headersInFirstColumnCount++;
             
             // In this case, the developer explicitly assigned a "data" table attribute.
-            if (cellElement->hasTagName(tdTag) || cellElement->hasTagName(thTag)) {
-                HTMLTableCellElement* tableCellElement = toHTMLTableCellElement(cellElement);
-                if (!tableCellElement->headers().isEmpty() || !tableCellElement->abbr().isEmpty()
-                    || !tableCellElement->axis().isEmpty() || !tableCellElement->scope().isEmpty())
+            if (is<HTMLTableCellElement>(cellElement)) {
+                HTMLTableCellElement& tableCellElement = downcast<HTMLTableCellElement>(*cellElement);
+                if (!tableCellElement.headers().isEmpty() || !tableCellElement.abbr().isEmpty()
+                    || !tableCellElement.axis().isEmpty() || !tableCellElement.scope().isEmpty())
                     return true;
             }
             const RenderStyle& renderStyle = cell->style();
index 074535a..f06ff48 100644 (file)
@@ -141,9 +141,9 @@ static const gchar* webkitAccessibleGetName(AtkObject* object)
 
     if (coreObject->isImage() || coreObject->isInputImage()) {
         Node* node = coreObject->node();
-        if (node && node->isHTMLElement()) {
+        if (node && is<HTMLElement>(node)) {
             // Get the attribute rather than altText String so as not to fall back on title.
-            String alt = toHTMLElement(node)->getAttribute(HTMLNames::altAttr);
+            const AtomicString& alt = downcast<HTMLElement>(*node).getAttribute(HTMLNames::altAttr);
             if (!alt.isEmpty())
                 return cacheAndReturnAtkProperty(object, AtkCachedAccessibleName, alt);
         }
@@ -174,7 +174,7 @@ static const gchar* webkitAccessibleGetDescription(AtkObject* object)
     Node* node = nullptr;
     if (coreObject->isAccessibilityRenderObject())
         node = coreObject->node();
-    if (!node || !node->isHTMLElement() || coreObject->ariaRoleAttribute() != UnknownRole || coreObject->isImage())
+    if (!node || !is<HTMLElement>(node) || coreObject->ariaRoleAttribute() != UnknownRole || coreObject->isImage())
         return cacheAndReturnAtkProperty(object, AtkCachedAccessibleDescription, accessibilityDescription(coreObject));
 
     // atk_table_get_summary returns an AtkObject. We have no summary object, so expose summary here.
@@ -186,7 +186,7 @@ static const gchar* webkitAccessibleGetDescription(AtkObject* object)
 
     // The title attribute should be reliably available as the object's descripton.
     // We do not want to fall back on other attributes in its absence. See bug 25524.
-    String title = toHTMLElement(node)->title();
+    String title = downcast<HTMLElement>(*node).title();
     if (!title.isEmpty())
         return cacheAndReturnAtkProperty(object, AtkCachedAccessibleDescription, title);
 
index 45166ce..825dfac 100644 (file)
@@ -84,8 +84,8 @@ WebKitDOMNode* wrap(Node* node)
 
     switch (node->nodeType()) {
     case Node::ELEMENT_NODE:
-        if (node->isHTMLElement())
-            return WEBKIT_DOM_NODE(wrap(toHTMLElement(node)));
+        if (is<HTMLElement>(node))
+            return WEBKIT_DOM_NODE(wrap(downcast<HTMLElement>(node)));
         return WEBKIT_DOM_NODE(wrapElement(toElement(node)));
     case Node::ATTRIBUTE_NODE:
         return WEBKIT_DOM_NODE(wrapAttr(static_cast<Attr*>(node)));
index 6c917e2..ed85719 100644 (file)
@@ -56,9 +56,9 @@ JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Element* e
     ASSERT(!getCachedWrapper(globalObject->world(), element));
 
     JSDOMWrapper* wrapper;        
-    if (element->isHTMLElement())
-        wrapper = createJSHTMLWrapper(globalObject, toHTMLElement(element));
-    else if (element->isSVGElement())
+    if (is<HTMLElement>(element))
+        wrapper = createJSHTMLWrapper(globalObject, downcast<HTMLElement>(element));
+    else if (is<SVGElement>(element))
         wrapper = createJSSVGWrapper(globalObject, downcast<SVGElement>(element));
     else
         wrapper = CREATE_DOM_WRAPPER(globalObject, Element, element);
index 7cab184..7d08a20 100644 (file)
@@ -192,9 +192,9 @@ static ALWAYS_INLINE JSValue createWrapperInline(ExecState* exec, JSDOMGlobalObj
     JSDOMWrapper* wrapper;    
     switch (node->nodeType()) {
         case Node::ELEMENT_NODE:
-            if (node->isHTMLElement())
-                wrapper = createJSHTMLWrapper(globalObject, toHTMLElement(node));
-            else if (node->isSVGElement())
+            if (is<HTMLElement>(node))
+                wrapper = createJSHTMLWrapper(globalObject, downcast<HTMLElement>(node));
+            else if (is<SVGElement>(node))
                 wrapper = createJSSVGWrapper(globalObject, downcast<SVGElement>(node));
             else
                 wrapper = CREATE_DOM_WRAPPER(globalObject, Element, node);
index 174488d..81aee9d 100644 (file)
@@ -35,19 +35,14 @@ using namespace HTMLNames;
 
 // JavaScript access to plug-in-exported properties for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
 
-static inline bool isPluginElement(HTMLElement& element)
-{
-    return element.hasTagName(objectTag) || element.hasTagName(embedTag) || element.hasTagName(appletTag);
-}
-
 Instance* pluginInstance(HTMLElement& element)
 {
     // The plugin element holds an owning reference, so we don't have to.
-    if (!isPluginElement(element))
-        return 0;
-    Instance* instance = toHTMLPlugInElement(element).getInstance().get();
+    if (!is<HTMLPlugInElement>(element))
+        return nullptr;
+    Instance* instance = downcast<HTMLPlugInElement>(element).getInstance().get();
     if (!instance || !instance->rootObject())
-        return 0;
+        return nullptr;
     return instance;
 }
 
@@ -55,10 +50,10 @@ static JSObject* pluginScriptObjectFromPluginViewBase(HTMLPlugInElement& pluginE
 {
     Widget* pluginWidget = pluginElement.pluginWidget();
     if (!pluginWidget)
-        return 0;
+        return nullptr;
     
     if (!pluginWidget->isPluginViewBase())
-        return 0;
+        return nullptr;
 
     PluginViewBase* pluginViewBase = toPluginViewBase(pluginWidget);
     return pluginViewBase->scriptObject(globalObject);
@@ -67,20 +62,20 @@ static JSObject* pluginScriptObjectFromPluginViewBase(HTMLPlugInElement& pluginE
 static JSObject* pluginScriptObjectFromPluginViewBase(JSHTMLElement* jsHTMLElement)
 {
     HTMLElement& element = jsHTMLElement->impl();
-    if (!isPluginElement(element))
-        return 0;
+    if (!is<HTMLPlugInElement>(element))
+        return nullptr;
 
-    HTMLPlugInElement& pluginElement = toHTMLPlugInElement(element);
+    HTMLPlugInElement& pluginElement = downcast<HTMLPlugInElement>(element);
     return pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject());
 }
 
 JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement)
 {
     HTMLElement& element = jsHTMLElement->impl();
-    if (!isPluginElement(element))
-        return 0;
+    if (!is<HTMLPlugInElement>(element))
+        return nullptr;
 
-    HTMLPlugInElement& pluginElement = toHTMLPlugInElement(element);
+    HTMLPlugInElement& pluginElement = downcast<HTMLPlugInElement>(element);
 
     // Choke point for script/plugin interaction; notify DOMTimer of the event.
     DOMTimer::scriptDidInteractWithPlugin(pluginElement);
@@ -98,7 +93,7 @@ JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement)
     // The plugin element holds an owning reference, so we don't have to.
     Instance* instance = pluginElement.getInstance().get();
     if (!instance || !instance->rootObject())
-        return 0;
+        return nullptr;
 
     return instance->createRuntimeObject(exec);
 }
@@ -132,7 +127,7 @@ bool pluginElementCustomPut(ExecState* exec, PropertyName propertyName, JSValue
 {
     JSObject* scriptObject = pluginScriptObject(exec, element);
     if (!scriptObject)
-        return 0;
+        return false;
     if (!scriptObject->hasProperty(exec, propertyName))
         return false;
     scriptObject->methodTable()->put(scriptObject, exec, propertyName, value, slot);
index 780940c..d504a74 100644 (file)
@@ -301,8 +301,8 @@ Class kitClass(WebCore::Node* impl)
 {
     switch (impl->nodeType()) {
         case WebCore::Node::ELEMENT_NODE:
-            if (impl->isHTMLElement())
-                return WebCore::elementClass(toHTMLElement(impl)->tagQName(), [DOMHTMLElement class]);
+            if (is<HTMLElement>(impl))
+                return WebCore::elementClass(downcast<HTMLElement>(*impl).tagQName(), [DOMHTMLElement class]);
             return [DOMElement class];
         case WebCore::Node::ATTRIBUTE_NODE:
             return [DOMAttr class];
index 10822a7..c273048 100644 (file)
@@ -397,9 +397,9 @@ void ElementRuleCollector::matchAllRules(bool matchAuthorAndUserStyles, bool inc
         // after all attributes, since their mapped style depends on the values of multiple attributes.
         addElementStyleProperties(styledElement.additionalPresentationAttributeStyle());
 
-        if (styledElement.isHTMLElement()) {
+        if (is<HTMLElement>(styledElement)) {
             bool isAuto;
-            TextDirection textDirection = toHTMLElement(styledElement).directionalityIfhasDirAutoAttribute(isAuto);
+            TextDirection textDirection = downcast<HTMLElement>(styledElement).directionalityIfhasDirAutoAttribute(isAuto);
             if (isAuto)
                 m_result.addMatchedProperties(textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration());
         }
@@ -421,7 +421,7 @@ void ElementRuleCollector::matchAllRules(bool matchAuthorAndUserStyles, bool inc
         }
 
         // Now check SMIL animation override style.
-        if (includeSMILProperties && styledElement.isSVGElement())
+        if (includeSMILProperties && is<SVGElement>(styledElement))
             addElementStyleProperties(downcast<SVGElement>(styledElement).animatedSMILStyleProperties(), false /* isCacheable */);
     }
 }
index 095762b..c3c1b39 100644 (file)
@@ -650,12 +650,12 @@ bool SelectorChecker::checkOne(const CheckingContextWithStatus& context) const
             break;
 #if ENABLE(CSS_SELECTORS_LEVEL4)
         case CSSSelector::PseudoClassPlaceholderShown:
-            if (isHTMLTextFormControlElement(*element)) {
+            if (is<HTMLTextFormControlElement>(*element)) {
                 if (context.resolvingMode == Mode::ResolvingStyle) {
                     if (RenderStyle* style = context.elementStyle ? context.elementStyle : element->renderStyle())
                         style->setUnique();
                 }
-                return toHTMLTextFormControlElement(*element).isPlaceholderVisible();
+                return downcast<HTMLTextFormControlElement>(*element).isPlaceholderVisible();
             }
             return false;
 #endif
index 884f694..8fcb379 100644 (file)
@@ -444,16 +444,16 @@ static inline bool parentElementPreventsSharing(const Element* parentElement)
 Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCount) const
 {
     if (visitedNodeCount >= cStyleSearchThreshold * cStyleSearchLevelThreshold)
-        return 0;
+        return nullptr;
     if (!parent || !parent->isStyledElement())
-        return 0;
+        return nullptr;
     StyledElement* styledParent = toStyledElement(parent);
     if (styledParent->inlineStyle())
-        return 0;
-    if (styledParent->isSVGElement() && downcast<SVGElement>(*styledParent).animatedSMILStyleProperties())
-        return 0;
+        return nullptr;
+    if (is<SVGElement>(styledParent) && downcast<SVGElement>(*styledParent).animatedSMILStyleProperties())
+        return nullptr;
     if (styledParent->hasID() && m_ruleSets.features().idsInRules.contains(styledParent->idForStyleResolution().impl()))
-        return 0;
+        return nullptr;
 
     RenderStyle* parentStyle = styledParent->renderStyle();
     unsigned subcount = 0;
@@ -546,7 +546,7 @@ bool StyleResolver::canShareStyleWithControl(StyledElement* element) const
 static inline bool elementHasDirectionAuto(Element* element)
 {
     // FIXME: This line is surprisingly hot, we may wish to inline hasDirectionAuto into StyleResolver.
-    return element->isHTMLElement() && toHTMLElement(element)->hasDirectionAuto();
+    return is<HTMLElement>(element) && downcast<HTMLElement>(*element).hasDirectionAuto();
 }
 
 bool StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement* sharingCandidate) const
index 424a17e..72b015d 100644 (file)
@@ -2782,29 +2782,29 @@ void SelectorCodeGenerator::generateElementIsOnlyChild(Assembler::JumpList& fail
 #if ENABLE(CSS_SELECTORS_LEVEL4)
 static bool makeContextStyleUniqueIfNecessaryAndTestIsPlaceholderShown(Element* element, const SelectorChecker::CheckingContext* checkingContext)
 {
-    if (isHTMLTextFormControlElement(*element)) {
+    if (is<HTMLTextFormControlElement>(*element)) {
         if (checkingContext->resolvingMode == SelectorChecker::Mode::ResolvingStyle)
             checkingContext->elementStyle->setUnique();
-        return toHTMLTextFormControlElement(*element).isPlaceholderVisible();
+        return downcast<HTMLTextFormControlElement>(*element).isPlaceholderVisible();
     }
     return false;
 }
 
 static bool makeElementStyleUniqueIfNecessaryAndTestIsPlaceholderShown(Element* element, const SelectorChecker::CheckingContext* checkingContext)
 {
-    if (isHTMLTextFormControlElement(*element)) {
+    if (is<HTMLTextFormControlElement>(*element)) {
         if (checkingContext->resolvingMode == SelectorChecker::Mode::ResolvingStyle) {
             if (RenderStyle* style = element->renderStyle())
                 style->setUnique();
         }
-        return toHTMLTextFormControlElement(*element).isPlaceholderVisible();
+        return downcast<HTMLTextFormControlElement>(*element).isPlaceholderVisible();
     }
     return false;
 }
 
 static bool isPlaceholderShown(Element* element)
 {
-    return isHTMLTextFormControlElement(*element) && toHTMLTextFormControlElement(*element).isPlaceholderVisible();
+    return is<HTMLTextFormControlElement>(*element) && downcast<HTMLTextFormControlElement>(*element).isPlaceholderVisible();
 }
 
 void SelectorCodeGenerator::generateElementHasPlaceholderShown(Assembler::JumpList& failureCases, const SelectorFragment& fragment)
index 9750df1..804a567 100644 (file)
@@ -103,8 +103,8 @@ static unsigned assertConnectedSubrameCountIsConsistent(ContainerNode& node)
     unsigned count = 0;
 
     if (node.isElementNode()) {
-        if (node.isFrameOwnerElement() && toHTMLFrameOwnerElement(node).contentFrame())
-            count++;
+        if (is<HTMLFrameOwnerElement>(node) && downcast<HTMLFrameOwnerElement>(node).contentFrame())
+            ++count;
 
         if (ShadowRoot* root = toElement(node).shadowRoot())
             count += assertConnectedSubrameCountIsConsistent(*root);
@@ -138,8 +138,8 @@ static void collectFrameOwners(Vector<Ref<HTMLFrameOwnerElement>>& frameOwners,
             continue;
         }
 
-        if (element.isHTMLElement() && element.isFrameOwnerElement())
-            frameOwners.append(toHTMLFrameOwnerElement(element));
+        if (is<HTMLFrameOwnerElement>(element))
+            frameOwners.append(downcast<HTMLFrameOwnerElement>(element));
 
         if (ShadowRoot* shadowRoot = element.shadowRoot())
             collectFrameOwners(frameOwners, *shadowRoot);
@@ -157,8 +157,8 @@ void disconnectSubframes(ContainerNode& root, SubframeDisconnectPolicy policy)
     Vector<Ref<HTMLFrameOwnerElement>> frameOwners;
 
     if (policy == RootAndDescendants) {
-        if (root.isHTMLElement() && root.isFrameOwnerElement())
-            frameOwners.append(toHTMLFrameOwnerElement(root));
+        if (is<HTMLFrameOwnerElement>(root))
+            frameOwners.append(downcast<HTMLFrameOwnerElement>(root));
     }
 
     collectFrameOwners(frameOwners, root);
index 070d0e7..f509329 100644 (file)
@@ -1036,8 +1036,8 @@ PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionCode& ec)
             ec = HIERARCHY_REQUEST_ERR;
             return nullptr;
         }
-        if (source->isFrameOwnerElement()) {
-            HTMLFrameOwnerElement& frameOwnerElement = toHTMLFrameOwnerElement(*source);
+        if (is<HTMLFrameOwnerElement>(*source)) {
+            HTMLFrameOwnerElement& frameOwnerElement = downcast<HTMLFrameOwnerElement>(*source);
             if (frame() && frame()->tree().isDescendantOf(frameOwnerElement.contentFrame())) {
                 ec = HIERARCHY_REQUEST_ERR;
                 return nullptr;
@@ -2345,7 +2345,7 @@ void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionCode& ec)
         if (ec)
             return;
         
-        newBody = toHTMLElement(node.get());
+        newBody = downcast<HTMLElement>(node.get());
     }
 
     HTMLElement* b = body();
@@ -4650,7 +4650,7 @@ const Vector<IconURL>& Document::iconURLs(int iconTypesMask)
     unsigned int length = children->length();
     for (unsigned int i = 0; i < length; ++i) {
         Node* child = children->item(i);
-        if (!child->hasTagName(linkTag))
+        if (!is<HTMLLinkElement>(child))
             continue;
         HTMLLinkElement& linkElement = downcast<HTMLLinkElement>(*child);
         if (!(linkElement.iconType() & iconTypesMask))
@@ -5540,8 +5540,8 @@ void Document::dispatchFullScreenChangeOrErrorEvent(Deque<RefPtr<Node>>& queue,
             queue.append(documentElement());
 
 #if ENABLE(VIDEO)
-        if (shouldNotifyMediaElement && isHTMLMediaElement(*node))
-            toHTMLMediaElement(*node).enteredOrExitedFullscreen();
+        if (shouldNotifyMediaElement && is<HTMLMediaElement>(*node))
+            downcast<HTMLMediaElement>(*node).enteredOrExitedFullscreen();
 #endif
         node->dispatchEvent(Event::create(eventName, true, false));
     }
@@ -6073,8 +6073,8 @@ void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
                 elementsToRemoveFromChain.append(element);
         }
         // Unset hovered nodes in sub frame documents if the old hovered node was a frame owner.
-        if (oldHoveredElement && oldHoveredElement->isFrameOwnerElement()) {
-            if (Document* contentDocument = toHTMLFrameOwnerElement(*oldHoveredElement).contentDocument())
+        if (oldHoveredElement && is<HTMLFrameOwnerElement>(*oldHoveredElement)) {
+            if (Document* contentDocument = downcast<HTMLFrameOwnerElement>(*oldHoveredElement).contentDocument())
                 contentDocument->updateHoverActiveState(request, nullptr);
         }
     }
index 83a4303..0c1e91b 100644 (file)
@@ -280,7 +280,7 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS
                 return;
             }
 #endif
-        } else if ((node->isHTMLElement() && (toHTMLElement(*node).hasTagName(linkTag) || toHTMLElement(*node).hasTagName(styleTag))) || (node->isSVGElement() && downcast<SVGElement>(*node).hasTagName(SVGNames::styleTag))) {
+        } else if (is<HTMLLinkElement>(*node) || is<HTMLStyleElement>(*node) || is<SVGStyleElement>(*node)) {
             Element& element = toElement(*node);
             AtomicString title = element.fastGetAttribute(titleAttr);
             bool enabledViaScript = false;
index 1dc2c92..8715766 100644 (file)
@@ -1123,7 +1123,7 @@ PassRefPtr<DocumentFragment> Range::createContextualFragment(const String& marku
         return 0;
     }
 
-    RefPtr<DocumentFragment> fragment = WebCore::createContextualFragment(markup, toHTMLElement(element), AllowScriptingContentAndDoNotMarkAlreadyStarted, ec);
+    RefPtr<DocumentFragment> fragment = WebCore::createContextualFragment(markup, downcast<HTMLElement>(element), AllowScriptingContentAndDoNotMarkAlreadyStarted, ec);
     if (!fragment)
         return 0;
 
index ff5f166..d082601 100755 (executable)
@@ -645,7 +645,7 @@ END
        if ($parameters{namespace} eq "HTML" && $parsedTags{$name}{wrapperOnlyIfMediaIsAvailable}) {
            print F <<END
     static bool checkTagName(const HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasTagName($parameters{namespace}Names::${name}Tag); }
-    static bool checkTagName(const Node& node) { return node.isHTMLElement() && checkTagName(toHTMLElement(node)); }
+    static bool checkTagName(const Node& node) { return is<HTMLElement>(node) && checkTagName(downcast<HTMLElement>(node)); }
 END
            ;
        } else {
index 55377c6..e90249c 100644 (file)
@@ -36,6 +36,7 @@
 #include "HTMLFontElement.h"
 #include "HTMLInterchange.h"
 #include "HTMLNames.h"
+#include "HTMLSpanElement.h"
 #include "NodeList.h"
 #include "NodeTraversal.h"
 #include "RenderObject.h"
@@ -67,11 +68,10 @@ static String& styleSpanClassString()
 
 bool isLegacyAppleStyleSpan(const Node* node)
 {
-    if (!node || !node->isHTMLElement())
+    if (!node || !is<HTMLSpanElement>(node))
         return false;
 
-    const HTMLElement& element = toHTMLElement(*node);
-    return element.hasTagName(spanTag) && element.fastGetAttribute(classAttr) == styleSpanClassString();
+    return downcast<HTMLSpanElement>(*node).fastGetAttribute(classAttr) == styleSpanClassString();
 }
 
 static bool hasNoAttributeOrOnlyStyleAttribute(const StyledElement* element, ShouldStyleAttributeBeEmpty shouldStyleAttributeBeEmpty)
@@ -92,24 +92,24 @@ static bool hasNoAttributeOrOnlyStyleAttribute(const StyledElement* element, Sho
 
 bool isStyleSpanOrSpanWithOnlyStyleAttribute(const Element* element)
 {
-    if (!element || !element->hasTagName(spanTag))
+    if (!element || !is<HTMLSpanElement>(element))
         return false;
-    return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(element), AllowNonEmptyStyleAttribute);
+    return hasNoAttributeOrOnlyStyleAttribute(downcast<HTMLSpanElement>(element), AllowNonEmptyStyleAttribute);
 }
 
 static inline bool isSpanWithoutAttributesOrUnstyledStyleSpan(const Element* element)
 {
-    if (!element || !element->isHTMLElement() || !element->hasTagName(spanTag))
+    if (!element || !is<HTMLSpanElement>(element))
         return false;
-    return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(element), StyleAttributeShouldBeEmpty);
+    return hasNoAttributeOrOnlyStyleAttribute(downcast<HTMLSpanElement>(element), StyleAttributeShouldBeEmpty);
 }
 
 bool isEmptyFontTag(const Element* element, ShouldStyleAttributeBeEmpty shouldStyleAttributeBeEmpty)
 {
-    if (!element || !element->hasTagName(fontTag))
+    if (!element || !is<HTMLFontElement>(element))
         return false;
 
-    return hasNoAttributeOrOnlyStyleAttribute(toHTMLElement(element), shouldStyleAttributeBeEmpty);
+    return hasNoAttributeOrOnlyStyleAttribute(downcast<HTMLFontElement>(element), shouldStyleAttributeBeEmpty);
 }
 
 static PassRefPtr<Element> createFontElement(Document& document)
@@ -276,11 +276,11 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style)
                 if (newBlock)
                     block = newBlock;
             }
-            ASSERT(!block || block->isHTMLElement());
-            if (block && block->isHTMLElement()) {
-                removeCSSStyle(style, toHTMLElement(block.get()));
+            ASSERT(!block || is<HTMLElement>(*block));
+            if (block && is<HTMLElement>(*block)) {
+                removeCSSStyle(style, downcast<HTMLElement>(block.get()));
                 if (!m_removeOnly)
-                    addBlockStyle(styleChange, toHTMLElement(block.get()));
+                    addBlockStyle(styleChange, downcast<HTMLElement>(block.get()));
             }
 
             if (nextParagraphStart.isOrphan())
@@ -377,11 +377,11 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style)
     Node* lastStyledNode = 0;
     for (Node* node = startNode; node != beyondEnd; node = NodeTraversal::next(node)) {
         RefPtr<HTMLElement> element;
-        if (node->isHTMLElement()) {
+        if (is<HTMLElement>(node)) {
             // Only work on fully selected nodes.
             if (!nodeFullySelected(node, start, end))
                 continue;
-            element = toHTMLElement(node);
+            element = downcast<HTMLElement>(node);
         } else if (node->isTextNode() && node->renderer() && node->parentNode() != lastStyledNode) {
             // Last styled node was not parent node of this text node, but we wish to style this
             // text node. To make this possible, add a style span to surround this text node.
@@ -473,13 +473,13 @@ HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool b
     WritingDirection highestAncestorDirection;
     if (allowedDirection != NaturalWritingDirection
         && highestAncestorUnicodeBidi != CSSValueBidiOverride
-        && highestAncestorWithUnicodeBidi->isHTMLElement()
+        && is<HTMLElement>(highestAncestorWithUnicodeBidi)
         && EditingStyle::create(highestAncestorWithUnicodeBidi, EditingStyle::AllProperties)->textDirection(highestAncestorDirection)
         && highestAncestorDirection == allowedDirection) {
         if (!nextHighestAncestorWithUnicodeBidi)
-            return toHTMLElement(highestAncestorWithUnicodeBidi);
+            return downcast<HTMLElement>(highestAncestorWithUnicodeBidi);
 
-        unsplitAncestor = toHTMLElement(highestAncestorWithUnicodeBidi);
+        unsplitAncestor = downcast<HTMLElement>(highestAncestorWithUnicodeBidi);
         highestAncestorWithUnicodeBidi = nextHighestAncestorWithUnicodeBidi;
     }
 
@@ -758,18 +758,18 @@ void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle* style, PassRef
         if (!node->renderer() || !node->hasEditableStyle())
             continue;
         
-        if (!node->hasRichlyEditableStyle() && node->isHTMLElement()) {
+        if (!node->hasRichlyEditableStyle() && is<HTMLElement>(*node)) {
             // This is a plaintext-only region. Only proceed if it's fully selected.
             // pastEndNode is the node after the last fully selected node, so if it's inside node then
             // node isn't fully selected.
             if (pastEndNode && pastEndNode->isDescendantOf(node.get()))
                 break;
             // Add to this element's inline style and skip over its contents.
-            HTMLElement* element = toHTMLElement(node.get());
-            RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle());
+            HTMLElement& element = downcast<HTMLElement>(*node);
+            RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element.inlineStyle());
             if (MutableStyleProperties* otherStyle = style->style())
                 inlineStyle->mergeAndOverrideOnConflict(*otherStyle);
-            setNodeAttribute(element, styleAttr, inlineStyle->asText());
+            setNodeAttribute(&element, styleAttr, inlineStyle->asText());
             next = NodeTraversal::nextSkippingChildren(node.get());
             continue;
         }
@@ -856,13 +856,14 @@ void ApplyStyleCommand::removeConflictingInlineStyleFromRun(EditingStyle* style,
             next = NodeTraversal::nextSkippingChildren(node.get());
         } else
             next = NodeTraversal::next(node.get());
-        if (!node->isHTMLElement())
+
+        if (!is<HTMLElement>(*node))
             continue;
 
         RefPtr<Node> previousSibling = node->previousSibling();
         RefPtr<Node> nextSibling = node->nextSibling();
         RefPtr<ContainerNode> parent = node->parentNode();
-        removeInlineStyleFromElement(style, toHTMLElement(node.get()), RemoveAlways);
+        removeInlineStyleFromElement(style, downcast<HTMLElement>(node.get()), RemoveAlways);
         if (!node->inDocument()) {
             // FIXME: We might need to update the start and the end of current selection here but need a test.
             if (runStart == node)
@@ -973,17 +974,17 @@ bool ApplyStyleCommand::removeCSSStyle(EditingStyle* style, HTMLElement* element
 HTMLElement* ApplyStyleCommand::highestAncestorWithConflictingInlineStyle(EditingStyle* style, Node* node)
 {
     if (!node)
-        return 0;
+        return nullptr;
 
-    HTMLElement* result = 0;
+    HTMLElement* result = nullptr;
     Node* unsplittableElement = unsplittableElementForPosition(firstPositionInOrBeforeNode(node));
 
-    for (Node *n = node; n; n = n->parentNode()) {
-        if (n->isHTMLElement() && shouldRemoveInlineStyleFromElement(style, toHTMLElement(n)))
-            result = toHTMLElement(n);
+    for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
+        if (is<HTMLElement>(ancestor) && shouldRemoveInlineStyleFromElement(style, downcast<HTMLElement>(ancestor)))
+            result = downcast<HTMLElement>(ancestor);
         // Should stop at the editable root (cannot cross editing boundary) and
         // also stop at the unsplittable element to be consistent with other UAs
-        if (n == unsplittableElement)
+        if (ancestor == unsplittableElement)
             break;
     }
 
@@ -996,19 +997,19 @@ void ApplyStyleCommand::applyInlineStyleToPushDown(Node* node, EditingStyle* sty
 
     node->document().updateStyleIfNeeded();
 
-    if (!style || style->isEmpty() || !node->renderer() || node->hasTagName(iframeTag))
+    if (!style || style->isEmpty() || !node->renderer() || is<HTMLIFrameElement>(node))
         return;
 
     RefPtr<EditingStyle> newInlineStyle = style;
-    if (node->isHTMLElement() && toHTMLElement(node)->inlineStyle()) {
+    if (is<HTMLElement>(node) && downcast<HTMLElement>(node)->inlineStyle()) {
         newInlineStyle = style->copy();
-        newInlineStyle->mergeInlineStyleOfElement(toHTMLElement(node), EditingStyle::OverrideValues);
+        newInlineStyle->mergeInlineStyleOfElement(downcast<HTMLElement>(node), EditingStyle::OverrideValues);
     }
 
     // Since addInlineStyleIfNeeded can't add styles to block-flow render objects, add style attribute instead.
     // FIXME: applyInlineStyleToRange should be used here instead.
-    if ((node->renderer()->isRenderBlockFlow() || node->hasChildNodes()) && node->isHTMLElement()) {
-        setNodeAttribute(toHTMLElement(node), styleAttr, newInlineStyle->style()->asText());
+    if ((node->renderer()->isRenderBlockFlow() || node->hasChildNodes()) && is<HTMLElement>(node)) {
+        setNodeAttribute(downcast<HTMLElement>(node), styleAttr, newInlineStyle->style()->asText());
         return;
     }
 
@@ -1045,8 +1046,8 @@ void ApplyStyleCommand::pushDownInlineStyleAroundNode(EditingStyle* style, Node*
         }
 
         RefPtr<EditingStyle> styleToPushDown = EditingStyle::create();
-        if (current->isHTMLElement())
-            removeInlineStyleFromElement(style, toHTMLElement(current.get()), RemoveIfNeeded, styleToPushDown.get());
+        if (is<HTMLElement>(*current))
+            removeInlineStyleFromElement(style, downcast<HTMLElement>(current.get()), RemoveIfNeeded, styleToPushDown.get());
 
         // The inner loop will go through children on each level
         // FIXME: we should aggregate inline child elements together so that we don't wrap each child separately.
@@ -1119,8 +1120,8 @@ void ApplyStyleCommand::removeInlineStyle(EditingStyle* style, const Position &s
         } else
             next = NodeTraversal::next(node.get());
 
-        if (node->isHTMLElement() && nodeFullySelected(node.get(), start, end)) {
-            RefPtr<HTMLElement> elem = toHTMLElement(node.get());
+        if (is<HTMLElement>(*node) && nodeFullySelected(node.get(), start, end)) {
+            RefPtr<HTMLElement> elem = downcast<HTMLElement>(node.get());
             RefPtr<Node> prev = NodeTraversal::previousPostOrder(elem.get());
             RefPtr<Node> next = NodeTraversal::next(elem.get());
             RefPtr<EditingStyle> styleToPushDown;
@@ -1248,10 +1249,10 @@ void ApplyStyleCommand::splitTextElementAtEnd(const Position& start, const Posit
 
 bool ApplyStyleCommand::shouldSplitTextElement(Element* element, EditingStyle* style)
 {
-    if (!element || !element->isHTMLElement())
+    if (!element || !is<HTMLElement>(element))
         return false;
 
-    return shouldRemoveInlineStyleFromElement(style, toHTMLElement(element));
+    return shouldRemoveInlineStyleFromElement(style, downcast<HTMLElement>(element));
 }
 
 bool ApplyStyleCommand::isValidCaretPositionInTextNode(const Position& position)
@@ -1427,14 +1428,14 @@ void ApplyStyleCommand::applyInlineStyleChange(PassRefPtr<Node> passedStart, Pas
     ASSERT(endNode->inDocument());
 
     // Find appropriate font and span elements top-down.
-    HTMLElement* fontContainer = 0;
-    HTMLElement* styleContainer = 0;
+    HTMLFontElement* fontContainer = nullptr;
+    HTMLElement* styleContainer = nullptr;
     for (Node* container = startNode.get(); container && startNode == endNode; container = container->firstChild()) {
-        if (container->isHTMLElement() && container->hasTagName(fontTag))
-            fontContainer = toHTMLElement(container);
-        bool styleContainerIsNotSpan = !styleContainer || !styleContainer->hasTagName(spanTag);
-        if (container->isHTMLElement() && (container->hasTagName(spanTag) || (styleContainerIsNotSpan && container->hasChildNodes())))
-            styleContainer = toHTMLElement(container);
+        if (is<HTMLFontElement>(container))
+            fontContainer = downcast<HTMLFontElement>(container);
+        bool styleContainerIsNotSpan = !styleContainer || !is<HTMLSpanElement>(styleContainer);
+        if (is<HTMLElement>(container) && (is<HTMLSpanElement>(container) || (styleContainerIsNotSpan && container->hasChildNodes())))
+            styleContainer = downcast<HTMLElement>(container);
         if (!container->firstChild())
             break;
         startNode = container->firstChild();
index fdcc0b0..90a1efe 100644 (file)
@@ -156,7 +156,7 @@ static HTMLElement* enclosingDeletableElement(const VisibleSelection& selection)
         return nullptr;
 
     Node* element = enclosingNodeOfType(firstPositionInNode(container), &isDeletableElement);
-    return element && element->isHTMLElement() ? toHTMLElement(element) : nullptr;
+    return element && is<HTMLElement>(element) ? downcast<HTMLElement>(element) : nullptr;
 }
 
 void DeleteButtonController::respondToChangedSelection(const VisibleSelection& oldSelection)
index e5b5b72..11b71ef 100644 (file)
@@ -209,7 +209,7 @@ VisibleSelection Editor::selectionForCommand(Event* event)
     // If the target is a text control, and the current selection is outside of its shadow tree,
     // then use the saved selection for that text control.
     HTMLTextFormControlElement* textFormControlOfSelectionStart = enclosingTextFormControl(selection.start());
-    HTMLTextFormControlElement* textFromControlOfTarget = isHTMLTextFormControlElement(*event->target()->toNode()) ? toHTMLTextFormControlElement(event->target()->toNode()) : nullptr;
+    HTMLTextFormControlElement* textFromControlOfTarget = is<HTMLTextFormControlElement>(*event->target()->toNode()) ? downcast<HTMLTextFormControlElement>(event->target()->toNode()) : nullptr;
     if (textFromControlOfTarget && (selection.start().isNull() || textFromControlOfTarget != textFormControlOfSelectionStart)) {
         if (RefPtr<Range> range = textFromControlOfTarget->selection())
             return VisibleSelection(range.get(), DOWNSTREAM, selection.isDirectional());
@@ -1660,10 +1660,10 @@ void Editor::setBaseWritingDirection(WritingDirection direction)
 #endif
         
     Element* focusedElement = document().focusedElement();
-    if (focusedElement && isHTMLTextFormControlElement(*focusedElement)) {
+    if (focusedElement && is<HTMLTextFormControlElement>(*focusedElement)) {
         if (direction == NaturalWritingDirection)
             return;
-        toHTMLElement(focusedElement)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
+        downcast<HTMLTextFormControlElement>(*focusedElement).setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
         focusedElement->dispatchInputEvent();
         document().updateStyleIfNeeded();
         return;
@@ -3536,8 +3536,8 @@ static Node* findFirstMarkable(Node* node)
             return nullptr;
         if (node->renderer()->isTextOrLineBreak())
             return node;
-        if (isHTMLTextFormControlElement(*node))
-            node = toHTMLTextFormControlElement(*node).visiblePositionForIndex(1).deepEquivalent().deprecatedNode();
+        if (is<HTMLTextFormControlElement>(*node))
+            node = downcast<HTMLTextFormControlElement>(*node).visiblePositionForIndex(1).deepEquivalent().deprecatedNode();
         else if (node->firstChild())
             node = node->firstChild();
         else
index 690b691..c17f6b9 100644 (file)
@@ -1686,8 +1686,8 @@ void FrameSelection::selectAll()
             selectStartTarget = root.get();
     } else {
         if (m_selection.isNone() && focusedElement) {
-            if (focusedElement->isTextFormControl()) {
-                toHTMLTextFormControlElement(*focusedElement).select();
+            if (is<HTMLTextFormControlElement>(focusedElement)) {
+                downcast<HTMLTextFormControlElement>(*focusedElement).select();
                 return;
             }
             root = focusedElement->nonBoundaryShadowTreeRootNode();
@@ -2025,8 +2025,8 @@ static HTMLFormElement* scanForForm(Element* start)
             return downcast<HTMLFormElement>(&element);
         if (is<HTMLFormControlElement>(element))
             return downcast<HTMLFormControlElement>(element).form();
-        if (isHTMLFrameElementBase(element)) {
-            Document* contentDocument = toHTMLFrameElementBase(element).contentDocument();
+        if (is<HTMLFrameElementBase>(element)) {
+            Document* contentDocument = downcast<HTMLFrameElementBase>(element).contentDocument();
             if (!contentDocument)
                 continue;
             if (HTMLFormElement* frameResult = scanForForm(contentDocument->documentElement()))
index 44050c0..116e21d 100644 (file)
@@ -72,12 +72,12 @@ PassRefPtr<HTMLElement> InsertListCommand::mergeWithNeighboringLists(PassRefPtr<
         mergeIdenticalElements(previousList, list);
 
     if (!list)
-        return 0;
+        return nullptr;
     Element* sibling = ElementTraversal::nextSibling(list.get());
-    if (!sibling || !sibling->isHTMLElement())
+    if (!sibling || !is<HTMLElement>(sibling))
         return list.release();
 
-    RefPtr<HTMLElement> nextList = toHTMLElement(sibling);
+    RefPtr<HTMLElement> nextList = downcast<HTMLElement>(sibling);
     if (canMergeLists(list.get(), nextList.get())) {
         mergeIdenticalElements(list, nextList);
         return nextList.release();
index 18e5894..b7f9a72 100644 (file)
@@ -603,14 +603,14 @@ bool MarkupAccumulator::shouldSelfClose(const Element& element)
 
 bool MarkupAccumulator::elementCannotHaveEndTag(const Node& node)
 {
-    if (!node.isHTMLElement())
+    if (!is<HTMLElement>(node))
         return false;
 
     // FIXME: ieForbidsInsertHTML may not be the right function to call here
     // ieForbidsInsertHTML is used to disallow setting innerHTML/outerHTML
     // or createContextualFragment.  It does not necessarily align with
     // which elements should be serialized w/o end tags.
-    return toHTMLElement(node).ieForbidsInsertHTML();
+    return downcast<HTMLElement>(node).ieForbidsInsertHTML();
 }
 
 void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Element& element)
index 816ea0a..07f1c50 100644 (file)
@@ -488,16 +488,16 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
         const StyleProperties* inlineStyle = element->inlineStyle();
         RefPtr<EditingStyle> newInlineStyle = EditingStyle::create(inlineStyle);
         if (inlineStyle) {
-            if (element->isHTMLElement()) {
+            if (is<HTMLElement>(element)) {
                 Vector<QualifiedName> attributes;
-                HTMLElement* htmlElement = toHTMLElement(element);
+                HTMLElement& htmlElement = downcast<HTMLElement>(*element);
 
-                if (newInlineStyle->conflictsWithImplicitStyleOfElement(htmlElement)) {
+                if (newInlineStyle->conflictsWithImplicitStyleOfElement(&htmlElement)) {
                     // e.g. <b style="font-weight: normal;"> is converted to <span style="font-weight: normal;">
-                    node = replaceElementWithSpanPreservingChildrenAndAttributes(htmlElement);
+                    node = replaceElementWithSpanPreservingChildrenAndAttributes(&htmlElement);
                     element = toStyledElement(node.get());
-                    insertedNodes.didReplaceNode(htmlElement, node.get());
-                } else if (newInlineStyle->extractConflictingImplicitStyleOfAttributes(htmlElement, EditingStyle::PreserveWritingDirection, 0, attributes,
+                    insertedNodes.didReplaceNode(&htmlElement, node.get());
+                } else if (newInlineStyle->extractConflictingImplicitStyleOfAttributes(&htmlElement, EditingStyle::PreserveWritingDirection, 0, attributes,
                     EditingStyle::DoNotExtractMatchingStyle)) {
                     // e.g. <font size="3" style="font-size: 20px;"> is converted to <font style="font-size: 20px;">
                     for (size_t i = 0; i < attributes.size(); i++)
@@ -626,10 +626,10 @@ void ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuild
     for (RefPtr<Node> node = insertedNodes.firstNodeInserted(); node && node != pastEndNode; node = next) {
         next = NodeTraversal::next(node.get());
 
-        if (!node->isHTMLElement())
+        if (!is<HTMLElement>(*node))
             continue;
 
-        if (isProhibitedParagraphChild(toHTMLElement(node.get())->localName())) {
+        if (isProhibitedParagraphChild(downcast<HTMLElement>(*node).localName())) {
             if (auto* paragraphElement = enclosingElementWithTag(positionInParentBeforeNode(node.get()), pTag)) {
                 auto* parent = paragraphElement->parentNode();
                 if (parent && parent->hasEditableStyle())
@@ -643,7 +643,7 @@ void ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuild
                 if (headerElement->parentNode() && headerElement->parentNode()->isContentRichlyEditable())
                     moveNodeOutOfAncestor(node, headerElement);
                 else {
-                    HTMLElement* newSpanElement = replaceElementWithSpanPreservingChildrenAndAttributes(toHTMLElement(node.get()));
+                    HTMLElement* newSpanElement = replaceElementWithSpanPreservingChildrenAndAttributes(downcast<HTMLElement>(node.get()));
                     insertedNodes.didReplaceNode(node.get(), newSpanElement);
                 }
             }
@@ -778,7 +778,7 @@ void ReplaceSelectionCommand::handleStyleSpans(InsertedNodes& insertedNodes)
     // so search for the top level style span instead of assuming it's at the top.
     for (Node* node = insertedNodes.firstNodeInserted(); node; node = NodeTraversal::next(node)) {
         if (isLegacyAppleStyleSpan(node)) {
-            wrappingStyleSpan = toHTMLElement(node);
+            wrappingStyleSpan = downcast<HTMLElement>(node);
             break;
         }
     }
@@ -1099,7 +1099,7 @@ void ReplaceSelectionCommand::doApply()
     Node* blockStart = enclosingBlock(insertionPos.deprecatedNode());
     if ((isListElement(refNode.get()) || (isLegacyAppleStyleSpan(refNode.get()) && isListElement(refNode->firstChild())))
         && blockStart && blockStart->renderer()->isListItem())
-        refNode = insertAsListItems(toHTMLElement(refNode.get()), blockStart, insertionPos, insertedNodes);
+        refNode = insertAsListItems(downcast<HTMLElement>(refNode.get()), blockStart, insertionPos, insertedNodes);
     else {
         insertNodeAt(refNode, insertionPos);
         insertedNodes.respondToNodeInsertion(refNode.get());
@@ -1438,7 +1438,7 @@ Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtr<HTMLElement> prpList
     RefPtr<HTMLElement> listElement = prpListElement;
 
     while (listElement->hasOneChild() && isListElement(listElement->firstChild()))
-        listElement = toHTMLElement(listElement->firstChild());
+        listElement = downcast<HTMLElement>(listElement->firstChild());
 
     bool isStart = isStartOfParagraph(insertPos);
     bool isEnd = isEndOfParagraph(insertPos);
index 11177ae..9163b0a 100644 (file)
@@ -33,6 +33,7 @@
 #include "Frame.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
+#include "HTMLParagraphElement.h"
 #include "HTMLTextFormControlElement.h"
 #include "InlineTextBox.h"
 #include "NodeTraversal.h"
@@ -813,9 +814,9 @@ static bool shouldEmitNewlinesBeforeAndAfterNode(Node& node)
     // a newline both before and after the element.
     auto* renderer = node.renderer();
     if (!renderer) {
-        if (!node.isHTMLElement())
+        if (!is<HTMLElement>(node))
             return false;
-        auto& element = toHTMLElement(node);
+        auto& element = downcast<HTMLElement>(node);
         return hasHeaderTag(element)
             || element.hasTagName(blockquoteTag)
             || element.hasTagName(ddTag)
@@ -884,9 +885,11 @@ static bool shouldEmitExtraNewlineForNode(Node& node)
         return false;
 
     // NOTE: We only do this for a select set of nodes, and WinIE appears not to do this at all.
-    if (!node.isHTMLElement())
+    if (!is<HTMLElement>(node))
         return false;
-    if (!(hasHeaderTag(toHTMLElement(node)) || toHTMLElement(node).hasTagName(pTag)))
+
+    HTMLElement& element = downcast<HTMLElement>(node);
+    if (!hasHeaderTag(element) && !is<HTMLParagraphElement>(element))
         return false;
 
     int bottomMargin = toRenderBox(renderer)->collapsedMarginAfter();
index 079db94..bd57d93 100644 (file)
@@ -1889,8 +1889,8 @@ void HTMLConverter::_addTableCellForElement(Element* element)
     RetainPtr<NSTextTableBlock> block;
     
     if (element) {
-        if (isHTMLTableCellElement(*element)) {
-            HTMLTableCellElement& tableCellElement = toHTMLTableCellElement(*element);
+        if (is<HTMLTableCellElement>(*element)) {
+            HTMLTableCellElement& tableCellElement = downcast<HTMLTableCellElement>(*element);
             
             rowSpan = tableCellElement.rowSpan();
             if (rowSpan < 1)
@@ -2002,8 +2002,8 @@ BOOL HTMLConverter::_processElement(Element& element, NSInteger depth)
             if (url)
                 retval = !_addAttachmentForElement(element, url, isBlockLevel, NO);
         }
-    } else if (element.hasTagName(frameTag) || element.hasTagName(iframeTag)) {
-        if (Document* contentDocument = toHTMLFrameElementBase(element).contentDocument()) {
+    } else if (is<HTMLFrameElementBase>(element)) {
+        if (Document* contentDocument = downcast<HTMLFrameElementBase>(element).contentDocument()) {
             _traverseNode(*contentDocument, depth + 1, true /* embedded */);
             retval = NO;
         }
index 5e8f595..244da80 100644 (file)
@@ -647,24 +647,24 @@ Element* enclosingAnchorElement(const Position& p)
 HTMLElement* enclosingList(Node* node)
 {
     if (!node)
-        return 0;
+        return nullptr;
         
     Node* root = highestEditableRoot(firstPositionInOrBeforeNode(node));
     
-    for (ContainerNode* n = node->parentNode(); n; n = n->parentNode()) {
-        if (n->hasTagName(ulTag) || n->hasTagName(olTag))
-            return toHTMLElement(n);
-        if (n == root)
-            return 0;
+    for (ContainerNode* ancestor = node->parentNode(); ancestor; ancestor = ancestor->parentNode()) {
+        if (is<HTMLUListElement>(ancestor) || is<HTMLOListElement>(ancestor))
+            return downcast<HTMLElement>(ancestor);
+        if (ancestor == root)
+            return nullptr;
     }
     
-    return 0;
+    return nullptr;
 }
 
 Node* enclosingListChild(Node *node)
 {
     if (!node)
-        return 0;
+        return nullptr;
     // Check for a list item element, or for a node whose parent is a list element. Such a node
     // will appear visually as a list item (but without a list marker)
     Node* root = highestEditableRoot(firstPositionInOrBeforeNode(node));
@@ -674,10 +674,10 @@ Node* enclosingListChild(Node *node)
         if (n->hasTagName(liTag) || (isListElement(n->parentNode()) && n != root))
             return n;
         if (n == root || isTableCell(n))
-            return 0;
+            return nullptr;
     }
     
-    return 0;
+    return nullptr;
 }
 
 static HTMLElement* embeddedSublist(Node* listItem)
@@ -685,10 +685,10 @@ static HTMLElement* embeddedSublist(Node* listItem)
     // Check the DOM so that we'll find collapsed sublists without renderers.
     for (Node* n = listItem->firstChild(); n; n = n->nextSibling()) {
         if (isListElement(n))
-            return toHTMLElement(n);
+            return downcast<HTMLElement>(n);
     }
     
-    return 0;
+    return nullptr;
 }
 
 static Node* appendedSublist(Node* listItem)
@@ -696,12 +696,12 @@ static Node* appendedSublist(Node* listItem)
     // Check the DOM so that we'll find collapsed sublists without renderers.
     for (Node* n = listItem->nextSibling(); n; n = n->nextSibling()) {
         if (isListElement(n))
-            return toHTMLElement(n);
+            return downcast<HTMLElement>(n);
         if (isListItem(listItem))
-            return 0;
+            return nullptr;
     }
     
-    return 0;
+    return nullptr;
 }
 
 // FIXME: This method should not need to call isStartOfParagraph/isEndOfParagraph
index 3192822..d9233a2 100644 (file)
@@ -186,7 +186,7 @@ void Editor::setTextAlignmentForChangedBaseWritingDirection(WritingDirection dir
             || downcast<HTMLInputElement>(*focusedElement).isSearchField())))) {
         if (direction == NaturalWritingDirection)
             return;
-        toHTMLElement(*focusedElement).setAttribute(alignAttr, newValue);
+        downcast<HTMLElement>(*focusedElement).setAttribute(alignAttr, newValue);
         m_frame.document()->updateStyleIfNeeded();
         return;
     }
index f652162..6458bb7 100644 (file)
@@ -250,8 +250,8 @@ static void maybeCopyNodeAttributesToFragment(const Node& node, DocumentFragment
         return;
 
     // And only if the source Element and destination Element have the same HTML tag name.
-    const HTMLElement& oldElement = toHTMLElement(node);
-    HTMLElement& newElement = toHTMLElement(*firstChild);
+    const HTMLElement& oldElement = downcast<HTMLElement>(node);
+    HTMLElement& newElement = downcast<HTMLElement>(*firstChild);
     if (oldElement.localName() != newElement.localName())
         return;
 
index 09f4687..097e32b 100644 (file)
@@ -327,7 +327,7 @@ void StyledMarkupAccumulator::appendElement(StringBuilder& out, const Element& e
 
         if (shouldAnnotateOrForceInline) {
             if (shouldAnnotate())
-                newInlineStyle->mergeStyleFromRulesForSerialization(toHTMLElement(const_cast<Element*>(&element)));
+                newInlineStyle->mergeStyleFromRulesForSerialization(downcast<HTMLElement>(const_cast<Element*>(&element)));
 
             if (addDisplayInline)
                 newInlineStyle->forceInline();
index c73d9b0..3c749a4 100644 (file)
@@ -73,14 +73,14 @@ void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree()
 void BaseChooserOnlyDateAndTimeInputType::updateAppearance()
 {
     Node* node = element().userAgentShadowRoot()->firstChild();
-    if (!node || !node->isHTMLElement())
+    if (!node || !is<HTMLElement>(node))
         return;
     String displayValue = visibleValue();
     if (displayValue.isEmpty()) {
         // Need to put something to keep text baseline.
         displayValue = ASCIILiteral(" ");
     }
-    toHTMLElement(node)->setInnerText(displayValue, ASSERT_NO_EXCEPTION);
+    downcast<HTMLElement>(*node).setInnerText(displayValue, ASSERT_NO_EXCEPTION);
 }
 
 void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
index 98e8a92..5a3437b 100644 (file)
@@ -199,7 +199,7 @@ void ColorInputType::updateColorSwatch()
 HTMLElement* ColorInputType::shadowColorSwatch() const
 {
     ShadowRoot* shadow = element().userAgentShadowRoot();
-    return shadow ? toHTMLElement(shadow->firstChild()->firstChild()) : 0;
+    return shadow ? downcast<HTMLElement>(shadow->firstChild()->firstChild()) : nullptr;
 }
 
 IntRect ColorInputType::elementRectRelativeToRootView() const
index a742f38..009329e 100644 (file)
@@ -175,8 +175,8 @@ Node::InsertionNotificationRequest HTMLBodyElement::insertedInto(ContainerNode&
     // magically appear on the <body> of all documents embedded through <iframe> or <frame>.
     // FIXME: Perhaps this code should be in attach() instead of here.
     HTMLFrameOwnerElement* ownerElement = document().ownerElement();
-    if (ownerElement && isHTMLFrameElementBase(*ownerElement)) {
-        HTMLFrameElementBase& ownerFrameElement = toHTMLFrameElementBase(*ownerElement);
+    if (ownerElement && is<HTMLFrameElementBase>(*ownerElement)) {
+        HTMLFrameElementBase& ownerFrameElement = downcast<HTMLFrameElementBase>(*ownerElement);
         int marginWidth = ownerFrameElement.marginWidth();
         if (marginWidth != -1)
             setIntegralAttribute(marginwidthAttr, marginWidth);
index e76093f..7ac8693 100644 (file)
@@ -388,23 +388,23 @@ Node* HTMLCollection::namedItem(const AtomicString& name) const
     // that are allowed a name attribute.
 
     if (name.isEmpty())
-        return 0;
+        return nullptr;
 
     ContainerNode& root = rootNode();
     if (!usesCustomForwardOnlyTraversal() && root.isInTreeScope()) {
         TreeScope& treeScope = root.treeScope();
-        Element* candidate = 0;
+        Element* candidate = nullptr;
         if (treeScope.hasElementWithId(*name.impl())) {
             if (!treeScope.containsMultipleElementsWithId(name))
                 candidate = treeScope.getElementById(name);
         } else if (treeScope.hasElementWithName(*name.impl())) {
             if (!treeScope.containsMultipleElementsWithName(name)) {
                 candidate = treeScope.getElementByName(name);
-                if (candidate && type() == DocAll && (!candidate->isHTMLElement() || !nameShouldBeVisibleInDocumentAll(toHTMLElement(*candidate))))
-                    candidate = 0;
+                if (candidate && type() == DocAll && (!is<HTMLElement>(candidate) || !nameShouldBeVisibleInDocumentAll(downcast<HTMLElement>(*candidate))))
+                    candidate = nullptr;
             }
         } else
-            return 0;
+            return nullptr;
 
         if (candidate && isMatchingElement(*this, *candidate)
             && (m_shouldOnlyIncludeDirectChildren ? candidate->parentNode() == &root : candidate->isDescendantOf(&root)))
@@ -425,7 +425,7 @@ Node* HTMLCollection::namedItem(const AtomicString& name) const
             return nameResults->at(0);
     }
 
-    return 0;
+    return nullptr;
 }
 
 void HTMLCollection::updateNamedElementCache() const
@@ -443,10 +443,10 @@ void HTMLCollection::updateNamedElementCache() const
         const AtomicString& idAttrVal = element->getIdAttribute();
         if (!idAttrVal.isEmpty())
             cache->appendIdCache(idAttrVal, element);
-        if (!element->isHTMLElement())
+        if (!is<HTMLElement>(element))
             continue;
         const AtomicString& nameAttrVal = element->getNameAttribute();
-        if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && (type() != DocAll || nameShouldBeVisibleInDocumentAll(toHTMLElement(*element))))
+        if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && (type() != DocAll || nameShouldBeVisibleInDocumentAll(downcast<HTMLElement>(*element))))
             cache->appendNameCache(nameAttrVal, element);
     }
 
index cd92ff8..3788f7a 100644 (file)
@@ -40,6 +40,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameView.h"
+#include "HTMLBDIElement.h"
 #include "HTMLBRElement.h"
 #include "HTMLCollection.h"
 #include "HTMLDocument.h"
@@ -363,8 +364,8 @@ bool HTMLElement::matchesReadWritePseudoClass() const
 {
     const Element* currentElement = this;
     do {
-        if (currentElement->isHTMLElement()) {
-            switch (contentEditableType(toHTMLElement(*currentElement))) {
+        if (is<HTMLElement>(currentElement)) {
+            switch (contentEditableType(downcast<HTMLElement>(*currentElement))) {
             case ContentEditableType::True:
             case ContentEditableType::PlaintextOnly:
                 return true;
@@ -451,11 +452,11 @@ static void mergeWithNextTextNode(Text& node, ExceptionCode& ec)
 void HTMLElement::setOuterHTML(const String& html, ExceptionCode& ec)
 {
     Element* p = parentElement();
-    if (!p || !p->isHTMLElement()) {
+    if (!p || !is<HTMLElement>(p)) {
         ec = NO_MODIFICATION_ALLOWED_ERR;
         return;
     }
-    RefPtr<HTMLElement> parent = toHTMLElement(p);
+    RefPtr<HTMLElement> parent = downcast<HTMLElement>(p);
     RefPtr<Node> prev = previousSibling();
     RefPtr<Node> next = nextSibling();
 
@@ -868,7 +869,10 @@ HTMLFormElement* HTMLElement::virtualForm() const
 
 static inline bool elementAffectsDirectionality(const Node& node)
 {
-    return node.isHTMLElement() && (toHTMLElement(node).hasTagName(bdiTag) || toHTMLElement(node).fastHasAttribute(dirAttr));
+    if (!is<HTMLElement>(node))
+        return false;
+    const HTMLElement& element = downcast<HTMLElement>(node);
+    return is<HTMLBDIElement>(element) || element.fastHasAttribute(dirAttr);
 }
 
 static void setHasDirAutoFlagRecursively(Node* firstNode, bool flag, Node* lastNode = nullptr)
@@ -919,8 +923,8 @@ TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con
 
 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const
 {
-    if (isHTMLTextFormControlElement(*this)) {
-        HTMLTextFormControlElement& textElement = toHTMLTextFormControlElement(const_cast<HTMLElement&>(*this));
+    if (is<HTMLTextFormControlElement>(*this)) {
+        HTMLTextFormControlElement& textElement = downcast<HTMLTextFormControlElement>(const_cast<HTMLElement&>(*this));
         bool hasStrongDirectionality;
         UCharDirection textDirection = textElement.value().defaultWritingDirection(&hasStrongDirectionality);
         if (strongDirectionalityTextNode)
@@ -966,8 +970,8 @@ void HTMLElement::dirAttributeChanged(const AtomicString& value)
 {
     Element* parent = parentElement();
 
-    if (parent && parent->isHTMLElement() && parent->selfOrAncestorHasDirAutoAttribute())
-        toHTMLElement(parent)->adjustDirectionalityIfNeededAfterChildAttributeChanged(this);
+    if (parent && is<HTMLElement>(parent) && parent->selfOrAncestorHasDirAutoAttribute())
+        downcast<HTMLElement>(*parent).adjustDirectionalityIfNeededAfterChildAttributeChanged(this);
 
     if (equalIgnoringCase(value, "auto"))
         calculateAndAdjustDirectionality();
index 87f2fdb..68f231b 100644 (file)
@@ -146,19 +146,13 @@ inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document
     ASSERT(tagName.localName().impl());
 }
 
-void isHTMLElement(const HTMLElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLElement(const Node& node) { return node.isHTMLElement(); }
-
-template <typename ArgType>
-struct NodeTypeCastTraits<const HTMLElement, ArgType> {
-    static bool isType(ArgType& node) { return isHTMLElement(node); }
-};
-
-NODE_TYPE_CASTS(HTMLElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLElement)
+    static bool isHTMLElement(const Node& node) { return node.isHTMLElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 inline bool Node::hasTagName(const HTMLQualifiedName& name) const
 {
-    return isHTMLElement() && toHTMLElement(*this).hasTagName(name);
+    return is<HTMLElement>(*this) && downcast<HTMLElement>(*this).hasTagName(name);
 }
 
 } // namespace WebCore
index eaff71f..b9c37e0 100644 (file)
@@ -800,7 +800,7 @@ void HTMLFormElement::getNamedElements(const AtomicString& name, Vector<Ref<Elem
 
     HTMLElement* elementFromPast = elementFromPastNamesMap(name);
     if (namedItems.size() == 1 && &namedItems.first().get() != elementFromPast)
-        addToPastNamesMap(toHTMLElement(&namedItems.first().get())->asFormNamedItem(), name);
+        addToPastNamesMap(downcast<HTMLElement>(namedItems.first().get()).asFormNamedItem(), name);
     else if (elementFromPast && namedItems.isEmpty())
         namedItems.append(*elementFromPast);
 }
index b475bd5..f38153f 100644 (file)
@@ -76,11 +76,10 @@ private:
     int m_marginHeight;
 };
 
-void isHTMLFrameElementBase(const HTMLFrameElementBase&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLFrameElementBase(const HTMLElement& element) { return is<HTMLFrameElement>(element) || is<HTMLIFrameElement>(element); }
-inline bool isHTMLFrameElementBase(const Node& node) { return is<HTMLFrameElement>(node) || is<HTMLIFrameElement>(node); }
-
-NODE_TYPE_CASTS(HTMLFrameElementBase)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLFrameElementBase)
+    static bool isHTMLFrameElementBase(const HTMLElement& element) { return is<HTMLFrameElement>(element) || is<HTMLIFrameElement>(element); }
+    static bool isHTMLFrameElementBase(const Node& node) { return is<HTMLElement>(node) && isHTMLFrameElementBase(downcast<HTMLElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 } // namespace WebCore
 
index d586d8d..06a4537 100644 (file)
@@ -69,9 +69,10 @@ private:
     SandboxFlags m_sandboxFlags;
 };
 
-void isHTMLFrameOwnerElement(const HTMLFrameOwnerElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLFrameOwnerElement(const Node& node) { return node.isFrameOwnerElement(); }
-NODE_TYPE_CASTS(HTMLFrameOwnerElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLFrameOwnerElement)
+    static bool isHTMLFrameOwnerElement(const Node& node) { return node.isFrameOwnerElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
 
 class SubframeLoadingDisabler {
 public:
index 28b9256..3dd7dbc 100644 (file)
@@ -910,16 +910,10 @@ struct ValueToString<TextTrackCue*> {
 #endif
 #endif
 
-void isHTMLMediaElement(const HTMLMediaElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLMediaElement(const Element& element) { return element.isMediaElement(); }
-inline bool isHTMLMediaElement(const Node& node) { return node.isElementNode() && toElement(node).isMediaElement(); }
-
-template <typename ArgType>
-struct NodeTypeCastTraits<const HTMLMediaElement, ArgType> {
-    static bool isType(ArgType& node) { return isHTMLMediaElement(node); }
-};
-
-NODE_TYPE_CASTS(HTMLMediaElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLMediaElement)
+    static bool isHTMLMediaElement(const Element& element) { return element.isMediaElement(); }
+    static bool isHTMLMediaElement(const Node& node) { return node.isElementNode() && isHTMLMediaElement(toElement(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 #ifndef NDEBUG
 template<>
index 3c37708..7e9c9d1 100644 (file)
@@ -312,11 +312,10 @@ bool HTMLOptionElement::isDisabledFormControl() const
     if (ownElementDisabled())
         return true;
 
-    if (!parentNode() || !parentNode()->isHTMLElement())
+    if (!parentNode() || !is<HTMLOptGroupElement>(parentNode()))
         return false;
 
-    HTMLElement& parentElement = toHTMLElement(*parentNode());
-    return is<HTMLOptGroupElement>(parentElement) && parentElement.isDisabledFormControl();
+    return downcast<HTMLOptGroupElement>(*parentNode()).isDisabledFormControl();
 }
 
 Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode& insertionPoint)
index e965017..0cadb82 100644 (file)
@@ -134,9 +134,9 @@ private:
     DisplayState m_displayState;
 };
 
-void isHTMLPlugInElement(const HTMLPlugInElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLPlugInElement(const Node& node) { return node.isPluginElement(); }
-NODE_TYPE_CASTS(HTMLPlugInElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLPlugInElement)
+    static bool isHTMLPlugInElement(const Node& node) { return node.isPluginElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 } // namespace WebCore
 
index 339b5c8..3690e9c 100644 (file)
@@ -414,15 +414,12 @@ static void addPlugInsFromNodeListMatchingPlugInOrigin(HTMLPlugInImageElementLis
 {
     for (unsigned i = 0, length = collection->length(); i < length; i++) {
         Node* node = collection->item(i);
-        if (node->isPluginElement()) {
-            HTMLPlugInElement* plugInElement = toHTMLPlugInElement(node);
-            if (plugInElement->isPlugInImageElement()) {
-                HTMLPlugInImageElement& plugInImageElement = toHTMLPlugInImageElement(*node);
-                const URL& loadedURL = plugInImageElement.loadedUrl();
-                String otherMimeType = plugInImageElement.loadedMimeType();
-                if (plugInOrigin == loadedURL.host() && mimeType == otherMimeType)
-                    plugInList.append(&plugInImageElement);
-            }
+        if (is<HTMLPlugInImageElement>(node)) {
+            HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(*node);
+            const URL& loadedURL = plugInImageElement.loadedUrl();
+            String otherMimeType = plugInImageElement.loadedMimeType();
+            if (plugInOrigin == loadedURL.host() && mimeType == otherMimeType)
+                plugInList.append(&plugInImageElement);
         }
     }
 }
index a9eee84..0786f21 100644 (file)
@@ -157,16 +157,10 @@ private:
     bool m_plugInDimensionsSpecified;
 };
 
-void isHTMLPlugInImageElement(const HTMLPlugInImageElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLPlugInImageElement(const HTMLPlugInElement& element) { return element.isPlugInImageElement(); }
-inline bool isHTMLPlugInImageElement(const Node& node) { return node.isPluginElement() && toHTMLPlugInElement(node).isPlugInImageElement(); }
-
-template <typename ArgType>
-struct NodeTypeCastTraits<const HTMLPlugInImageElement, ArgType> {
-    static bool isType(ArgType& node) { return isHTMLPlugInImageElement(node); }
-};
-
-NODE_TYPE_CASTS(HTMLPlugInImageElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLPlugInImageElement)
+    static bool isHTMLPlugInImageElement(const HTMLPlugInElement& element) { return element.isPlugInImageElement(); }
+    static bool isHTMLPlugInImageElement(const Node& node) { return is<HTMLPlugInElement>(node) && isHTMLPlugInImageElement(downcast<HTMLPlugInElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 } // namespace WebCore
 
index 5d32e38..ecc87e2 100644 (file)
@@ -449,7 +449,7 @@ void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc
         setLength(index, ec);
         // Replace an existing entry?
     } else if (diff < 0) {
-        before = toHTMLElement(options()->item(index+1));
+        before = downcast<HTMLElement>(options()->item(index + 1));
         removeByIndex(index);
     }
     // Finally add the new element.
@@ -471,7 +471,7 @@ void HTMLSelectElement::setLength(unsigned newLen, ExceptionCode& ec)
         do {
             RefPtr<Element> option = document().createElement(optionTag, false);
             ASSERT(option);
-            add(toHTMLElement(option.get()), 0, ec);
+            add(downcast<HTMLElement>(option.get()), nullptr, ec);
             if (ec)
                 break;
         } while (++diff);
@@ -785,7 +785,7 @@ void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
             currentElement = ElementTraversal::nextSkippingChildren(currentElement, this);
             continue;
         }
-        HTMLElement* current = toHTMLElement(currentElement);
+        HTMLElement* current = downcast<HTMLElement>(currentElement);
 
         // optgroup tags may not nest. However, both FireFox and IE will
         // flatten the tree automatically, so we follow suit.
index 7cd3e2d..8daf340 100644 (file)
@@ -55,8 +55,8 @@ Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
 {
     HTMLElement::insertedInto(insertionPoint);
     Element* parent = parentElement();
-    if (parent && parent->isMediaElement())
-        toHTMLMediaElement(parentNode())->sourceWasAdded(this);
+    if (parent && is<HTMLMediaElement>(parent))
+        downcast<HTMLMediaElement>(*parent).sourceWasAdded(this);
     return InsertionDone;
 }
 
@@ -65,8 +65,8 @@ void HTMLSourceElement::removedFrom(ContainerNode& removalRoot)
     Element* parent = parentElement();
     if (!parent && removalRoot.isElementNode())
         parent = &toElement(removalRoot);
-    if (parent && parent->isMediaElement())
-        toHTMLMediaElement(parent)->sourceWasRemoved(this);
+    if (parent && is<HTMLMediaElement>(parent))
+        downcast<HTMLMediaElement>(*parent).sourceWasRemoved(this);
     HTMLElement::removedFrom(removalRoot);
 }
 
index ccb74ca..1f99789 100644 (file)
@@ -174,7 +174,7 @@ HTMLTableCellElement* HTMLTableCellElement::cellAbove() const
     if (!cellAboveRenderer)
         return nullptr;
 
-    return toHTMLTableCellElement(cellAboveRenderer->element());
+    return downcast<HTMLTableCellElement>(cellAboveRenderer->element());
 }
 
 } // namespace WebCore
index 2cfdf46..036beb6 100644 (file)
@@ -62,9 +62,10 @@ private:
     virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const override;
 };
 
-void isHTMLTableCellElement(const HTMLTableCellElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLTableCellElement(const Node& node) { return node.hasTagName(HTMLNames::tdTag) || node.hasTagName(HTMLNames::thTag); }
-NODE_TYPE_CASTS(HTMLTableCellElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLTableCellElement)
+    static bool isHTMLTableCellElement(const HTMLElement& element) { return element.hasTagName(HTMLNames::tdTag) || element.hasTagName(HTMLNames::thTag); }
+    static bool isHTMLTableCellElement(const Node& node) { return is<HTMLElement>(node) && isHTMLTableCellElement(downcast<HTMLElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 } // namespace
 
index 6284cec..c73c477 100644 (file)
@@ -86,9 +86,9 @@ HTMLTableSectionElement* HTMLTableElement::tHead() const
 {
     for (Node* child = firstChild(); child; child = child->nextSibling()) {
         if (child->hasTagName(theadTag))
-            return toHTMLTableSectionElement(child);
+            return downcast<HTMLTableSectionElement>(child);
     }
-    return 0;
+    return nullptr;
 }
 
 void HTMLTableElement::setTHead(PassRefPtr<HTMLTableSectionElement> newHead, ExceptionCode& ec)
@@ -107,9 +107,9 @@ HTMLTableSectionElement* HTMLTableElement::tFoot() const
 {
     for (Node* child = firstChild(); child; child = child->nextSibling()) {
         if (child->hasTagName(tfootTag))
-            return toHTMLTableSectionElement(child);
+            return downcast<HTMLTableSectionElement>(child);
     }
-    return 0;
+    return nullptr;
 }
 
 void HTMLTableElement::setTFoot(PassRefPtr<HTMLTableSectionElement> newFoot, ExceptionCode& ec)
@@ -178,9 +178,9 @@ HTMLTableSectionElement* HTMLTableElement::lastBody() const
 {
     for (Node* child = lastChild(); child; child = child->previousSibling()) {
         if (child->hasTagName(tbodyTag))
-            return toHTMLTableSectionElement(child);
+            return downcast<HTMLTableSectionElement>(child);
     }
-    return 0;
+    return nullptr;
 }
 
 PassRefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
index 1ff671c..c6c4d9e 100644 (file)
@@ -81,8 +81,8 @@ int HTMLTableRowElement::rowIndex() const
     
     for (Node *node = table->firstChild(); node; node = node->nextSibling()) {
         if (node->hasTagName(tbodyTag)) {
-            HTMLTableSectionElement* section = toHTMLTableSectionElement(node);
-            for (Node* row = section->firstChild(); row; row = row->nextSibling()) {
+            HTMLTableSectionElement& section = downcast<HTMLTableSectionElement>(*node);
+            for (Node* row = section.firstChild(); row; row = row->nextSibling()) {
                 if (row == this)
                     return rIndex;
                 if (row->hasTagName(trTag))
index 3ad22a5..1162aa3 100644 (file)
@@ -58,7 +58,7 @@ static inline bool isInSection(HTMLTableRowElement& row, const HTMLQualifiedName
 {
     // Because we know that the parent is a table or a section, it's safe to cast it to an HTMLElement
     // giving us access to the faster hasTagName overload from that class.
-    return toHTMLElement(row.parentNode())->hasTagName(sectionTag);
+    return downcast<HTMLElement>(*row.parentNode()).hasTagName(sectionTag);
 }
 
 HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement* table, HTMLTableRowElement* previous)
index 70eb17f..6845707 100644 (file)
@@ -61,12 +61,10 @@ private:
     virtual const StyleProperties* additionalPresentationAttributeStyle() override;
 };
 
-inline bool isHTMLTableSectionElement(const Node& node)
-{
-    return node.hasTagName(HTMLNames::theadTag) || node.hasTagName(HTMLNames::tfootTag) || node.hasTagName(HTMLNames::tbodyTag);
-}
-
-NODE_TYPE_CASTS(HTMLTableSectionElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLTableSectionElement)
+    static bool isHTMLTableSectionElement(const HTMLElement& element) { return element.hasTagName(HTMLNames::theadTag) || element.hasTagName(HTMLNames::tfootTag) || element.hasTagName(HTMLNames::tbodyTag); }
+    static bool isHTMLTableSectionElement(const Node& node) { return is<HTMLElement>(node) && isHTMLTableSectionElement(downcast<HTMLElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 } //namespace
 
index c54afa1..0fc8b04 100644 (file)
@@ -15,7 +15,7 @@ audio wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, constructorNeedsCreatedB
 b interfaceName=HTMLElement
 base generateTypeHelpers
 basefont interfaceName=HTMLBaseFontElement
-bdi interfaceName=HTMLBDIElement, JSInterfaceName=HTMLElement
+bdi interfaceName=HTMLBDIElement, JSInterfaceName=HTMLElement, generateTypeHelpers
 bdo interfaceName=HTMLElement
 bgsound interfaceName=HTMLElement
 big interfaceName=HTMLElement
@@ -46,7 +46,7 @@ embed constructorNeedsCreatedByParser, generateTypeHelpers
 fieldset interfaceName=HTMLFieldSetElement, constructorNeedsFormElement, generateTypeHelpers
 figcaption interfaceName=HTMLElement
 figure interfaceName=HTMLElement
-font
+font generateTypeHelpers
 footer interfaceName=HTMLElement
 form generateTypeHelpers
 frame generateTypeHelpers
@@ -94,7 +94,7 @@ ol interfaceName=HTMLOListElement, generateTypeHelpers
 optgroup interfaceName=HTMLOptGroupElement, generateTypeHelpers
 option generateTypeHelpers
 output constructorNeedsFormElement
-p interfaceName=HTMLParagraphElement
+p interfaceName=HTMLParagraphElement, generateTypeHelpers
 param generateTypeHelpers
 plaintext interfaceName=HTMLElement
 pre
@@ -132,7 +132,7 @@ tr interfaceName=HTMLTableRowElement, generateTypeHelpers
 track wrapperOnlyIfMediaIsAvailable, conditional=VIDEO_TRACK, generateTypeHelpers
 tt interfaceName=HTMLElement
 u interfaceName=HTMLElement
-ul interfaceName=HTMLUListElement
+ul interfaceName=HTMLUListElement, generateTypeHelpers
 var interfaceName=HTMLElement
 video wrapperOnlyIfMediaIsAvailable, conditional=VIDEO, constructorNeedsCreatedByParser, generateTypeHelpers
 wbr interfaceName=HTMLElement
index 8cb151b..c041e6e 100644 (file)
@@ -717,7 +717,7 @@ HTMLTextFormControlElement* enclosingTextFormControl(const Position& position)
     if (!container)
         return nullptr;
     Element* ancestor = container->shadowHost();
-    return ancestor && isHTMLTextFormControlElement(*ancestor) ? toHTMLTextFormControlElement(ancestor) : nullptr;
+    return ancestor && is<HTMLTextFormControlElement>(*ancestor) ? downcast<HTMLTextFormControlElement>(ancestor) : nullptr;
 }
 
 static const Element* parentHTMLElement(const Element* element)
index 970f7ab..3337fd9 100644 (file)
@@ -151,10 +151,10 @@ private:
     unsigned char m_isPlaceholderVisible : 1;
 };
 
-void isHTMLTextFormControlElement(const HTMLTextFormControlElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLTextFormControlElement(const Element& element) { return element.isTextFormControl(); }
-inline bool isHTMLTextFormControlElement(const Node& node) { return node.isElementNode() && toElement(node).isTextFormControl(); }
-NODE_TYPE_CASTS(HTMLTextFormControlElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(HTMLTextFormControlElement)
+    static bool isHTMLTextFormControlElement(const Element& element) { return element.isTextFormControl(); }
+    static bool isHTMLTextFormControlElement(const Node& node) { return node.isElementNode() && isHTMLTextFormControlElement(toElement(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 HTMLTextFormControlElement* enclosingTextFormControl(const Position&);
 
index 24e1148..2d0d142 100644 (file)
@@ -85,8 +85,8 @@ Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode&
 
 void HTMLTrackElement::removedFrom(ContainerNode& insertionPoint)
 {
-    if (!parentNode() && isHTMLMediaElement(insertionPoint))
-        toHTMLMediaElement(insertionPoint).didRemoveTextTrack(this);
+    if (!parentNode() && is<HTMLMediaElement>(insertionPoint))
+        downcast<HTMLMediaElement>(insertionPoint).didRemoveTextTrack(this);
     HTMLElement::removedFrom(insertionPoint);
 }
 
@@ -343,10 +343,10 @@ void HTMLTrackElement::textTrackRemoveCue(TextTrack* track, PassRefPtr<TextTrack
 HTMLMediaElement* HTMLTrackElement::mediaElement() const
 {
     Element* parent = parentElement();
-    if (parent && parent->isMediaElement())
-        return toHTMLMediaElement(parentNode());
+    if (parent && is<HTMLMediaElement>(parent))
+        return downcast<HTMLMediaElement>(parentNode());
 
-    return 0;
+    return nullptr;
 }
 
 }
index 3ce6d04..40055c3 100644 (file)
@@ -52,7 +52,7 @@ private:
 
 void isLabelableElement(const LabelableElement&); // Catch unnecessary runtime check of type known at compile time.
 inline bool isLabelableElement(const HTMLElement& element) { return element.isLabelable(); }
-inline bool isLabelableElement(const Node& node) { return node.isHTMLElement() && toHTMLElement(node).isLabelable(); }
+inline bool isLabelableElement(const Node& node) { return is<HTMLElement>(node) && downcast<HTMLElement>(node).isLabelable(); }
 
 template <typename ArgType>
 struct NodeTypeCastTraits<const LabelableElement, ArgType> {
index 68f00f5..96b18cd 100644 (file)
@@ -268,7 +268,7 @@ HTMLElement* RangeInputType::sliderTrackElement() const
     ASSERT(element().userAgentShadowRoot()->firstChild()->isHTMLElement());
     ASSERT(element().userAgentShadowRoot()->firstChild()->firstChild()); // track
 
-    return &toHTMLElement(*element().userAgentShadowRoot()->firstChild()->firstChild());
+    return downcast<HTMLElement>(element().userAgentShadowRoot()->firstChild()->firstChild());
 }
 
 SliderThumbElement& RangeInputType::typedSliderThumbElement() const
index ce7de9b..9e83e62 100644 (file)
@@ -53,18 +53,17 @@ HTMLMediaElement* parentMediaElement(Node* node)
     Node* mediaNode = node->shadowHost();
     if (!mediaNode)
         mediaNode = node;
-    if (!mediaNode->isElementNode() || !toElement(mediaNode)->isMediaElement())
+    if (!is<HTMLMediaElement>(mediaNode))
         return nullptr;
-    return toHTMLMediaElement(mediaNode);
+    return downcast<HTMLMediaElement>(mediaNode);
 }
 
 MediaControlElementType mediaControlElementType(Node* node)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(node->isMediaControlElement());
-    HTMLElement* element = toHTMLElement(node);
-    if (is<HTMLInputElement>(element))
-        return static_cast<MediaControlInputElement*>(element)->displayType();
-    return static_cast<MediaControlDivElement*>(element)->displayType();
+    if (is<HTMLInputElement>(node))
+        return static_cast<MediaControlInputElement*>(node)->displayType();
+    return static_cast<MediaControlDivElement*>(node)->displayType();
 }
 
 MediaControlElement::MediaControlElement(MediaControlElementType displayType, HTMLElement* element)
index c4d87be..b2e8b39 100644 (file)
@@ -71,7 +71,7 @@ private:
 };
 
 inline bool isTextControlInnerTextElement(const HTMLElement& element) { return element.isTextControlInnerTextElement(); }
-inline bool isTextControlInnerTextElement(const Node& node) { return node.isHTMLElement() && isTextControlInnerTextElement(toHTMLElement(node)); }
+inline bool isTextControlInnerTextElement(const Node& node) { return is<HTMLElement>(node) && isTextControlInnerTextElement(downcast<HTMLElement>(node)); }
 NODE_TYPE_CASTS(TextControlInnerTextElement)
 
 class SearchFieldResultsButtonElement final : public HTMLDivElement {
index 0f8a29d..3a3de30 100644 (file)
@@ -1280,14 +1280,14 @@ PassRefPtr<Inspector::Protocol::DOM::Node> InspectorDOMAgent::buildObjectForNode
     if (node->isElementNode()) {
         Element* element = toElement(node);
         value->setAttributes(buildArrayForElementAttributes(element));
-        if (node->isFrameOwnerElement()) {
-            HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(node);
-            Frame* frame = frameOwner->contentFrame();
+        if (is<HTMLFrameOwnerElement>(node)) {
+            HTMLFrameOwnerElement& frameOwner = downcast<HTMLFrameOwnerElement>(*node);
+            Frame* frame = frameOwner.contentFrame();
             if (frame)
                 value->setFrameId(m_pageAgent->frameId(frame));
-            Document* doc = frameOwner->contentDocument();
-            if (doc)
-                value->setContentDocument(buildObjectForNode(doc, 0, nodesMap));
+            Document* document = frameOwner.contentDocument();
+            if (document)
+                value->setContentDocument(buildObjectForNode(document, 0, nodesMap));
         }
 
         if (ShadowRoot* root = element->shadowRoot()) {
index ffeb302..87c0a8f 100644 (file)
@@ -89,9 +89,9 @@ void InspectorNodeFinder::searchUsingDOMTreeTraversal(Node* parentNode)
                 m_results.add(node);
 
             // Search inside frame elements.
-            if (node->isFrameOwnerElement()) {
-                HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(node);
-                if (Document* document = frameOwner->contentDocument())
+            if (is<HTMLFrameOwnerElement>(node)) {
+                HTMLFrameOwnerElement& frameOwner = downcast<HTMLFrameOwnerElement>(*node);
+                if (Document* document = frameOwner.contentDocument())
                     performSearch(document);
             }
 
index d94d72a..4adc572 100644 (file)
@@ -297,8 +297,8 @@ Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement& ownerElement, const U
     bool allowsScrolling = true;
     int marginWidth = -1;
     int marginHeight = -1;
-    if (ownerElement.hasTagName(frameTag) || ownerElement.hasTagName(iframeTag)) {
-        HTMLFrameElementBase& frameElementBase = toHTMLFrameElementBase(ownerElement);
+    if (is<HTMLFrameElementBase>(ownerElement)) {
+        HTMLFrameElementBase& frameElementBase = downcast<HTMLFrameElementBase>(ownerElement);
         allowsScrolling = frameElementBase.scrollingMode() != ScrollbarAlwaysOff;
         marginWidth = frameElementBase.marginWidth();
         marginHeight = frameElementBase.marginHeight();
index d122083..0802681 100644 (file)
@@ -36,6 +36,7 @@
 #include "FrameLoader.h"
 #include "FrameSelection.h"
 #include "FrameTree.h"
+#include "HTMLFrameElementBase.h"
 #include "HTMLFrameOwnerElement.h"
 #include "HTMLNames.h"
 #include "IconDatabase.h"
@@ -516,8 +517,8 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
     for (size_t i = 0; i < nodesSize; ++i) {
         Node& node = *nodes[i];
         Frame* childFrame;
-        if ((is<HTMLFrameElement>(node) || is<HTMLIFrameElement>(node) || is<HTMLObjectElement>(node))
-            && (childFrame = toHTMLFrameOwnerElement(node).contentFrame())) {
+        if ((is<HTMLFrameElementBase>(node) || is<HTMLObjectElement>(node))
+            && (childFrame = downcast<HTMLFrameOwnerElement>(node).contentFrame())) {
             if (frameFilter && !frameFilter(*childFrame))
                 continue;
                 
index 16bd7c6..31f6fc4 100644 (file)
@@ -83,19 +83,19 @@ bool MathMLElement::isPhrasingContent(const Node& node) const
     if (!node.isElementNode())
         return node.isTextNode();
 
-    if (node.isMathMLElement()) {
+    if (is<MathMLElement>(node)) {
         auto& mathmlElement = downcast<MathMLElement>(node);
-        return mathmlElement.hasTagName(MathMLNames::mathTag);
+        return is<MathMLMathElement>(mathmlElement);
     }
 
-    if (node.isSVGElement()) {
+    if (is<SVGElement>(node)) {
         auto& svgElement = downcast<SVGElement>(node);
-        return svgElement.hasTagName(SVGNames::svgTag);
+        return is<SVGSVGElement>(svgElement);
     }
 
-    if (node.isHTMLElement()) {
+    if (is<HTMLElement>(node)) {
         // FIXME: add the <data> and <time> tags when they are implemented.
-        auto& htmlElement = toHTMLElement(node);
+        auto& htmlElement = downcast<HTMLElement>(node);
         return htmlElement.hasTagName(HTMLNames::aTag)
             || htmlElement.hasTagName(HTMLNames::abbrTag)
             || (htmlElement.hasTagName(HTMLNames::areaTag) && ancestorsOfType<HTMLMapElement>(htmlElement).first())
@@ -158,10 +158,10 @@ bool MathMLElement::isFlowContent(const Node& node) const
     if (isPhrasingContent(node))
         return true;
 
-    if (!node.isHTMLElement())
+    if (!is<HTMLElement>(node))
         return false;
 
-    auto& htmlElement = toHTMLElement(node);
+    auto& htmlElement = downcast<HTMLElement>(node);
     // FIXME add the <dialog> tag when it is implemented.
     return htmlElement.hasTagName(HTMLNames::addressTag)
         || htmlElement.hasTagName(HTMLNames::articleTag)
@@ -268,26 +268,26 @@ bool MathMLElement::childShouldCreateRenderer(const Node& child) const
 
         // See annotation-xml.model.mathml, annotation-xml.model.svg and annotation-xml.model.xhtml in the HTML5 RelaxNG schema.
 
-        if (child.isMathMLElement() && (MathMLSelectElement::isMathMLEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
+        if (is<MathMLElement>(child) && (MathMLSelectElement::isMathMLEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
             auto& mathmlElement = downcast<MathMLElement>(child);
-            return mathmlElement.hasTagName(MathMLNames::mathTag);
+            return is<MathMLMathElement>(mathmlElement);
         }
 
-        if (child.isSVGElement() && (MathMLSelectElement::isSVGEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
+        if (is<SVGElement>(child) && (MathMLSelectElement::isSVGEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
             auto& svgElement = downcast<SVGElement>(child);
-            return svgElement.hasTagName(SVGNames::svgTag);
+            return is<SVGSVGElement>(svgElement);
         }
 
-        if (child.isHTMLElement() && MathMLSelectElement::isHTMLEncoding(value)) {
-            auto& htmlElement = toHTMLElement(child);
-            return htmlElement.hasTagName(HTMLNames::htmlTag) || (isFlowContent(htmlElement) && StyledElement::childShouldCreateRenderer(child));
+        if (is<HTMLElement>(child) && MathMLSelectElement::isHTMLEncoding(value)) {
+            auto& htmlElement = downcast<HTMLElement>(child);
+            return is<HTMLHtmlElement>(htmlElement) || (isFlowContent(htmlElement) && StyledElement::childShouldCreateRenderer(child));
         }
 
         return false;
     }
 
     // In general, only MathML children are allowed. Text nodes are only visible in token MathML elements.
-    return child.isMathMLElement();
+    return is<MathMLElement>(child);
 }
 
 void MathMLElement::attributeChanged(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason reason)
index 3b7fb41..9ef714e 100644 (file)
@@ -6,7 +6,7 @@ fallbackInterfaceName="MathMLElement"
 annotation interfaceName=MathMLTextElement
 annotation-xml interfaceName=MathMLInlineContainerElement
 maction interfaceName=MathMLSelectElement
-math
+math generateTypeHelpers
 mfrac interfaceName=MathMLInlineContainerElement
 mfenced interfaceName=MathMLInlineContainerElement
 msubsup interfaceName=MathMLInlineContainerElement
index 179eea5..ac40589 100644 (file)
@@ -552,8 +552,8 @@ bool DragController::canProcessDrag(DragData& dragData)
     if (dragData.containsFiles() && asFileInput(result.innerNonSharedNode()))
         return true;
 
-    if (result.innerNonSharedNode()->isPluginElement()) {
-        if (!toHTMLPlugInElement(result.innerNonSharedNode())->canProcessDrag() && !result.innerNonSharedNode()->hasEditableStyle())
+    if (is<HTMLPlugInElement>(result.innerNonSharedNode())) {
+        if (!downcast<HTMLPlugInElement>(result.innerNonSharedNode())->canProcessDrag() && !result.innerNonSharedNode()->hasEditableStyle())
             return false;
     } else if (!result.innerNonSharedNode()->hasEditableStyle())
         return false;
index 6779292..bbde743 100644 (file)
@@ -2141,14 +2141,10 @@ bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Element& dra
 
 static bool targetIsFrame(Node* target, Frame*& frame)
 {
-    if (!target)
-        return false;
-
-    if (!target->hasTagName(frameTag) && !target->hasTagName(iframeTag))
+    if (!target || !is<HTMLFrameElementBase>(target))
         return false;
 
-    frame = toHTMLFrameElementBase(target)->contentFrame();
-
+    frame = downcast<HTMLFrameElementBase>(*target).contentFrame();
     return true;
 }
 
index ec85606..db42b87 100644 (file)
@@ -45,6 +45,7 @@
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
+#include "HTMLPlugInElement.h"
 #include "HTMLTextAreaElement.h"
 #include "HitTestResult.h"
 #include "KeyboardEvent.h"
@@ -134,7 +135,7 @@ static inline void dispatchEventsOnWindowAndFocusedElement(Document* document, b
 
 static inline bool hasCustomFocusLogic(Element& element)
 {
-    return element.isHTMLElement() && toHTMLElement(element).hasCustomFocusLogic();
+    return is<HTMLElement>(element) && downcast<HTMLElement>(element).hasCustomFocusLogic();
 }
 
 static inline bool isNonFocusableShadowHost(Element& element, KeyboardEvent& event)
@@ -227,8 +228,8 @@ Element* FocusController::findFocusableElementDescendingDownIntoFrameDocument(Fo
     // The node we found might be a HTMLFrameOwnerElement, so descend down the tree until we find either:
     // 1) a focusable node, or
     // 2) the deepest-nested HTMLFrameOwnerElement.
-    while (element && element->isFrameOwnerElement()) {
-        HTMLFrameOwnerElement& owner = toHTMLFrameOwnerElement(*element);
+    while (element && is<HTMLFrameOwnerElement>(element)) {
+        HTMLFrameOwnerElement& owner = downcast<HTMLFrameOwnerElement>(*element);
         if (!owner.contentFrame())
             break;
         Element* foundElement = findFocusableElement(direction, FocusNavigationScope::focusNavigationScopeOwnedByIFrame(&owner), 0, event);
@@ -311,10 +312,10 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
         return true;
     }
 
-    if (element->isFrameOwnerElement() && (!element->isPluginElement() || !element->isKeyboardFocusable(event))) {
+    if (is<HTMLFrameOwnerElement>(*element) && (!is<HTMLPlugInElement>(*element) || !element->isKeyboardFocusable(event))) {
         // We focus frames rather than frame owners.
         // FIXME: We should not focus frames that have no scrollbars, as focusing them isn't useful to the user.
-        HTMLFrameOwnerElement& owner = toHTMLFrameOwnerElement(*element);
+        HTMLFrameOwnerElement& owner = downcast<HTMLFrameOwnerElement>(*element);
         if (!owner.contentFrame())
             return false;
 
index fad9a92..a9cd3ba 100644 (file)
@@ -61,6 +61,7 @@
 #include "HTMLFrameElementBase.h"
 #include "HTMLNames.h"
 #include "HTMLTableCellElement.h"
+#include "HTMLTableRowElement.h"
 #include "HitTestResult.h"
 #include "ImageBuffer.h"
 #include "InspectorInstrumentation.h"
@@ -392,9 +393,9 @@ String Frame::searchForLabelsBeforeElement(const Vector<String>& labels, Element
         if (is<HTMLFormElement>(n) || is<HTMLFormControlElement>(n))
             break;
 
-        if (n->hasTagName(tdTag) && !startingTableCell) {
-            startingTableCell = toHTMLTableCellElement(n);
-        } else if (n->hasTagName(trTag) && startingTableCell) {
+        if (n->hasTagName(tdTag) && !startingTableCell)
+            startingTableCell = downcast<HTMLTableCellElement>(n);
+        else if (is<HTMLTableRowElement>(n) && startingTableCell) {
             String result = searchForLabelsAboveCell(regExp, startingTableCell, resultDistance);
             if (!result.isEmpty()) {
                 if (resultIsInCellAbove)
index 4fc53de..fdfb6cc 100644 (file)
@@ -322,12 +322,12 @@ void FrameView::init()
 
     // Propagate the marginwidth/height and scrolling modes to the view.
     Element* ownerElement = frame().ownerElement();
-    if (ownerElement && (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))) {
-        HTMLFrameElementBase* frameElt = toHTMLFrameElementBase(ownerElement);
-        if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
+    if (ownerElement && is<HTMLFrameElementBase>(ownerElement)) {
+        HTMLFrameElementBase& frameElement = downcast<HTMLFrameElementBase>(*ownerElement);
+        if (frameElement.scrollingMode() == ScrollbarAlwaysOff)
             setCanHaveScrollbars(false);
-        LayoutUnit marginWidth = frameElt->marginWidth();
-        LayoutUnit marginHeight = frameElt->marginHeight();
+        LayoutUnit marginWidth = frameElement.marginWidth();
+        LayoutUnit marginHeight = frameElement.marginHeight();
         if (marginWidth != -1)
             setMarginWidth(marginWidth);
         if (marginHeight != -1)
@@ -1416,7 +1416,7 @@ void FrameView::addEmbeddedObjectToUpdate(RenderEmbeddedObject& embeddedObject)
     HTMLFrameOwnerElement& element = embeddedObject.frameOwnerElement();
     if (is<HTMLObjectElement>(element) || is<HTMLEmbedElement>(element)) {
         // Tell the DOM element that it needs a widget update.
-        HTMLPlugInImageElement& pluginElement = toHTMLPlugInImageElement(element);
+        HTMLPlugInImageElement& pluginElement = downcast<HTMLPlugInImageElement>(element);
         if (!pluginElement.needsCheckForSizeChange())
             pluginElement.setNeedsWidgetUpdate(true);
     }
@@ -2789,7 +2789,7 @@ void FrameView::updateEmbeddedObject(RenderEmbeddedObject& embeddedObject)
 
     if (embeddedObject.isSnapshottedPlugIn()) {
         if (is<HTMLObjectElement>(element) || is<HTMLEmbedElement>(element)) {
-            HTMLPlugInImageElement& pluginElement = toHTMLPlugInImageElement(element);
+            HTMLPlugInImageElement& pluginElement = downcast<HTMLPlugInImageElement>(element);
             pluginElement.checkSnapshotStatus();
         }
         return;
@@ -2799,8 +2799,8 @@ void FrameView::updateEmbeddedObject(RenderEmbeddedObject& embeddedObject)
 
     // FIXME: This could turn into a real virtual dispatch if we defined
     // updateWidget(PluginCreationOption) on HTMLElement.
-    if (is<HTMLObjectElement>(element) || is<HTMLEmbedElement>(element) || is<HTMLAppletElement>(element)) {
-        HTMLPlugInImageElement& pluginElement = toHTMLPlugInImageElement(element);
+    if (is<HTMLPlugInImageElement>(element)) {
+        HTMLPlugInImageElement& pluginElement = downcast<HTMLPlugInImageElement>(element);
         if (pluginElement.needsCheckForSizeChange()) {
             pluginElement.checkSnapshotStatus();
             return;
index 8e1dcef..096ee1e 100644 (file)
@@ -66,10 +66,10 @@ namespace WebCore {
 
 static bool isCharsetSpecifyingNode(const Node& node)
 {
-    if (!node.isHTMLElement())
+    if (!is<HTMLElement>(node))
         return false;
 
-    const HTMLElement& element = toHTMLElement(node);
+    const HTMLElement& element = downcast<HTMLElement>(node);
     if (!element.hasTagName(HTMLNames::metaTag))
         return false;
     HTMLMetaCharsetParser::AttributeList attributes;
@@ -146,10 +146,10 @@ void SerializerMarkupAccumulator::appendElement(StringBuilder& out, const Elemen
 
 void SerializerMarkupAccumulator::appendCustomAttributes(StringBuilder& out, const Element& element, Namespaces* namespaces)
 {
-    if (!element.isFrameOwnerElement())
+    if (!is<HTMLFrameOwnerElement>(element))
         return;
 
-    const HTMLFrameOwnerElement& frameOwner = toHTMLFrameOwnerElement(element);
+    const HTMLFrameOwnerElement& frameOwner = downcast<HTMLFrameOwnerElement>(element);
     Frame* frame = frameOwner.contentFrame();
     if (!frame)
         return;
index 4e38924..e5fb05e 100644 (file)
@@ -758,7 +758,7 @@ LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement* area, FocusDir
 
 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate& candidate)
 {
-    return candidate.isFrameOwnerElement() ? toHTMLFrameOwnerElement(candidate.visibleNode) : nullptr;
-};
+    return candidate.isFrameOwnerElement() ? downcast<HTMLFrameOwnerElement>(candidate.visibleNode) : nullptr;
+}
 
 } // namespace WebCore
index 93ce49d..9aaec8c 100644 (file)
@@ -337,7 +337,7 @@ URL HitTestResult::absolutePDFURL() const
     if (!is<HTMLEmbedElement>(*m_innerNonSharedNode) && !is<HTMLObjectElement>(*m_innerNonSharedNode))
         return URL();
 
-    HTMLPlugInImageElement& element = toHTMLPlugInImageElement(*m_innerNonSharedNode);
+    HTMLPlugInImageElement& element = downcast<HTMLPlugInImageElement>(*m_innerNonSharedNode);
     URL url = m_innerNonSharedNode->document().completeURL(stripLeadingAndTrailingHTMLSpaces(element.url()));
     if (!url.isValid())
         return URL();
@@ -372,14 +372,14 @@ bool HitTestResult::mediaSupportsFullscreen() const
 HTMLMediaElement* HitTestResult::mediaElement() const
 {
     if (!m_innerNonSharedNode)
-        return 0;
+        return nullptr;
 
     if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->isMedia()))
-        return 0;
+        return nullptr;
 
-    if (is<HTMLVideoElement>(m_innerNonSharedNode.get()) || is<HTMLAudioElement>(m_innerNonSharedNode.get()))
-        return toHTMLMediaElement(m_innerNonSharedNode.get());
-    return 0;
+    if (is<HTMLMediaElement>(*m_innerNonSharedNode))
+        return downcast<HTMLMediaElement>(m_innerNonSharedNode.get());
+    return nullptr;
 }
 #endif
 
index 19aa99b..3fb84d8 100644 (file)
@@ -3567,8 +3567,8 @@ inline static bool resizeTextPermitted(RenderObject* render)
     auto renderer = render->parent();
     while (renderer) {
         // Get the first non-shadow HTMLElement and see if it's an input.
-        if (renderer->element() && renderer->element()->isHTMLElement() && !renderer->element()->isInShadowTree()) {
-            const HTMLElement& element = toHTMLElement(*renderer->element());
+        if (renderer->element() && is<HTMLElement>(renderer->element()) && !renderer->element()->isInShadowTree()) {
+            const HTMLElement& element = downcast<HTMLElement>(*renderer->element());
             return !is<HTMLInputElement>(element) && !is<HTMLTextAreaElement>(element);
         }
         renderer = renderer->parent();
index 6c50ded..149060a 100644 (file)
@@ -224,10 +224,10 @@ void RenderEmbeddedObject::paintSnapshotImage(PaintInfo& paintInfo, const Layout
 
 void RenderEmbeddedObject::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!frameOwnerElement().isPluginElement())
+    if (!is<HTMLPlugInElement>(frameOwnerElement()))
         return;
 
-    HTMLPlugInElement& plugInElement = toHTMLPlugInElement(frameOwnerElement());
+    HTMLPlugInElement& plugInElement = downcast<HTMLPlugInElement>(frameOwnerElement());
 
     if (plugInElement.displayState() > HTMLPlugInElement::DisplayingSnapshot) {
         RenderWidget::paintContents(paintInfo, paintOffset);
@@ -235,10 +235,10 @@ void RenderEmbeddedObject::paintContents(PaintInfo& paintInfo, const LayoutPoint
             return;
     }
 
-    if (!plugInElement.isPlugInImageElement())
+    if (!is<HTMLPlugInImageElement>(plugInElement))
         return;
 
-    if (Image* snapshot = toHTMLPlugInImageElement(plugInElement).snapshotImage())
+    if (Image* snapshot = downcast<HTMLPlugInImageElement>(plugInElement).snapshotImage())
         paintSnapshotImage(paintInfo, paintOffset, snapshot);
 }
 
@@ -493,8 +493,8 @@ void RenderEmbeddedObject::layout()
 
     if (!wasMissingWidget && newSize.width() >= oldSize.width() && newSize.height() >= oldSize.height()) {
         HTMLFrameOwnerElement& element = frameOwnerElement();
-        if (element.isPluginElement() && toHTMLPlugInElement(element).isPlugInImageElement()) {
-            HTMLPlugInImageElement& plugInImageElement = toHTMLPlugInImageElement(element);
+        if (is<HTMLPlugInImageElement>(element)) {
+            HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(element);
             if (plugInImageElement.displayState() > HTMLPlugInElement::DisplayingSnapshot && plugInImageElement.snapshotDecision() == HTMLPlugInImageElement::MaySnapshotWhenResized) {
                 plugInImageElement.setNeedsCheckForSizeChange();
                 view().frameView().addEmbeddedObjectToUpdate(*this);
@@ -604,7 +604,7 @@ void RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent(Event* event)
         return;
 
     MouseEvent* mouseEvent = toMouseEvent(event);
-    HTMLPlugInElement& element = toHTMLPlugInElement(frameOwnerElement());
+    HTMLPlugInElement& element = downcast<HTMLPlugInElement>(frameOwnerElement());
     if (event->type() == eventNames().mousedownEvent && toMouseEvent(event)->button() == LeftButton) {
         m_mouseDownWasInUnavailablePluginIndicator = isInUnavailablePluginIndicator(mouseEvent);
         if (m_mouseDownWasInUnavailablePluginIndicator) {
index 5f3a497..93efaf5 100644 (file)
@@ -2380,8 +2380,8 @@ void RenderLayer::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignm
         if (ownerElement && ownerElement->renderer()) {
             HTMLFrameElementBase* frameElementBase = nullptr;
 
-            if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))
-                frameElementBase = toHTMLFrameElementBase(ownerElement);
+            if (is<HTMLFrameElementBase>(ownerElement))
+                frameElementBase = downcast<HTMLFrameElementBase>(ownerElement);
 
             if (frameElementAndViewPermitScroll(frameElementBase, &frameView)) {
                 LayoutRect viewRect = frameView.visibleContentRect(LegacyIOSDocumentVisibleRect);
@@ -3089,11 +3089,11 @@ bool RenderLayer::hasScrollableOrRubberbandableAncestor()
 void RenderLayer::updateSnapOffsets()
 {
     // FIXME: Extend support beyond HTMLElements.
-    if (!enclosingElement() || !enclosingElement()->renderBox() || !enclosingElement()->isHTMLElement())
+    if (!enclosingElement() || !enclosingElement()->renderBox() || !is<HTMLElement>(enclosingElement()))
         return;
 
     RenderBox* box = enclosingElement()->renderBox();
-    updateSnapOffsetsForScrollableArea(*this, *toHTMLElement(enclosingElement()), *box, box->style());
+    updateSnapOffsetsForScrollableArea(*this, *downcast<HTMLElement>(enclosingElement()), *box, box->style());
 }
 #endif
 
index 371df40..64a6f47 100644 (file)
@@ -586,7 +586,7 @@ bool RenderLayerBacking::updateConfiguration()
     }
 #if ENABLE(VIDEO)
     else if (renderer().isVideo()) {
-        HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer().element());
+        HTMLMediaElement* mediaElement = downcast<HTMLMediaElement>(renderer().element());
         m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(), GraphicsLayer::ContentsLayerForMedia);
     }
 #endif
@@ -1681,10 +1681,10 @@ static bool isRestartedPlugin(RenderObject* renderer)
         return false;
 
     Element* element = toElement(renderer->node());
-    if (!element || !element->isPluginElement())
+    if (!element || !is<HTMLPlugInElement>(element))
         return false;
 
-    return toHTMLPlugInElement(element)->isRestartedPlugin();
+    return downcast<HTMLPlugInElement>(*element).isRestartedPlugin();
 }
 
 static bool isCompositedPlugin(RenderObject* renderer)
index 7319dda..e959e24 100644 (file)
@@ -39,7 +39,7 @@ public:
     RenderMedia(HTMLMediaElement&, PassRef<RenderStyle>, const IntSize& intrinsicSize);
     virtual ~RenderMedia();
 
-    HTMLMediaElement& mediaElement() const { return toHTMLMediaElement(nodeForNonAnonymous()); }
+    HTMLMediaElement& mediaElement() const { return downcast<HTMLMediaElement>(nodeForNonAnonymous()); }
 
 private:
     void element() const = delete;
index f78baf3..79c8ecc 100644 (file)
@@ -2444,7 +2444,7 @@ RenderBoxModelObject* RenderObject::offsetParent() const
     auto curr = parent();
     while (curr && (!curr->element() || (!curr->isPositioned() && !curr->isBody())) && !curr->isRenderNamedFlowThread()) {
         Element* element = curr->element();
-        if (!skipTables && element && (is<HTMLTableElement>(*element) || isHTMLTableCellElement(*element)))
+        if (!skipTables && element && (is<HTMLTableElement>(*element) || is<HTMLTableCellElement>(*element)))
             break;
  
         float newZoom = curr->style().effectiveZoom();
index 7978fe2..de3726d 100644 (file)
@@ -64,7 +64,7 @@ RenderSnapshottedPlugIn::~RenderSnapshottedPlugIn()
 
 HTMLPlugInImageElement& RenderSnapshottedPlugIn::plugInImageElement() const
 {
-    return toHTMLPlugInImageElement(RenderEmbeddedObject::frameOwnerElement());
+    return downcast<HTMLPlugInImageElement>(RenderEmbeddedObject::frameOwnerElement());
 }
 
 void RenderSnapshottedPlugIn::layout()
index 66fb390..4215b8f 100644 (file)
@@ -88,8 +88,8 @@ void RenderTableCell::willBeRemovedFromTree()
 unsigned RenderTableCell::parseColSpanFromDOM() const
 {
     ASSERT(element());
-    if (element()->hasTagName(tdTag) || element()->hasTagName(thTag))
-        return std::min<unsigned>(toHTMLTableCellElement(element())->colSpan(), maxColumnIndex);
+    if (is<HTMLTableCellElement>(element()))
+        return std::min<unsigned>(downcast<HTMLTableCellElement>(*element()).colSpan(), maxColumnIndex);
 #if ENABLE(MATHML)
     if (element()->hasTagName(MathMLNames::mtdTag))
         return std::min<unsigned>(downcast<MathMLElement>(*element()).colSpan(), maxColumnIndex);
@@ -100,8 +100,8 @@ unsigned RenderTableCell::parseColSpanFromDOM() const
 unsigned RenderTableCell::parseRowSpanFromDOM() const
 {
     ASSERT(element());
-    if (element()->hasTagName(tdTag) || element()->hasTagName(thTag))
-        return std::min<unsigned>(toHTMLTableCellElement(element())->rowSpan(), maxRowIndex);
+    if (is<HTMLTableCellElement>(element()))
+        return std::min<unsigned>(downcast<HTMLTableCellElement>(*element()).rowSpan(), maxRowIndex);
 #if ENABLE(MATHML)
     if (element()->hasTagName(MathMLNames::mtdTag))
         return std::min<unsigned>(downcast<MathMLElement>(*element()).rowSpan(), maxRowIndex);
index 8b0d0ef..4035f66 100644 (file)
@@ -48,7 +48,7 @@ RenderTextControl::~RenderTextControl()
 
 HTMLTextFormControlElement& RenderTextControl::textFormControlElement() const
 {
-    return toHTMLTextFormControlElement(nodeForNonAnonymous());
+    return downcast<HTMLTextFormControlElement>(nodeForNonAnonymous());
 }
 
 TextControlInnerTextElement* RenderTextControl::innerTextElement() const
index 4bd2397..cbd92ab 100644 (file)
@@ -258,13 +258,13 @@ static GRefPtr<GdkPixbuf> getStockSymbolicIconForWidgetType(GType widgetType, co
 static HTMLMediaElement* getMediaElementFromRenderObject(const RenderObject& o)
 {
     Node* node = o.node();
-    Node* mediaNode = node ? node->shadowHost() : 0;
+    Node* mediaNode = node ? node->shadowHost() : nullptr;
     if (!mediaNode)
         mediaNode = node;
-    if (!mediaNode || !mediaNode->isElementNode() || !toElement(mediaNode)->isMediaElement())
-        return 0;
+    if (!mediaNode || !is<HTMLMediaElement>(mediaNode))
+        return nullptr;
 
-    return toHTMLMediaElement(mediaNode);
+    return downcast<HTMLMediaElement>(mediaNode);
 }
 
 void RenderThemeGtk::initMediaColors()
index 82f101e..36e0771 100644 (file)
@@ -1683,7 +1683,7 @@ bool RenderThemeMac::paintSearchFieldCancelButton(const RenderObject& o, const P
 
     NSSearchFieldCell* search = this->search();
 
-    if (!input->isDisabledFormControl() && (input->isTextFormControl() && !toHTMLTextFormControlElement(*input).isReadOnly()))
+    if (!input->isDisabledFormControl() && (is<HTMLTextFormControlElement>(input) && !downcast<HTMLTextFormControlElement>(*input).isReadOnly()))
         updatePressedState([search cancelButtonCell], o);
     else if ([[search cancelButtonCell] isHighlighted])
         [[search cancelButtonCell] setHighlighted:NO];
@@ -1851,22 +1851,22 @@ bool RenderThemeMac::paintSnapshottedPluginOverlay(const RenderObject& o, const
     // from our node. Assuming this node is the plugin overlay element, we should get to the
     // plugin itself by asking for the shadow root parent, and then its parent.
 
-    if (!renderBlock.element()->isHTMLElement())
+    if (!is<HTMLElement>(renderBlock.element()))
         return true;
 
-    HTMLElement* plugInOverlay = toHTMLElement(renderBlock.element());
-    Element* parent = plugInOverlay->parentOrShadowHostElement();
-    while (parent && !parent->isPluginElement())
+    HTMLElement& plugInOverlay = downcast<HTMLElement>(*renderBlock.element());
+    Element* parent = plugInOverlay.parentOrShadowHostElement();
+    while (parent && !is<HTMLPlugInElement>(parent))
         parent = parent->parentOrShadowHostElement();
 
     if (!parent)
         return true;
 
-    HTMLPlugInElement* plugInElement = toHTMLPlugInElement(parent);
-    if (!plugInElement->isPlugInImageElement())
+    HTMLPlugInElement& plugInElement = downcast<HTMLPlugInElement>(*parent);
+    if (!plugInElement.isPlugInImageElement())
         return true;
 
-    HTMLPlugInImageElement& plugInImageElement = toHTMLPlugInImageElement(*plugInElement);
+    HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(plugInElement);
 
     Image* snapshot = plugInImageElement.snapshotImage();
     if (!snapshot)
index eeaceb8..1e7d752 100644 (file)
@@ -33,6 +33,7 @@
 #include "FrameView.h"
 #include "HTMLElement.h"
 #include "HTMLNames.h"
+#include "HTMLSpanElement.h"
 #include "InlineTextBox.h"
 #include "PrintContext.h"
 #include "PseudoElement.h"
@@ -124,17 +125,17 @@ static String getTagName(Node* n)
 
 static bool isEmptyOrUnstyledAppleStyleSpan(const Node* node)
 {
-    if (!node || !node->isHTMLElement() || !node->hasTagName(spanTag))
+    if (!node || !is<HTMLSpanElement>(node))
         return false;
 
-    const HTMLElement* elem = toHTMLElement(node);
-    if (elem->getAttribute(classAttr) != "Apple-style-span")
+    const HTMLElement& element = downcast<HTMLSpanElement>(*node);
+    if (element.getAttribute(classAttr) != "Apple-style-span")
         return false;
 
     if (!node->hasChildNodes())
         return true;
 
-    const StyleProperties* inlineStyleDecl = elem->inlineStyle();
+    const StyleProperties* inlineStyleDecl = element.inlineStyle();
     return (!inlineStyleDecl || inlineStyleDecl->isEmpty());
 }
 
index 7731bbe..15781f6 100644 (file)
@@ -60,7 +60,7 @@ class RenderWidget : public RenderReplaced, private OverlapTestRequestClient {
 public:
     virtual ~RenderWidget();
 
-    HTMLFrameOwnerElement& frameOwnerElement() const { return toHTMLFrameOwnerElement(nodeForNonAnonymous()); }
+    HTMLFrameOwnerElement& frameOwnerElement() const { return downcast<HTMLFrameOwnerElement>(nodeForNonAnonymous()); }
 
     Widget* widget() const { return m_widget.get(); }
     WEBCORE_EXPORT void setWidget(PassRefPtr<Widget>);
index d2ae130..aa3a714 100644 (file)
@@ -623,8 +623,8 @@ void Internals::setShadowPseudoId(Element* element, const String& id, ExceptionC
 
 String Internals::visiblePlaceholder(Element* element)
 {
-    if (element && isHTMLTextFormControlElement(*element)) {
-        const HTMLTextFormControlElement& textFormControlElement = toHTMLTextFormControlElement(*element);
+    if (element && is<HTMLTextFormControlElement>(*element)) {
+        const HTMLTextFormControlElement& textFormControlElement = downcast<HTMLTextFormControlElement>(*element);
         if (!textFormControlElement.isPlaceholderVisible())
             return String();
         if (HTMLElement* placeholderElement = textFormControlElement.placeholderElement())
@@ -2073,7 +2073,7 @@ String Internals::getImageSourceURL(Element* element, ExceptionCode& ec)
 void Internals::simulateAudioInterruption(Node* node)
 {
 #if USE(GSTREAMER)
-    HTMLMediaElement* element = toHTMLMediaElement(node);
+    HTMLMediaElement* element = downcast<HTMLMediaElement>(node);
     element->player()->simulateAudioInterruption();
 #else
     UNUSED_PARAM(node);
@@ -2232,7 +2232,7 @@ bool Internals::isPluginSnapshotted(Element* element, ExceptionCode& ec)
         ec = INVALID_ACCESS_ERR;
         return false;
     }
-    HTMLPlugInElement* pluginElement = toHTMLPlugInElement(element);
+    HTMLPlugInElement* pluginElement = downcast<HTMLPlugInElement>(element);
     return pluginElement->displayState() <= HTMLPlugInElement::DisplayingSnapshot;
 }
     
index 4e2a75c..4916c73 100644 (file)
@@ -208,9 +208,9 @@ inline bool nodeMatchesBasicTest(Node& node, Step::Axis axis, const Step::NodeTe
                 return namespaceURI.isEmpty() || namespaceURI == node.namespaceURI();
 
             if (node.document().isHTMLDocument()) {
-                if (node.isHTMLElement()) {
+                if (is<HTMLElement>(node)) {
                     // Paths without namespaces should match HTML elements in HTML documents despite those having an XHTML namespace. Names are compared case-insensitively.
-                    return equalIgnoringCase(toHTMLElement(node).localName(), name) && (namespaceURI.isNull() || namespaceURI == node.namespaceURI());
+                    return equalIgnoringCase(downcast<HTMLElement>(node).localName(), name) && (namespaceURI.isNull() || namespaceURI == node.namespaceURI());
                 }
                 // An expression without any prefix shouldn't match no-namespace nodes (because HTML5 says so).
                 return toElement(node).hasLocalName(name) && namespaceURI == node.namespaceURI() && !namespaceURI.isNull();
index 10559c5..c713da2 100644 (file)
@@ -1,3 +1,17 @@
+2014-09-26  Christophe Dumez  <cdumez@apple.com>
+
+        Stop using legacy NODE_TYPE_CASTS() macro for HTML Elements
+        https://bugs.webkit.org/show_bug.cgi?id=137137
+
+        Reviewed by Benjamin Poulain.
+
+        Use is<>() / downcast<>() where appropriate.
+
+        * DOMHTMLClasses.cpp:
+        (DOMHTMLElement::idName):
+        (DOMHTMLElement::innerText):
+        (DOMHTMLElement::setInnerText):
+
 2014-09-25  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Debug builds of TestWebKitAPI are crashing.
index 1d1d240..5a9f7a1 100644 (file)
@@ -395,8 +395,8 @@ HRESULT STDMETHODCALLTYPE DOMHTMLElement::idName(
     if (!result)
         return E_POINTER;
 
-    ASSERT(m_element && m_element->isHTMLElement());
-    String idString = toHTMLElement(m_element)->getAttribute(idAttr);
+    ASSERT(m_element && is<HTMLElement>(m_element));
+    String idString = downcast<HTMLElement>(m_element)->getAttribute(idAttr);
     *result = BString(idString).release();
     return S_OK;
 }
@@ -481,8 +481,8 @@ HRESULT STDMETHODCALLTYPE DOMHTMLElement::setInnerHTML(
 HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText( 
         /* [retval][out] */ BSTR* result)
 {
-    ASSERT(m_element && m_element->isHTMLElement());
-    WTF::String innerTextString = toHTMLElement(m_element)->innerText();
+    ASSERT(m_element && is<HTMLElement>(m_element));
+    WTF::String innerTextString = downcast<HTMLElement>(m_element)->innerText();
     *result = BString(innerTextString).release();
     return S_OK;
 }
@@ -490,8 +490,8 @@ HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText(
 HRESULT STDMETHODCALLTYPE DOMHTMLElement::setInnerText( 
         /* [in] */ BSTR text)
 {
-    ASSERT(m_element && m_element->isHTMLElement());
-    HTMLElement* htmlEle = toHTMLElement(m_element);
+    ASSERT(m_element && is<HTMLElement>(m_element));
+    HTMLElement* htmlEle = downcast<HTMLElement>(m_element);
     WTF::String textString(text, SysStringLen(text));
     WebCore::ExceptionCode ec = 0;
     htmlEle->setInnerText(textString, ec);
index a0e2be3..8ffea0a 100644 (file)
@@ -1,3 +1,23 @@
+2014-09-26  Christophe Dumez  <cdumez@apple.com>
+
+        Stop using legacy NODE_TYPE_CASTS() macro for HTML Elements
+        https://bugs.webkit.org/show_bug.cgi?id=137137
+
+        Reviewed by Benjamin Poulain.
+
+        Use is<>() / downcast<>() where appropriate.
+
+        * WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:
+        (WebKit::PDFPluginTextAnnotation::value):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::initializePlugin):
+        (WebKit::PluginView::pluginSnapshotTimerFired):
+        (WebKit::PluginView::pluginDidReceiveUserInteraction):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::createPlugin):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::performActionOnElement):
+
 2014-09-26  Anders Carlsson  <andersca@apple.com>
 
         Add API for loading local files
index 068ae09..e240fc8 100644 (file)
@@ -128,7 +128,7 @@ void PDFPluginTextAnnotation::commit()
 
 String PDFPluginTextAnnotation::value() const
 {
-    return toHTMLTextFormControlElement(element())->value();
+    return downcast<HTMLTextFormControlElement>(element())->value();
 }
 
 bool PDFPluginTextAnnotation::handleEvent(Event* event)
index 103f857..f67518b 100644 (file)
@@ -590,8 +590,8 @@ void PluginView::initializePlugin()
     }
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
-    HTMLPlugInImageElement* plugInImageElement = toHTMLPlugInImageElement(m_pluginElement.get());
-    m_didPlugInStartOffScreen = !m_webPage->plugInIntersectsSearchRect(*plugInImageElement);
+    HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(*m_pluginElement);
+    m_didPlugInStartOffScreen = !m_webPage->plugInIntersectsSearchRect(plugInImageElement);
 #endif
     m_plugin->initialize(this, m_parameters);
     
@@ -1713,8 +1713,8 @@ void PluginView::pluginSnapshotTimerFired()
     ASSERT(m_plugin);
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
-    HTMLPlugInImageElement* plugInImageElement = toHTMLPlugInImageElement(m_pluginElement.get());
-    bool isPlugInOnScreen = m_webPage->plugInIntersectsSearchRect(*plugInImageElement);
+    HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(*m_pluginElement);
+    bool isPlugInOnScreen = m_webPage->plugInIntersectsSearchRect(plugInImageElement);
     bool plugInCameOnScreen = isPlugInOnScreen && m_didPlugInStartOffScreen;
     bool snapshotFound = false;
 #endif
@@ -1747,7 +1747,7 @@ void PluginView::pluginSnapshotTimerFired()
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
     unsigned candidateArea = 0;
     bool noSnapshotFoundAfterMaxRetries = m_countSnapshotRetries == frame()->settings().maximumPlugInSnapshotAttempts() && !isPlugInOnScreen && !snapshotFound;
-    if (m_webPage->plugInIsPrimarySize(*plugInImageElement, candidateArea)
+    if (m_webPage->plugInIsPrimarySize(plugInImageElement, candidateArea)
         && (noSnapshotFoundAfterMaxRetries || plugInCameOnScreen))
         m_pluginElement->setDisplayState(HTMLPlugInElement::Playing);
     else
@@ -1781,12 +1781,12 @@ void PluginView::pluginDidReceiveUserInteraction()
 
     m_didReceiveUserInteraction = true;
 
-    WebCore::HTMLPlugInImageElement* plugInImageElement = toHTMLPlugInImageElement(m_pluginElement.get());
-    String pageOrigin = plugInImageElement->document().page()->mainFrame().document()->baseURL().host();
-    String pluginOrigin = plugInImageElement->loadedUrl().host();
-    String mimeType = plugInImageElement->loadedMimeType();
+    HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(*m_pluginElement);
+    String pageOrigin = plugInImageElement.document().page()->mainFrame().document()->baseURL().host();
+    String pluginOrigin = plugInImageElement.loadedUrl().host();
+    String mimeType = plugInImageElement.loadedMimeType();
 
-    WebProcess::shared().plugInDidReceiveUserInteraction(pageOrigin, pluginOrigin, mimeType, plugInImageElement->document().page()->sessionID());
+    WebProcess::shared().plugInDidReceiveUserInteraction(pageOrigin, pluginOrigin, mimeType, plugInImageElement.document().page()->sessionID());
 }
 
 bool PluginView::shouldCreateTransientPaintingSnapshot() const
index b53dec2..57abf0a 100644 (file)
@@ -628,7 +628,7 @@ PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* plu
     String pageURLString = m_page->mainFrame().loader().documentLoader()->responseURL().string();
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
-    HTMLPlugInImageElement& pluginImageElement = toHTMLPlugInImageElement(*pluginElement);
+    HTMLPlugInImageElement& pluginImageElement = downcast<HTMLPlugInImageElement>(*pluginElement);
     unsigned pluginArea = 0;
     PluginProcessType processType = pluginElement->displayState() == HTMLPlugInElement::WaitingForSnapshot && !(plugInIsPrimarySize(pluginImageElement, pluginArea) && !plugInIntersectsSearchRect(pluginImageElement)) ? PluginProcessTypeSnapshot : PluginProcessTypeNormal;
 #else
index b69f866..b608f91 100644 (file)
@@ -1952,10 +1952,10 @@ void WebPage::stopInteraction()
 
 void WebPage::performActionOnElement(uint32_t action)
 {
-    if (!m_interactionNode || !m_interactionNode->isHTMLElement())
+    if (!m_interactionNode || !is<HTMLElement>(m_interactionNode))
         return;
 
-    HTMLElement* element = toHTMLElement(m_interactionNode.get());
+    HTMLElement* element = downcast<HTMLElement>(m_interactionNode.get());
     if (!element->renderer())
         return;