<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>32137</bug_id>
          
          <creation_ts>2009-12-03 16:00:01 -0800</creation_ts>
          <short_desc>[Website] Style guide should allow indentation of _nested_ namespaces</short_desc>
          <delta_ts>2010-02-02 15:18:33 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Website</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jens Alfke">jens</reporter>
          <assigned_to name="Jens Alfke">jens</assigned_to>
          <cc>cjerdonek</cc>
    
    <cc>eric</cc>
    
    <cc>hamaji</cc>
    
    <cc>levin</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>168584</commentid>
    <comment_count>0</comment_count>
    <who name="Jens Alfke">jens</who>
    <bug_when>2009-12-03 16:00:01 -0800</bug_when>
    <thetext>At http://webkit.org/coding/coding-style.html, rule #3 says &quot;Code inside a namespace should not be indented&quot;. This is obviously because most source files have a namespace wrapped around them and indenting the whole file is pointless.

However, this shouldn&apos;t apply to _nested_ namespace declarations, which are a lot shorter, and by normal C/C++ rules should be indented to distinguish their scope. An example from a patch I&apos;m currently getting reviewed:

// HTTPHeaderMap.h
namespace WebCore {

   class HTTPHeaderMap : public HashMap&lt;AtomicString, String, CaseFoldingHash&gt; {
	...
	...
   };

   namespace HTTPHeaders {
       extern const char* const Accept;
       extern const char* const Authorization;
       ...
       extern const char* const UserAgent;
   }
}

This would look strange if the contents of HTTPHeaders weren&apos;t indented. Especially since if HTTPHeaders were made a class instead (which I almost decided to do) the style guide _would_ say to indent it.

   namespace HTTPHeaders {
   extern const char* const Accept;
   extern const char* const Authorization;
   ...
   extern const char* const UserAgent;
   }

So I propose to edit the rule to read:

