On 12/19/2013 10:20 AM, Andrea Marchesini wrote:
Hi,

Writing a patch for bug 949488 I had to indent this piece of code:

   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
   if (NS_WARN_IF(NS_FAILED(ssm->GetSimpleCodebasePrincipal(
                                        originURI,
                                        getter_AddRefs(providedPrincipal))))) {

It seems that our style guide does not say anything about how indent this 
tricky case.
So, talking with bholley we decided to write an email proposing something like 
this:

1. if they can, all the params on the same line. max 80 chars.

2. otherwise multiple lines, aligned with the beginning of the params list.

es: obj->ThisIsALooooooooooongNameMethod(looooooooongParam1,
                                          loooooooooogParam2);

3. if 1 param alone goes over 80chars, it must be aligned in order to stay in 
the 80chars and the rest of the params must be aligned with it.

   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
   if (NS_WARN_IF(NS_FAILED(ssm->GetSimpleCodebasePrincipal(
                                        originURI,
                                        getter_AddRefs(providedPrincipal))))) {
                                                              // 80chars here ^

This approach is already used in dom/workers and IndexedDB.
https://mxr.mozilla.org/mozilla-central/source/dom/workers/RuntimeService.cpp#1647

I would suggest:

|     nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|     rv = ssm->GetSimpleCodebasePrincipal(originURI,
| getter_AddRefs(providedPrincipal);
|     if (NS_WARN_IF(NS_FAILED(rv))) {

HTH
Ms2ger
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to