[webkit-dev] Style question: static, protected, or public members

TAMURA, Kent tkent at chromium.org
Tue May 25 03:05:33 PDT 2010


2010/5/25 Darin Adler <darin at apple.com>

> On May 20, 2010, at 8:54 PM, TAMURA, Kent wrote:

> > What's the naming rule for non-const static members?
> >
> > Some classes give "s_" prefixes:
> > WebCore/page/DOMTimer.h:        static double s_minTimerInterval;
> > WebCore/page/GeolocationPositionCache.h:    static int s_instances;
> >
> > FrameView gives "s" prefix:
> > WebCore/page/FrameView.h:    static double sCurrentPaintTimeStamp; //  
> used for detecting decoded resource thrash in the cache
> >
> > Settings gives "g" prefix:
> > WebCore/page/Settings.h:        static bool gShouldPaintNativeControls;
> > WebCore/page/Settings.h:        static bool  
> gShouldUseHighResolutionTimers;

> If we have to use a prefix for this, I suggest the "s_" prefix.

I think "s_" is reasonable.

> > And what about public and protected members?  The style guide has no  
> exceptions for them, so I think they should have m_.  But many classes in  
> WebCore don't use m_ for public members.

> Generally speaking I suggest we do not use the "m_" prefix for the  
> members of structs. And I suggest that classes with public data members  
> be structs instead of classes. Classes that have public data members only  
> for historical reasons should be changed so the data members are not  
> public. We should talk some specific examples.

ok, public data members in classes should be changed.
As for protected data members, many classes use "m_" prefix.
I found protected members without "m_" in HTMLTableCellElement and
HTMLTableColElement.  I guess they are legacy code and we should use "m_"
for protected members too.

--
TAMURA Kent
Software Engineer, Google





More information about the webkit-dev mailing list