<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<>(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<>(T&) overload taking a reference in argument to avoid the null check: e.g. “if (is<HTMLDivElement>(*node)) …"</div><div class="">- Do not do an explicit null check on the pointer before calling is<>(T*). “if (node && is<HTMLDivElement>(node))” -> "if (is<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<>(T*) which will correctly cast a null pointer.</div><div class="">- Having a is<>(T*) overload in addition to is<>(T&) 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<>() / downcast<>() 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<>() / downcast<>() 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] <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>