Add initial is<>() / downcast<>() support for any type of Nodes
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Sep 2014 03:50:40 +0000 (03:50 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Sep 2014 03:50:40 +0000 (03:50 +0000)
commit8e76a525eb2996a1a1a77579c6e17c7fbc3c5a95
tree58b94d5ee199b13da0660334ecd06d47cc329976
parent8a3453967c41fbce7375acdf5814acba1efd0bf0
Add initial is<>() / downcast<>() support for any type of Nodes
https://bugs.webkit.org/show_bug.cgi?id=137056

Reviewed by Benjamin Poulain.

Source/WebCore:

Add initial is<>() / downcast<>() support for any type of Nodes, not
just Elements by:
- Moving the is<>() / downcast<>() declarations from Element.h to
  Node.h
- Introducing a SPECIALIZE_TYPE_TRAITS_*() macro that generates the
  needed template specializations for is<>() / downcast<>() to work.
  This macro will replace NODE_TYPE_CASTS() entirely once the code base
  is fully ported.

This patch makes use of SPECIALIZE_TYPE_TRAITS_*() macro for
HTMLFormControlElement, that is an HTMLElement for which the template
specializations cannot be automatically generated because it requires
special handling.

This patch also makes use of SPECIALIZE_TYPE_TRAITS_*() macro for
DocumentFragment to show that it can be used for non-Element Nodes.

No new tests, no behavior change.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isReadOnly):
(WebCore::AccessibilityNodeObject::isRequired):
(WebCore::AccessibilityNodeObject::isControl):
* css/SelectorCheckerTestFunctions.h:
(WebCore::isAutofilled):
(WebCore::isDisabled):
(WebCore::isEnabled):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::canShareStyleWithElement):
(WebCore::StyleResolver::adjustRenderStyle):
* dom/Document.cpp:
(WebCore::Document::importNode):
(WebCore::Document::setFocusedElement):
* dom/DocumentFragment.h:
(WebCore::isDocumentFragment):
* dom/Element.cpp:
(WebCore::Element::focus):
* dom/Element.h:
(WebCore::is): Deleted.
(WebCore::downcast): Deleted.
* dom/Node.h:
(WebCore::is):
(WebCore::downcast):
* dom/make_names.pl:
(printTypeHelpers):
* editing/FrameSelection.cpp:
(WebCore::scanForForm):
* editing/TextIterator.cpp:
(WebCore::isRendererReplacedElement):
* html/FormAssociatedElement.h:
* html/HTMLElement.h:
* html/HTMLFieldSetElement.cpp:
(WebCore::updateFromControlElementsAncestorDisabledStateUnder):
(WebCore::HTMLFieldSetElement::refreshElementsIfNeeded):
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::enclosingFormControlElement):
* html/HTMLFormControlElement.h:
(WebCore::isHTMLFormControlElement):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::submitImplicitly):
(WebCore::submitElementFromEvent):
(WebCore::HTMLFormElement::validateInteractively):
(WebCore::HTMLFormElement::submit):
(WebCore::HTMLFormElement::reset):
(WebCore::HTMLFormElement::formElementIndex):
(WebCore::HTMLFormElement::defaultButton):
(WebCore::HTMLFormElement::checkInvalidControlsAndCollectUnhandled):
(WebCore::HTMLFormElement::documentDidResumeFromPageCache):
* html/HTMLMediaElement.h:
* html/HTMLPlugInImageElement.h:
* html/HTMLSummaryElement.cpp:
(WebCore::isClickableControl):
* html/LabelableElement.h:
* html/RadioNodeList.cpp:
(WebCore::RadioNodeList::checkElementMatchesRadioNodeListFilter):
(WebCore::RadioNodeList::elementMatches):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::findFosterSite):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::disallowTelephoneNumberParsing):
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* mathml/MathMLElement.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate):
* page/Frame.cpp:
(WebCore::Frame::searchForLabelsBeforeElement):
* rendering/RenderButton.cpp:
(WebCore::RenderButton::formControlElement):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::resize):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isReadOnlyControl):
* svg/SVGElement.h:
* svg/SVGFilterPrimitiveStandardAttributes.h:
* svg/animation/SVGSMILElement.h:

Source/WebKit/mac:

Use is<HTMLFormControlElement>() / downcast<HTMLFormControlElement>()
instead of isFormControlElement() / toHTMLFormControlElement().

* WebView/WebHTMLRepresentation.mm:
(searchForLabelsBeforeElement):

Source/WebKit/win:

Use is<HTMLFormControlElement>() / downcast<HTMLFormControlElement>()
instead of isFormControlElement() / toHTMLFormControlElement().

* WebFrame.cpp:
(WebFrame::elementWithName):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173944 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/css/SelectorCheckerTestFunctions.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentFragment.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Node.h
Source/WebCore/dom/make_names.pl
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/html/FormAssociatedElement.h
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLFieldSetElement.cpp
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/html/HTMLSummaryElement.cpp
Source/WebCore/html/LabelableElement.h
Source/WebCore/html/RadioNodeList.cpp
Source/WebCore/html/parser/HTMLConstructionSite.cpp
Source/WebCore/html/parser/HTMLTreeBuilder.cpp
Source/WebCore/loader/FormSubmission.cpp
Source/WebCore/mathml/MathMLElement.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/rendering/RenderButton.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/svg/SVGElement.h
Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h
Source/WebCore/svg/animation/SVGSMILElement.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebFrame.cpp