Introduce typed Node/Element iterators for range-based for loops of C++11.

Intend to replace the following typical for loop:

for (Node* child = node.firstChild(); child; child = child->nextSibling()) {
    ....
}

with range-based for loop of C++11:

for (Node& child : NodeTraversal::childrenOf(node)) {
    ....
}

Less verbose and improves readability, especially if we could close our eyes on NodeTraversal prefix.


The following iterators are introduced to address common use cases in our code base:

1. NodeTraversal::childrenOf(const Node&)

  This could replace:
    for (Node* child = node.firstChild(); child; child = child->nextSibling()) { ... }
  with:
    for (Node& child : NodeTraversal::childrenOf(node)) { ... }

2. NodeTraversal::descendantsOf(const Node&)

  This could replace:
    for (Node* node = root.firstChild(); node; node = NodeTraversal::next(*node, &root) { ... }
  with:
    for (Node& node : NodeTraversal::descendantsOf(root)) { ... }

3. NodeTraversal::inclusiveDescendantsOf(const Node&)

  This could replace:
    for (Node* node = &root; node; node = NodeTraversal::next(*node, &root) { ... }
  with:
    for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { ... }

4. NodeTraversal::fromNext(const Node&)

  This could replace:
    for (Node* node = NodeTraversal::next(start); node; node = NodeTraversal::next(*node) { ... }
  with:
    for (Node& node : NodeTraversal::fromNext(start)) { ... }


There are also typed template versions for other element types:

5. Traversal<ElementType>::childrenOf(const Node&)

  This could replace:
    for (ElementType* child = Traversal<ElementType>::firstChild(node); child; child = Traversal<ElementType>::nextSibling(*child)) { ... }
  with:
    for (ElementType& child : Traversal<ElementType>::childrenOf(node)) { ... }

6. Traversal<ElementType>::descendantsOf(const Node&)

  This could replace:
    for (ElementType* node = Traversal<ElementType>::firstWithin(root); node; node = Traversal<ElementType>::next(*node, &root)) { ... }
  with:
    for (ElementType& node : Traversal<ElementType>::descendantsOf(root)) { ... }

7. Traversal<ElementType>::inclusiveDescendantsOf(const ElementType&)

  This could replace:
    for (ElementType* node = &root; node; node = Traversal<ElementType>::next(*node, &root)) { ... }
  with:
    for (ElementType& node : Traversal<ElementType>::inclusiveDescendantsOf(root)) { ... }

8. Traversal<ElementType>::fromNext(const Node&)

  This could replace:
    for (ElementType* node = Traversal<ElementType>::next(start); node; node = Traversal<ElementType>::next(*node) { ... }
  with:
    for (ElementType& node : Traversal<ElementType>::fromNext(start)) { ... }


New iterators should be zero overhead because compilers can make them all inlined in a release build.

As the first showcase, I let some files use this range-based for loops. This is not comprehensive so that this patch wouldn't get larger.
Other changes will be done in another patch.

We might want to have similar things for other classes, such as RenderObject, which can also be done in another patch.

BUG=none
TEST=no layout test failure

Review URL: https://codereview.chromium.org/642973003

git-svn-id: svn://svn.chromium.org/blink/trunk@183872 bbb929c8-8fbe-4397-9dbb-9b2b20218538