3. Code inside a namespace that takes up the entire file (apart from its #includes) should not be indented. However, if there are nested namespaces, their contents should be indented normally.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168590</commentid>
    <comment_count>1</comment_count>
      <attachid>44276</attachid>
    <who name="Jens Alfke">jens</who>
    <bug_when>2009-12-03 16:10:30 -0800</bug_when>
    <thetext>Created attachment 44276
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168591</commentid>
    <comment_count>2</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2009-12-03 16:11:56 -0800</bug_when>
    <thetext>style-queue ran check-webkit-style on attachment 44276 without any errors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168599</commentid>
    <comment_count>3</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-12-03 17:12:24 -0800</bug_when>
    <thetext>We&apos;ll have to fix check-webkit-style too if we&apos;re changing the guidelines.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168601</commentid>
    <comment_count>4</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2009-12-03 17:19:47 -0800</bug_when>
    <thetext>I&apos;ll work on a fix fir check-webkit-style.  This issue is a bit rare so we won&apos;t get a lot of cases with issues anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168628</commentid>
    <comment_count>5</comment_count>
    <who name="Chris Jerdonek">cjerdonek</who>
    <bug_when>2009-12-03 20:21:52 -0800</bug_when>
    <thetext>(In reply to comment #1)
&gt; Created an attachment (id=44276) [details]
&gt; patch

&gt; -&lt;li&gt;Code inside a namespace should not be indented.
&gt; +&lt;li&gt;Code inside a namespace that takes up the entire file (apart from its
&gt; +#includes) should not be indented. However, if there are nested namespaces,
&gt; +their contents should be indented normally.

Note that there are non-nested namespaces that don&apos;t take up the entire file.  For example--

namespace JSC {
...
}

namespace WTF {
...
}

So I think you should use a word like &quot;outermost&quot;.

Also, I think consecutive declarations should be treated as a single namespace for the purposes of this rule, rather than as a nesting.  For example--

namespace JSC { namespace WREC {

(This actually occurs in the code base.)

I mentioned these points in an e-mail to the group last month:

https://lists.webkit.org/pipermail/webkit-dev/2009-November/010521.html

Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168792</commentid>
    <comment_count>6</comment_count>
    <who name="Jens Alfke">jens</who>
    <bug_when>2009-12-04 09:20:51 -0800</bug_when>
    <thetext>How does this sound:

&quot;When one or more &lt;code&gt;namespace&lt;/code&gt; blocks together take up the entire file (apart from its
#includes), their contents should not be indented. However, if there are nested namespaces that occupy only a portion of the file, their contents should be indented normally.&quot;

Thumbs-up and I&apos;ll roll a new patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168798</commentid>
    <comment_count>7</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2009-12-04 09:30:24 -0800</bug_when>
    <thetext>&quot;take up the entire file&quot; seems mildly subjective and it needs multiple exceptions: comments, #include&apos;s, #ifdef, #endif, #define, using (see JavaScriptCore/wtf/RefCounted.h)

I think outermost namespace is a simpler concept and the right idea.  Consecutive namespaces is the right thing for the other idea.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168800</commentid>
    <comment_count>8</comment_count>
    <who name="Jens Alfke">jens</who>
    <bug_when>2009-12-04 09:34:40 -0800</bug_when>
    <thetext>Well, I was considering the possibility of files that are mostly non-namespaced but have a short namespace in them; in that case it would make sense to indent the namespace. But maybe that doesn&apos;t appear anywhere in WebKit.

How about:

&quot;The contents of an outermost &lt;code&gt;namespace&lt;/code&gt; block should not be indented. However, if there are nested namespaces that occupy only a portion of the file, their contents should be indented normally.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168871</commentid>
    <comment_count>9</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2009-12-04 12:18:31 -0800</bug_when>
    <thetext>How about this?

&quot;The contents of an outermost &lt;code&gt;namespace&lt;/code&gt; (and any nested namespaces with the same scope) block should not be indented. The contents of other namespaces should be indented.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168902</commentid>
    <comment_count>10</comment_count>
    <who name="Jens Alfke">jens</who>
    <bug_when>2009-12-04 13:19:19 -0800</bug_when>
    <thetext>It wasn&apos;t intuitively clear to me what &quot;with the same scope&quot; means, but I think this is about as clear as we&apos;re going to be able to get it :) I&apos;ll update the patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168903</commentid>
    <comment_count>11</comment_count>
      <attachid>44329</attachid>
    <who name="Jens Alfke">jens</who>
    <bug_when>2009-12-04 13:24:44 -0800</bug_when>
    <thetext>Created attachment 44329
patch 2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>168905</commentid>
    <comment_count>12</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2009-12-04 13:27:34 -0800</bug_when>
    <thetext>style-queue ran check-webkit-style on attachment 44329 without any errors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172969</commentid>
    <comment_count>13</comment_count>
      <attachid>44329</attachid>
    <who name="David Levin">levin</who>
    <bug_when>2009-12-17 15:24:38 -0800</bug_when>
    <thetext>Comment on attachment 44329
patch 2 

Missing ChangeLog. Please add one and feel free to submit (since this issue has already been discussed on WebKit-dev in the past).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>178032</commentid>
    <comment_count>14</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-01-06 23:39:30 -0800</bug_when>
    <thetext>Hmm.  Looks like this one got stalled at commit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>187174</commentid>
    <comment_count>15</comment_count>
    <who name="Jens Alfke">jens</who>
    <bug_when>2010-02-02 15:18:33 -0800</bug_when>
    <thetext>Sorry this fell on the floor ... committed r54258.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>44276</attachid>
            <date>2009-12-03 16:10:30 -0800</date>
            <delta_ts>2009-12-04 13:24:44 -0800</delta_ts>
            <desc>patch</desc>
            <filename>textmate stdin rFw9eP.txt</filename>
            <type>text/plain</type>
            <size>857</size>
            <attacher name="Jens Alfke">jens</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYktpdFNpdGUvY29kaW5nL2NvZGluZy1zdHlsZS5odG1sIGIvV2ViS2l0
U2l0ZS9jb2RpbmcvY29kaW5nLXN0eWxlLmh0bWwKaW5kZXggNmJlMGFlNi4uYjg3YzEzYiAxMDA2
NDQKLS0tIGEvV2ViS2l0U2l0ZS9jb2RpbmcvY29kaW5nLXN0eWxlLmh0bWwKKysrIGIvV2ViS2l0
U2l0ZS9jb2RpbmcvY29kaW5nLXN0eWxlLmh0bWwKQEAgLTQ1LDcgKzQ1LDkgQEAgaW50IG1haW4o
KQogfQogPC9wcmU+CiA8L2xpPgotPGxpPkNvZGUgaW5zaWRlIGEgbmFtZXNwYWNlIHNob3VsZCBu
b3QgYmUgaW5kZW50ZWQuCis8bGk+Q29kZSBpbnNpZGUgYSBuYW1lc3BhY2UgdGhhdCB0YWtlcyB1
cCB0aGUgZW50aXJlIGZpbGUgKGFwYXJ0IGZyb20gaXRzCisjaW5jbHVkZXMpIHNob3VsZCBub3Qg
YmUgaW5kZW50ZWQuIEhvd2V2ZXIsIGlmIHRoZXJlIGFyZSBuZXN0ZWQgbmFtZXNwYWNlcywKK3Ro
ZWlyIGNvbnRlbnRzIHNob3VsZCBiZSBpbmRlbnRlZCBub3JtYWxseS4KIDxoNCBjbGFzcz0icmln
aHQiPlJpZ2h0OjwvaDQ+CiA8cHJlIGNsYXNzPSJjb2RlIj4KIC8vIERvY3VtZW50LmgKQEAgLTU2
LDYgKzU4LDEwIEBAIGNsYXNzIERvY3VtZW50IHsKICAgICAuLi4KIH07CiAKK25hbWVzcGFjZSBO
ZXN0ZWROYW1lc3BhY2UgeworICAgIC4uLgorfQorCiB9IC8vIG5hbWVzcGFjZSBXZWJDb3JlCiAK
IC8vIERvY3VtZW50LmNwcApAQCAtNzksNiArODUsMTAgQEAgbmFtZXNwYWNlIFdlYkNvcmUgewog
ICAgICAgICAuLi4KICAgICB9OwogCisgICAgbmFtZXNwYWNlIE5lc3RlZE5hbWVzcGFjZSB7Cisg
ICAgLi4uCisgICAgfQorCiB9IC8vIG5hbWVzcGFjZSBXZWJDb3JlCiAKIC8vIERvY3VtZW50LmNw
cAo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>44329</attachid>
            <date>2009-12-04 13:24:44 -0800</date>
            <delta_ts>2009-12-17 15:24:37 -0800</delta_ts>
            <desc>patch 2 </desc>
            <filename>textmate stdin VrDu7H.txt</filename>
            <type>text/plain</type>
            <size>856</size>
            <attacher name="Jens Alfke">jens</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYktpdFNpdGUvY29kaW5nL2NvZGluZy1zdHlsZS5odG1sIGIvV2ViS2l0
U2l0ZS9jb2RpbmcvY29kaW5nLXN0eWxlLmh0bWwKaW5kZXggNmJlMGFlNi4uODRmNTkxYyAxMDA2
NDQKLS0tIGEvV2ViS2l0U2l0ZS9jb2RpbmcvY29kaW5nLXN0eWxlLmh0bWwKKysrIGIvV2ViS2l0
U2l0ZS9jb2RpbmcvY29kaW5nLXN0eWxlLmh0bWwKQEAgLTQ1LDcgKzQ1LDggQEAgaW50IG1haW4o
KQogfQogPC9wcmU+CiA8L2xpPgotPGxpPkNvZGUgaW5zaWRlIGEgbmFtZXNwYWNlIHNob3VsZCBu
b3QgYmUgaW5kZW50ZWQuCis8bGk+VGhlIGNvbnRlbnRzIG9mIGFuIG91dGVybW9zdCA8Y29kZT5u
YW1lc3BhY2U8L2NvZGU+IGJsb2NrIChhbmQgYW55IG5lc3RlZCBuYW1lc3BhY2VzIHdpdGggdGhl
IHNhbWUgc2NvcGUpCitzaG91bGQgbm90IGJlIGluZGVudGVkLiBUaGUgY29udGVudHMgb2Ygb3Ro
ZXIgbmVzdGVkIG5hbWVzcGFjZXMgc2hvdWxkIGJlIGluZGVudGVkLgogPGg0IGNsYXNzPSJyaWdo
dCI+UmlnaHQ6PC9oND4KIDxwcmUgY2xhc3M9ImNvZGUiPgogLy8gRG9jdW1lbnQuaApAQCAtNTYs
NiArNTcsMTAgQEAgY2xhc3MgRG9jdW1lbnQgewogICAgIC4uLgogfTsKIAorbmFtZXNwYWNlIE5l
c3RlZE5hbWVzcGFjZSB7CisgICAgLi4uCit9CisKIH0gLy8gbmFtZXNwYWNlIFdlYkNvcmUKIAog
Ly8gRG9jdW1lbnQuY3BwCkBAIC03OSw2ICs4NCwxMCBAQCBuYW1lc3BhY2UgV2ViQ29yZSB7CiAg
ICAgICAgIC4uLgogICAgIH07CiAKKyAgICBuYW1lc3BhY2UgTmVzdGVkTmFtZXNwYWNlIHsKKyAg
ICAuLi4KKyAgICB9CisKIH0gLy8gbmFtZXNwYWNlIFdlYkNvcmUKIAogLy8gRG9jdW1lbnQuY3Bw
Cg==
</data>
<flag name="review"
          id="26155"
          type_id="1"
          status="+"
          setter="levin"
    />
    <flag name="commit-queue"
          id="27087"
          type_id="3"
          status="-"
          setter="levin"
    />
          </attachment>
      

    </bug>

</bugzilla>