<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I would like to bring attention to a behavior change I have just landed [1]. The is&lt;&gt;(T*) type checking function is now doing a null-check on the pointer argument instead of simply asserting that the pointer argument should not be null.</div><div class=""><br class=""></div><div class="">Please keep this in mind in your future patches:</div><div class="">- If you know the pointer cannot be null (because a null check was done earlier in the function), then call the is&lt;&gt;(T&amp;) overload taking a reference in argument to avoid the null check: e.g. “if (is&lt;HTMLDivElement&gt;(*node)) …"</div><div class="">- Do not do an explicit null check on the pointer before calling&nbsp;is&lt;&gt;(T*). “if (node &amp;&amp; is&lt;HTMLDivElement&gt;(node))” -&gt; "if (is&lt;HTMLDivElement(node))"</div><div class=""><br class=""></div><div class="">This change was made because:</div><div class="">- It simplifies the code a bit as it avoids a lot of explicit null checks.</div><div class="">- It is more consistent with downcast&lt;&gt;(T*) which will correctly cast a null pointer.</div><div class="">- Having a is&lt;&gt;(T*) overload in addition to is&lt;&gt;(T&amp;) was previously only helpful to avoid having to dereference the pointer. Dereferencing is just one ‘*’ character and doesn’t decrease code readability much IMHO. However, getting rid of a lot of explicit null checks does simplify the code quite a bit.</div><div class=""><br class=""></div><div class="">FYI, all Node subclasses should now support is&lt;&gt;() / downcast&lt;&gt;() already. I am in the process of porting non-Node classes over as well for consistency (WorkerGlobalScope class, File class and Event subclasses were already ported for e.g.).</div><div class="">If you try to use is&lt;&gt;() / downcast&lt;&gt;() for a class that doesn’t support it yet, you should now get a clear build error (instead of the obscure linking error we would get previously).</div><div class=""><br class=""></div><div class="">Kr,<br class=""><div apple-content-edited="true" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">--</div><div class="">Chris Dumez - Apple Inc.</div><div class="">Cupertino, CA</div><div class=""><br class=""></div></div>[1] &nbsp;<a href="http://trac.webkit.org/changeset/174225" style="white-space: pre-wrap; color: rgb(102, 51, 102);" class="">http://trac.webkit.org/changeset/174225</a></div></div></body></html>