Use data driven code when registering Element constructors.

For more compact initialization code. Because I want to.

R=adamk@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@167443 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Get rid of inefficient uses of childNodeCount()

Get rid of inefficient uses of childNodeCount() as this method can be costly.
Its implementation needs to traverse the node's direct children in the DOM tree
in order to count them. A lot of callers wrongly assume calling
childNodeCount() is cheap.

In a lot of cases, the callers simply want to know if the node has any children
or it is has exactly one child. hasChildNodes() / hasOneChild() methods provide
the same information much more efficiently.

In some cases, we already know the node is a ContainerNode but call the
Node::childNodeCount() method instead of ContainerNode::childNodeCount() which
bypasses the isContainerNode() check.

Finally, the caller sometimes wants to traverse all the direct children and
uses childNodeCount() / childNode(index) to do so. This causes the children to
be traversed twice (even more when childNodeCount() is used as loop condition
and not cached before the loop). In this case, it is best to use the traversal
API (NodeTraversal / ElementTraversal).

R=adamk, eseidel

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

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