webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
[](#indentation-no-tabs) Use spaces, not tabs. Tabs should only appear in files that require them for semantic meaning, like Makefiles.
[](#indentation-4-spaces) The indent size is 4 spaces.
[](#indentation-namespace) The contents of an outermost namespace
block (and any nested namespaces with the same scope) should not be indented. The contents of other nested namespaces should be indented.
[](#indentation-case-label) A case label should line up with its switch statement. The case statement is indented.
[](#indentation-wrap-bool-op) Boolean expressions at the same nesting level that span multiple lines should have their operators on the left side of the line instead of the right side.
[](#spacing-unary-op) Do not place spaces around unary operators.
[](#spacing-binary-ternary-op) Do place spaces around binary and ternary operators.
[](#spacing-for-colon) Place spaces around the colon in a range-based for loop.
[](#spacing-comma-semicolon) Do not place spaces before comma and semicolon.
[](#spacing-control-paren) Place spaces between control statements and their parentheses.
[](#spacing-function-paren) Do not place spaces between a function and its parentheses, or between a parenthesis and its content.
[](#linebreaking-multiple-statements) Each statement should get its own line.
[](#linebreaking-else-braces) An else
statement should go on the same line as a preceding close brace if one is present, else it should line up with the if
statement.
[](#linebreaking-else-if) An else if
statement should be written as an if
statement when the prior if
concludes with a return
statement.
[](#braces-function) Function definitions: place each brace on its own line.
[](#braces-blocks) Other braces: place the open brace on the line preceding the code block; place the close brace on its own line.
[](#braces-one-line) One-line control clauses should not use braces unless comments are included or a single statement spans multiple lines.
[](#braces-empty-block) Control clauses without a body should use empty braces:
[](#zero-null) In C++, the null pointer value should be written as nullptr
. In C, it should be written as NULL
. In Objective-C and Objective-C++, follow the guideline for C or C++, respectively, but use nil
to represent a null Objective-C object.
[](#zero-bool) C++ and C bool
values should be written as true
and false
. Objective-C BOOL
values should be written as YES
and NO
.
[](#zero-comparison) Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.
[](#zero-objc-variables) In Objective-C, instance variables are initialized to zero automatically. Don't add explicit initializations to nil or NO in an init method.
[](#float-suffixes) Unless required in order to force floating point math, do not append .0
, .f
and .0f
to floating point literals.
[](names-basic) Use CamelCase. Capitalize the first letter, including all letters in an acronym, in a class, struct, protocol, or namespace name. Lower-case the first letter, including all letters in an acronym, in a variable or function name.
[](names-full-words) Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.
[](names-data-members) Data members in C++ classes should be private. Static data members should be prefixed by "s_". Other data members should be prefixed by "m_".
[](names-objc-instance-variables) Prefix Objective-C instance variables with "_".
```cpp