<!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&lt;HTML*Element&gt;() for type checking
https://bugs.webkit.org/show_bug.cgi?id=137015

Reviewed by Benjamin Poulain.

Add support for is&lt;HTML*Element&gt;() 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&lt;HTML*Element&gt;()
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&lt;ElementType&gt;::firstChildTemplate):
(WebCore::Traversal&lt;ElementType&gt;::lastChildTemplate):
(WebCore::Traversal&lt;ElementType&gt;::firstWithinTemplate):
(WebCore::Traversal&lt;ElementType&gt;::lastWithinTemplate):
(WebCore::Traversal&lt;ElementType&gt;::nextTemplate):
(WebCore::Traversal&lt;ElementType&gt;::previous):
(WebCore::Traversal&lt;ElementType&gt;::nextSibling):
(WebCore::Traversal&lt;ElementType&gt;::previousSibling):
(WebCore::Traversal&lt;ElementType&gt;::nextSkippingChildren):
* dom/TypedElementDescendantIterator.h:
(WebCore::TypedElementDescendantIteratorAdapter&lt;ElementType&gt;::from):
(WebCore::TypedElementDescendantConstIteratorAdapter&lt;ElementType&gt;::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  &lt;cdumez@apple.com&gt;
+
+        Add support for is&lt;HTML*Element&gt;() for type checking
+        https://bugs.webkit.org/show_bug.cgi?id=137015
+
+        Reviewed by Benjamin Poulain.
+
+        Add support for is&lt;HTML*Element&gt;() 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&lt;HTML*Element&gt;()
+        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&lt;ElementType&gt;::firstChildTemplate):
+        (WebCore::Traversal&lt;ElementType&gt;::lastChildTemplate):
+        (WebCore::Traversal&lt;ElementType&gt;::firstWithinTemplate):
+        (WebCore::Traversal&lt;ElementType&gt;::lastWithinTemplate):
+        (WebCore::Traversal&lt;ElementType&gt;::nextTemplate):
+        (WebCore::Traversal&lt;ElementType&gt;::previous):
+        (WebCore::Traversal&lt;ElementType&gt;::nextSibling):
+        (WebCore::Traversal&lt;ElementType&gt;::previousSibling):
+        (WebCore::Traversal&lt;ElementType&gt;::nextSkippingChildren):
+        * dom/TypedElementDescendantIterator.h:
+        (WebCore::TypedElementDescendantIteratorAdapter&lt;ElementType&gt;::from):
+        (WebCore::TypedElementDescendantConstIteratorAdapter&lt;ElementType&gt;::from):
+        * dom/make_names.pl:
+        (printTypeHelpers):
+
</ins><span class="cx"> 2014-09-23  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</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 &amp;&amp; isHTMLTitleElement(*m_titleElement))
</del><ins>+    if (m_titleElement &amp;&amp; is&lt;HTMLTitleElement&gt;(*m_titleElement))
</ins><span class="cx">         downcast&lt;HTMLTitleElement&gt;(*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&amp; childElement = downcast&lt;SVGElement&gt;(child);
</span><del>-        return isSVGSVGElement(childElement) &amp;&amp; childElement.isValid();
</del><ins>+        return is&lt;SVGSVGElement&gt;(childElement) &amp;&amp; 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&amp;);
</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&lt;&gt;().
</ins><span class="cx"> template &lt;typename ExpectedType, typename ArgType&gt;
</span><del>-inline bool isElementOfType(const ArgType&amp; node) { return ElementTypeCastTraits&lt;ExpectedType, const ArgType&gt;::is(node); }
</del><ins>+inline bool is(ArgType&amp; node)
+{
+    static_assert(!std::is_base_of&lt;ExpectedType, ArgType&gt;::value, &quot;Unnecessary type check&quot;);
+    return ElementTypeCastTraits&lt;const ExpectedType, const ArgType&gt;::is(node);
+}
</ins><span class="cx"> 
</span><ins>+template &lt;typename ExpectedType, typename ArgType&gt;
+inline bool is(ArgType* node)
+{
+    ASSERT(node);
+    static_assert(!std::is_base_of&lt;ExpectedType, ArgType&gt;::value, &quot;Unnecessary type check&quot;);
+    return ElementTypeCastTraits&lt;const ExpectedType, const ArgType&gt;::is(*node);
+}
+
</ins><span class="cx"> template &lt;&gt;
</span><span class="cx"> struct ElementTypeCastTraits&lt;const Element, const Node&gt; {
</span><span class="cx">     static bool is(const Node&amp; node) { return node.isElementNode(); }
</span><span class="lines">@@ -694,13 +706,13 @@
</span><span class="cx"> inline typename std::conditional&lt;std::is_const&lt;Source&gt;::value, const Target&amp;, Target&amp;&gt;::type downcast(Source&amp; source)
</span><span class="cx"> {
</span><span class="cx">     static_assert(!std::is_base_of&lt;Target, Source&gt;::value, &quot;Unnecessary cast&quot;);
</span><del>-    ASSERT_WITH_SECURITY_IMPLICATION(isElementOfType&lt;const Target&gt;(source));
</del><ins>+    ASSERT_WITH_SECURITY_IMPLICATION(is&lt;Target&gt;(source));
</ins><span class="cx">     return static_cast&lt;typename std::conditional&lt;std::is_const&lt;Source&gt;::value, const Target&amp;, Target&amp;&gt;::type&gt;(source);
</span><span class="cx"> }
</span><span class="cx"> template&lt;typename Target, typename Source&gt; inline typename std::conditional&lt;std::is_const&lt;Source&gt;::value, const Target*, Target*&gt;::type downcast(Source* source)
</span><span class="cx"> {
</span><span class="cx">     static_assert(!std::is_base_of&lt;Target, Source&gt;::value, &quot;Unnecessary cast&quot;);
</span><del>-    ASSERT_WITH_SECURITY_IMPLICATION(!source || isElementOfType&lt;const Target&gt;(*source));
</del><ins>+    ASSERT_WITH_SECURITY_IMPLICATION(!source || is&lt;Target&gt;(*source));
</ins><span class="cx">     return static_cast&lt;typename std::conditional&lt;std::is_const&lt;Source&gt;::value, const Target*, Target*&gt;::type&gt;(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 &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementAncestorIteratorAdapter&lt;ElementType&gt; lineageOfType(Element&amp; first)
</span><span class="cx"> {
</span><del>-    if (isElementOfType&lt;const ElementType&gt;(first))
</del><ins>+    if (is&lt;ElementType&gt;(first))
</ins><span class="cx">         return ElementAncestorIteratorAdapter&lt;ElementType&gt;(static_cast&lt;ElementType*&gt;(&amp;first));
</span><span class="cx">     return ancestorsOfType&lt;ElementType&gt;(first);
</span><span class="cx"> }
</span><span class="lines">@@ -192,7 +192,7 @@
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementAncestorConstIteratorAdapter&lt;ElementType&gt; lineageOfType(const Element&amp; first)
</span><span class="cx"> {
</span><del>-    if (isElementOfType&lt;const ElementType&gt;(first))
</del><ins>+    if (is&lt;ElementType&gt;(first))
</ins><span class="cx">         return ElementAncestorConstIteratorAdapter&lt;ElementType&gt;(static_cast&lt;const ElementType*&gt;(&amp;first));
</span><span class="cx">     return ancestorsOfType&lt;ElementType&gt;(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&amp; current)
</span><span class="cx"> {
</span><span class="cx">     for (Element* ancestor = current.parentElement(); ancestor; ancestor = ancestor-&gt;parentElement()) {
</span><del>-        if (isElementOfType&lt;const ElementType&gt;(*ancestor))
-            return static_cast&lt;ElementType*&gt;(ancestor);
</del><ins>+        if (is&lt;ElementType&gt;(*ancestor))
+            return downcast&lt;ElementType&gt;(ancestor);
</ins><span class="cx">     }
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;&gt;
+inline Element* findElementAncestorOfType&lt;Element&gt;(const Element&amp; current)
+{
+    return current.parentElement();
+}
+
</ins><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementIterator&lt;ElementType&gt;&amp; ElementIterator&lt;ElementType&gt;::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&lt;ElementType&gt;::firstChildTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = current-&gt;firstChild();
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = node-&gt;nextSibling();
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="lines">@@ -126,9 +126,9 @@
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::lastChildTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = current-&gt;lastChild();
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = node-&gt;previousSibling();
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="lines">@@ -136,9 +136,9 @@
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::firstWithinTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = current-&gt;firstChild();
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::next(node, current);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="lines">@@ -146,9 +146,9 @@
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::lastWithinTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = NodeTraversal::last(current);
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::previous(node, current);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="lines">@@ -156,9 +156,9 @@
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::nextTemplate(CurrentType* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = NodeTraversal::next(current);
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::next(node);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="lines">@@ -166,63 +166,63 @@
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::nextTemplate(CurrentType* current, const Node* stayWithin)
</span><span class="cx"> {
</span><span class="cx">     Node* node = NodeTraversal::next(current, stayWithin);
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::next(node, stayWithin);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::previous(const Node* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = NodeTraversal::previous(current);
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::previous(node);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::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 &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::previous(node, stayWithin);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::nextSibling(const Node* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = current-&gt;nextSibling();
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = node-&gt;nextSibling();
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::previousSibling(const Node* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = current-&gt;previousSibling();
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = node-&gt;previousSibling();
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::nextSkippingChildren(const Node* current)
</span><span class="cx"> {
</span><span class="cx">     Node* node = NodeTraversal::nextSkippingChildren(current);
</span><del>-    while (node &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::nextSkippingChildren(node);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</span><span class="cx"> inline ElementType* Traversal&lt;ElementType&gt;::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 &amp;&amp; !isElementOfType&lt;const ElementType&gt;(*node))
</del><ins>+    while (node &amp;&amp; !is&lt;ElementType&gt;(*node))
</ins><span class="cx">         node = NodeTraversal::nextSkippingChildren(node, stayWithin);
</span><del>-    return static_cast&lt;ElementType*&gt;(node);
</del><ins>+    return downcast&lt;ElementType&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename ElementType&gt;
</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&lt;ElementType&gt; TypedElementDescendantIteratorAdapter&lt;ElementType&gt;::from(Element&amp; descendant)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(descendant.isDescendantOf(&amp;m_root));
</span><del>-    if (isElementOfType&lt;const ElementType&gt;(descendant))
-        return TypedElementDescendantIterator&lt;ElementType&gt;(m_root, static_cast&lt;ElementType*&gt;(&amp;descendant));
</del><ins>+    if (is&lt;ElementType&gt;(descendant))
+        return TypedElementDescendantIterator&lt;ElementType&gt;(m_root, downcast&lt;ElementType&gt;(&amp;descendant));
</ins><span class="cx">     ElementType* next = Traversal&lt;ElementType&gt;::next(&amp;m_root, &amp;descendant);
</span><span class="cx">     return TypedElementDescendantIterator&lt;ElementType&gt;(m_root, next);
</span><span class="cx"> }
</span><span class="lines">@@ -202,8 +202,8 @@
</span><span class="cx"> inline TypedElementDescendantConstIterator&lt;ElementType&gt; TypedElementDescendantConstIteratorAdapter&lt;ElementType&gt;::from(const Element&amp; descendant) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(descendant.isDescendantOf(&amp;m_root));
</span><del>-    if (isElementOfType&lt;const ElementType&gt;(descendant))
-        return TypedElementDescendantConstIterator&lt;ElementType&gt;(m_root, static_cast&lt;const ElementType*&gt;(&amp;descendant));
</del><ins>+    if (is&lt;ElementType&gt;(descendant))
+        return TypedElementDescendantConstIterator&lt;ElementType&gt;(m_root, downcast&lt;ElementType&gt;(&amp;descendant));
</ins><span class="cx">     const ElementType* next = Traversal&lt;ElementType&gt;::next(&amp;m_root, &amp;descendant);
</span><span class="cx">     return TypedElementDescendantConstIterator&lt;ElementType&gt;(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&lt;*Element&gt;().
-        my $checkHelper = &quot;is$class&quot;;
-
</del><span class="cx">         print F &lt;&lt;END
</span><span class="cx"> class $class;
</span><del>-void $checkHelper(const $class&amp;); // 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 &lt;typename ArgType&gt;
+class ElementTypeCastTraits&lt;const $class, ArgType&gt; {
+public:
+    static bool is(ArgType&amp; node) { return checkTagName(node); }
+private:
</ins><span class="cx"> END
</span><del>-        ;
-
-        if ($parameters{namespace} eq &quot;HTML&quot; &amp;&amp; $parsedTags{$name}{wrapperOnlyIfMediaIsAvailable}) {
-            # We need to check for HTMLUnknownElement if it might have been created by the factory.
-            print F &lt;&lt;END
-inline bool $checkHelper(const HTMLElement&amp; element) { return !element.isHTMLUnknownElement() &amp;&amp; element.hasTagName($parameters{namespace}Names::${name}Tag); }
-inline bool $checkHelper(const Node&amp; node) { return node.isHTMLElement() &amp;&amp; $checkHelper(toHTMLElement(node)); }
</del><ins>+       ;
+       if ($parameters{namespace} eq &quot;HTML&quot; &amp;&amp; $parsedTags{$name}{wrapperOnlyIfMediaIsAvailable}) {
+           print F &lt;&lt;END
+    static bool checkTagName(const HTMLElement&amp; element) { return !element.isHTMLUnknownElement() &amp;&amp; element.hasTagName($parameters{namespace}Names::${name}Tag); }
+    static bool checkTagName(const Node&amp; node) { return node.isHTMLElement() &amp;&amp; checkTagName(toHTMLElement(node)); }
</ins><span class="cx"> END
</span><del>-            ;
-        } else {
-            print F &lt;&lt;END
-inline bool $checkHelper(const $parameters{namespace}Element&amp; element) { return element.hasTagName($parameters{namespace}Names::${name}Tag); }
-inline bool $checkHelper(const Node&amp; node) { return node.hasTagName($parameters{namespace}Names::${name}Tag); }
</del><ins>+           ;
+       } else {
+           print F &lt;&lt;END
+    static bool checkTagName(const $parameters{namespace}Element&amp; element) { return element.hasTagName($parameters{namespace}Names::${name}Tag); }
+    static bool checkTagName(const Node&amp; node) { return node.hasTagName($parameters{namespace}Names::${name}Tag); }
</ins><span class="cx"> END
</span><del>-            ;
-        }
-        print F &lt;&lt;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 &lt;typename ArgType&gt;
-struct ElementTypeCastTraits&lt;const $class, ArgType&gt; {
-    static bool is(ArgType&amp; node) { return $checkHelper(node); }
</del><ins>+           ;
+       }
+       print F &lt;&lt;END
</ins><span class="cx"> };
</span><ins>+
+// FIXME: Remove these macros once the code has been ported to using
+// is&lt;*Element&gt;().
+#define is$class(x) WebCore::is&lt;WebCore::$class&gt;(x)
</ins><span class="cx"> END
</span><span class="cx">         ;
</span><span class="cx">         print F &quot;\n&quot;;
</span></span></pre>
</div>
</div>

</body>
</html>