<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[173907] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/173907">173907</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2014-09-23 20:31:50 -0700 (Tue, 23 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for is<HTML*Element>() for type checking
https://bugs.webkit.org/show_bug.cgi?id=137015
Reviewed by Benjamin Poulain.
Add support for is<HTML*Element>() for type checking while keeping
support for the legacy toHTML*Element() form until the code base is
ported.
toHTML*Element() helpers are now macros to the new is<HTML*Element>()
type checking helpers.
No new tests, no behavior change.
* dom/Document.cpp:
(WebCore::Document::setTitle):
* dom/Element.cpp:
(WebCore::Element::childShouldCreateRenderer):
* dom/Element.h:
(WebCore::is):
(WebCore::downcast):
(WebCore::isElementOfType): Deleted.
* dom/ElementAncestorIterator.h:
(WebCore::lineageOfType):
* dom/ElementIterator.h:
(WebCore::findElementAncestorOfType):
* dom/ElementTraversal.h:
(WebCore::Traversal<ElementType>::firstChildTemplate):
(WebCore::Traversal<ElementType>::lastChildTemplate):
(WebCore::Traversal<ElementType>::firstWithinTemplate):
(WebCore::Traversal<ElementType>::lastWithinTemplate):
(WebCore::Traversal<ElementType>::nextTemplate):
(WebCore::Traversal<ElementType>::previous):
(WebCore::Traversal<ElementType>::nextSibling):
(WebCore::Traversal<ElementType>::previousSibling):
(WebCore::Traversal<ElementType>::nextSkippingChildren):
* dom/TypedElementDescendantIterator.h:
(WebCore::TypedElementDescendantIteratorAdapter<ElementType>::from):
(WebCore::TypedElementDescendantConstIteratorAdapter<ElementType>::from):
* dom/make_names.pl:
(printTypeHelpers):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCoredomElementAncestorIteratorh">trunk/Source/WebCore/dom/ElementAncestorIterator.h</a></li>
<li><a href="#trunkSourceWebCoredomElementIteratorh">trunk/Source/WebCore/dom/ElementIterator.h</a></li>
<li><a href="#trunkSourceWebCoredomElementTraversalh">trunk/Source/WebCore/dom/ElementTraversal.h</a></li>
<li><a href="#trunkSourceWebCoredomTypedElementDescendantIteratorh">trunk/Source/WebCore/dom/TypedElementDescendantIterator.h</a></li>
<li><a href="#trunkSourceWebCoredommake_namespl">trunk/Source/WebCore/dom/make_names.pl</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/ChangeLog        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2014-09-23 Chris Dumez <cdumez@apple.com>
+
+ Add support for is<HTML*Element>() for type checking
+ https://bugs.webkit.org/show_bug.cgi?id=137015
+
+ Reviewed by Benjamin Poulain.
+
+ Add support for is<HTML*Element>() for type checking while keeping
+ support for the legacy toHTML*Element() form until the code base is
+ ported.
+
+ toHTML*Element() helpers are now macros to the new is<HTML*Element>()
+ type checking helpers.
+
+ No new tests, no behavior change.
+
+ * dom/Document.cpp:
+ (WebCore::Document::setTitle):
+ * dom/Element.cpp:
+ (WebCore::Element::childShouldCreateRenderer):
+ * dom/Element.h:
+ (WebCore::is):
+ (WebCore::downcast):
+ (WebCore::isElementOfType): Deleted.
+ * dom/ElementAncestorIterator.h:
+ (WebCore::lineageOfType):
+ * dom/ElementIterator.h:
+ (WebCore::findElementAncestorOfType):
+ * dom/ElementTraversal.h:
+ (WebCore::Traversal<ElementType>::firstChildTemplate):
+ (WebCore::Traversal<ElementType>::lastChildTemplate):
+ (WebCore::Traversal<ElementType>::firstWithinTemplate):
+ (WebCore::Traversal<ElementType>::lastWithinTemplate):
+ (WebCore::Traversal<ElementType>::nextTemplate):
+ (WebCore::Traversal<ElementType>::previous):
+ (WebCore::Traversal<ElementType>::nextSibling):
+ (WebCore::Traversal<ElementType>::previousSibling):
+ (WebCore::Traversal<ElementType>::nextSkippingChildren):
+ * dom/TypedElementDescendantIterator.h:
+ (WebCore::TypedElementDescendantIteratorAdapter<ElementType>::from):
+ (WebCore::TypedElementDescendantConstIteratorAdapter<ElementType>::from):
+ * dom/make_names.pl:
+ (printTypeHelpers):
+
</ins><span class="cx"> 2014-09-23 Benjamin Poulain <bpoulain@apple.com>
</span><span class="cx">
</span><span class="cx"> The style resolution cache applies properties incorrectly whenever direction != ltr
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/Document.cpp        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -1551,7 +1551,7 @@
</span><span class="cx"> // The DOM API has no method of specifying direction, so assume LTR.
</span><span class="cx"> updateTitle(StringWithDirection(title, LTR));
</span><span class="cx">
</span><del>- if (m_titleElement && isHTMLTitleElement(*m_titleElement))
</del><ins>+ if (m_titleElement && is<HTMLTitleElement>(*m_titleElement))
</ins><span class="cx"> downcast<HTMLTitleElement>(*m_titleElement).setText(title);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/Element.cpp        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -2405,7 +2405,7 @@
</span><span class="cx"> if (child.isSVGElement()) {
</span><span class="cx"> ASSERT(!isSVGElement());
</span><span class="cx"> const SVGElement& childElement = downcast<SVGElement>(child);
</span><del>- return isSVGSVGElement(childElement) && childElement.isValid();
</del><ins>+ return is<SVGSVGElement>(childElement) && childElement.isValid();
</ins><span class="cx"> }
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/Element.h        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -675,10 +675,22 @@
</span><span class="cx"> static bool is(ArgType&);
</span><span class="cx"> };
</span><span class="cx">
</span><del>-// This is needed so that the compiler can deduce the second template parameter (ArgType).
</del><ins>+// Type checking function for Elements, to use before casting with downcast<>().
</ins><span class="cx"> template <typename ExpectedType, typename ArgType>
</span><del>-inline bool isElementOfType(const ArgType& node) { return ElementTypeCastTraits<ExpectedType, const ArgType>::is(node); }
</del><ins>+inline bool is(ArgType& node)
+{
+ static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
+ return ElementTypeCastTraits<const ExpectedType, const ArgType>::is(node);
+}
</ins><span class="cx">
</span><ins>+template <typename ExpectedType, typename ArgType>
+inline bool is(ArgType* node)
+{
+ ASSERT(node);
+ static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
+ return ElementTypeCastTraits<const ExpectedType, const ArgType>::is(*node);
+}
+
</ins><span class="cx"> template <>
</span><span class="cx"> struct ElementTypeCastTraits<const Element, const Node> {
</span><span class="cx"> static bool is(const Node& node) { return node.isElementNode(); }
</span><span class="lines">@@ -694,13 +706,13 @@
</span><span class="cx"> inline typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type downcast(Source& source)
</span><span class="cx"> {
</span><span class="cx"> static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
</span><del>- ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType<const Target>(source));
</del><ins>+ ASSERT_WITH_SECURITY_IMPLICATION(is<Target>(source));
</ins><span class="cx"> return static_cast<typename std::conditional<std::is_const<Source>::value, const Target&, Target&>::type>(source);
</span><span class="cx"> }
</span><span class="cx"> template<typename Target, typename Source> inline typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type downcast(Source* source)
</span><span class="cx"> {
</span><span class="cx"> static_assert(!std::is_base_of<Target, Source>::value, "Unnecessary cast");
</span><del>- ASSERT_WITH_SECURITY_IMPLICATION(!source || isElementOfType<const Target>(*source));
</del><ins>+ ASSERT_WITH_SECURITY_IMPLICATION(!source || is<Target>(*source));
</ins><span class="cx"> return static_cast<typename std::conditional<std::is_const<Source>::value, const Target*, Target*>::type>(source);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementAncestorIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ElementAncestorIterator.h (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ElementAncestorIterator.h        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/ElementAncestorIterator.h        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -184,7 +184,7 @@
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementAncestorIteratorAdapter<ElementType> lineageOfType(Element& first)
</span><span class="cx"> {
</span><del>- if (isElementOfType<const ElementType>(first))
</del><ins>+ if (is<ElementType>(first))
</ins><span class="cx"> return ElementAncestorIteratorAdapter<ElementType>(static_cast<ElementType*>(&first));
</span><span class="cx"> return ancestorsOfType<ElementType>(first);
</span><span class="cx"> }
</span><span class="lines">@@ -192,7 +192,7 @@
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementAncestorConstIteratorAdapter<ElementType> lineageOfType(const Element& first)
</span><span class="cx"> {
</span><del>- if (isElementOfType<const ElementType>(first))
</del><ins>+ if (is<ElementType>(first))
</ins><span class="cx"> return ElementAncestorConstIteratorAdapter<ElementType>(static_cast<const ElementType*>(&first));
</span><span class="cx"> return ancestorsOfType<ElementType>(first);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ElementIterator.h (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ElementIterator.h        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/ElementIterator.h        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -183,12 +183,18 @@
</span><span class="cx"> inline ElementType* findElementAncestorOfType(const Element& current)
</span><span class="cx"> {
</span><span class="cx"> for (Element* ancestor = current.parentElement(); ancestor; ancestor = ancestor->parentElement()) {
</span><del>- if (isElementOfType<const ElementType>(*ancestor))
- return static_cast<ElementType*>(ancestor);
</del><ins>+ if (is<ElementType>(*ancestor))
+ return downcast<ElementType>(ancestor);
</ins><span class="cx"> }
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+template <>
+inline Element* findElementAncestorOfType<Element>(const Element& current)
+{
+ return current.parentElement();
+}
+
</ins><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementIterator<ElementType>& ElementIterator<ElementType>::traverseAncestor()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementTraversalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ElementTraversal.h (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ElementTraversal.h        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/ElementTraversal.h        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -116,9 +116,9 @@
</span><span class="cx"> inline ElementType* Traversal<ElementType>::firstChildTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = current->firstChild();
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = node->nextSibling();
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="lines">@@ -126,9 +126,9 @@
</span><span class="cx"> inline ElementType* Traversal<ElementType>::lastChildTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = current->lastChild();
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = node->previousSibling();
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="lines">@@ -136,9 +136,9 @@
</span><span class="cx"> inline ElementType* Traversal<ElementType>::firstWithinTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = current->firstChild();
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::next(node, current);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="lines">@@ -146,9 +146,9 @@
</span><span class="cx"> inline ElementType* Traversal<ElementType>::lastWithinTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = NodeTraversal::last(current);
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::previous(node, current);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="lines">@@ -156,9 +156,9 @@
</span><span class="cx"> inline ElementType* Traversal<ElementType>::nextTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = NodeTraversal::next(current);
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::next(node);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="lines">@@ -166,63 +166,63 @@
</span><span class="cx"> inline ElementType* Traversal<ElementType>::nextTemplate(CurrentType* current, const Node* stayWithin)
</span><span class="cx"> {
</span><span class="cx"> Node* node = NodeTraversal::next(current, stayWithin);
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::next(node, stayWithin);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementType* Traversal<ElementType>::previous(const Node* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = NodeTraversal::previous(current);
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::previous(node);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementType* Traversal<ElementType>::previous(const Node* current, const Node* stayWithin)
</span><span class="cx"> {
</span><span class="cx"> Node* node = NodeTraversal::previous(current, stayWithin);
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::previous(node, stayWithin);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementType* Traversal<ElementType>::nextSibling(const Node* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = current->nextSibling();
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = node->nextSibling();
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementType* Traversal<ElementType>::previousSibling(const Node* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = current->previousSibling();
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = node->previousSibling();
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementType* Traversal<ElementType>::nextSkippingChildren(const Node* current)
</span><span class="cx"> {
</span><span class="cx"> Node* node = NodeTraversal::nextSkippingChildren(current);
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::nextSkippingChildren(node);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementType* Traversal<ElementType>::nextSkippingChildren(const Node* current, const Node* stayWithin)
</span><span class="cx"> {
</span><span class="cx"> Node* node = NodeTraversal::nextSkippingChildren(current, stayWithin);
</span><del>- while (node && !isElementOfType<const ElementType>(*node))
</del><ins>+ while (node && !is<ElementType>(*node))
</ins><span class="cx"> node = NodeTraversal::nextSkippingChildren(node, stayWithin);
</span><del>- return static_cast<ElementType*>(node);
</del><ins>+ return downcast<ElementType>(node);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename ElementType>
</span></span></pre></div>
<a id="trunkSourceWebCoredomTypedElementDescendantIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/TypedElementDescendantIterator.h (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/TypedElementDescendantIterator.h        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/TypedElementDescendantIterator.h        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -153,8 +153,8 @@
</span><span class="cx"> inline TypedElementDescendantIterator<ElementType> TypedElementDescendantIteratorAdapter<ElementType>::from(Element& descendant)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(descendant.isDescendantOf(&m_root));
</span><del>- if (isElementOfType<const ElementType>(descendant))
- return TypedElementDescendantIterator<ElementType>(m_root, static_cast<ElementType*>(&descendant));
</del><ins>+ if (is<ElementType>(descendant))
+ return TypedElementDescendantIterator<ElementType>(m_root, downcast<ElementType>(&descendant));
</ins><span class="cx"> ElementType* next = Traversal<ElementType>::next(&m_root, &descendant);
</span><span class="cx"> return TypedElementDescendantIterator<ElementType>(m_root, next);
</span><span class="cx"> }
</span><span class="lines">@@ -202,8 +202,8 @@
</span><span class="cx"> inline TypedElementDescendantConstIterator<ElementType> TypedElementDescendantConstIteratorAdapter<ElementType>::from(const Element& descendant) const
</span><span class="cx"> {
</span><span class="cx"> ASSERT(descendant.isDescendantOf(&m_root));
</span><del>- if (isElementOfType<const ElementType>(descendant))
- return TypedElementDescendantConstIterator<ElementType>(m_root, static_cast<const ElementType*>(&descendant));
</del><ins>+ if (is<ElementType>(descendant))
+ return TypedElementDescendantConstIterator<ElementType>(m_root, downcast<ElementType>(&descendant));
</ins><span class="cx"> const ElementType* next = Traversal<ElementType>::next(&m_root, &descendant);
</span><span class="cx"> return TypedElementDescendantConstIterator<ElementType>(m_root, next);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredommake_namespl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/make_names.pl (173906 => 173907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/make_names.pl        2014-09-24 03:17:44 UTC (rev 173906)
+++ trunk/Source/WebCore/dom/make_names.pl        2014-09-24 03:31:50 UTC (rev 173907)
</span><span class="lines">@@ -633,37 +633,34 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> my $class = $parsedTags{$name}{interfaceName};
</span><del>- # FIXME: Rename these helpers to is<*Element>().
- my $checkHelper = "is$class";
-
</del><span class="cx"> print F <<END
</span><span class="cx"> class $class;
</span><del>-void $checkHelper(const $class&); // Catch unnecessary runtime check of type known at compile time.
-void $checkHelper(const $class*); // Catch unnecessary runtime check of type known at compile time.
</del><ins>+template <typename ArgType>
+class ElementTypeCastTraits<const $class, ArgType> {
+public:
+ static bool is(ArgType& node) { return checkTagName(node); }
+private:
</ins><span class="cx"> END
</span><del>- ;
-
- if ($parameters{namespace} eq "HTML" && $parsedTags{$name}{wrapperOnlyIfMediaIsAvailable}) {
- # We need to check for HTMLUnknownElement if it might have been created by the factory.
- print F <<END
-inline bool $checkHelper(const HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasTagName($parameters{namespace}Names::${name}Tag); }
-inline bool $checkHelper(const Node& node) { return node.isHTMLElement() && $checkHelper(toHTMLElement(node)); }
</del><ins>+ ;
+ 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)); }
</ins><span class="cx"> END
</span><del>- ;
- } else {
- print F <<END
-inline bool $checkHelper(const $parameters{namespace}Element& element) { return element.hasTagName($parameters{namespace}Names::${name}Tag); }
-inline bool $checkHelper(const Node& node) { return node.hasTagName($parameters{namespace}Names::${name}Tag); }
</del><ins>+ ;
+ } else {
+ print F <<END
+ static bool checkTagName(const $parameters{namespace}Element& element) { return element.hasTagName($parameters{namespace}Names::${name}Tag); }
+ static bool checkTagName(const Node& node) { return node.hasTagName($parameters{namespace}Names::${name}Tag); }
</ins><span class="cx"> END
</span><del>- ;
- }
- print F <<END
-inline bool $checkHelper(const $parameters{namespace}Element* element) { ASSERT(element); return $checkHelper(*element); }
-inline bool $checkHelper(const Node* node) { ASSERT(node); return $checkHelper(*node); }
-template <typename ArgType>
-struct ElementTypeCastTraits<const $class, ArgType> {
- static bool is(ArgType& node) { return $checkHelper(node); }
</del><ins>+ ;
+ }
+ print F <<END
</ins><span class="cx"> };
</span><ins>+
+// FIXME: Remove these macros once the code has been ported to using
+// is<*Element>().
+#define is$class(x) WebCore::is<WebCore::$class>(x)
</ins><span class="cx"> END
</span><span class="cx"> ;
</span><span class="cx"> print F "\n";
</span></span></pre>
</div>
</div>
</body>
</html>