[webkit-dev] Coding style change - Indentation of forward declarations in headers

Brady Eidson beidson at apple.com
Mon Nov 1 09:40:59 PDT 2010


Currently, the style guidelines specify "The contents of an outermost namespace block (and any nested namespaces with the same scope) should not be indented."

I like this rule - *most* of the time.

A common pattern throughout the project is forward declaring types from different namespaces in headers.  And traditionally, we've indented these declarations.

While it's not difficult to find this pattern in WebCore itself, it is quite pervasive in the WebKit layers where WebCore:: types often need to be forward declared.  To be clear, I'm talking about situations like this from WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm:

namespace WebCore {
    class AuthenticationChallenge;
    class CachedFrame;
    class HistoryItem;
    class ProtectionSpace;
    class ResourceLoader;
    class ResourceRequest;
}

class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
    ...
}

...which I think is far superior in the header to:

namespace WebCore {
class AuthenticationChallenge;
class CachedFrame;
class HistoryItem;
class ProtectionSpace;
class ResourceLoader;
class ResourceRequest;
}

class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
    ...
}

I think this pattern increases readability of forward declarations in headers and we should change the style guidelines to specify its continued use.

Thoughts?

~Brady
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20101101/c461f8e6/attachment.html>


More information about the webkit-dev mailing list