[webkit-dev] Type cast by using toFoo()

Gyuyoung Kim gyuyoung.kim at webkit.org
Mon Sep 30 03:39:01 PDT 2013

Hello WebKittens,

I have focused on using toFoo() for SVG and CSS instead of using
static_cast<>.  Because I think there are some advantages when we use it.

  - Bad type cast can be detected by using ASSERTION in toFoo(). The
toFoo() function has an ASSERTION to check if source value is a proper
super class.
  - Unnecessary local variables can be removed. There are some local
variables, which are only used once in WebKit. In those cases, we don’t
need to use a local variable. Besides, we can remove unnecessary ASSERTION
because toFoo() already has it.
  - I believe toFoo() can improve code readability.

Currently, HTML, SVG Elements support toHTML|SVGFooElement() and CSSValue
also starts to support toCSSFooValue(). Please check if there is toFoo()
when you need to use static_cast<> in HTML, SVG and CSS module.

Finally I plan to add this toFoo() policy to the WebKit style checker.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130930/5410bef9/attachment.html>

More information about the webkit-dev mailing list