Optimized dom search performance by caching all the elements in HTMLCollection when counting the number

It improves the browsermark/dom/search performance by 50%.
https://bugs.webkit.org/show_bug.cgi?id=129450

this patch is based on WebKit r164853 by <rniwa@webkit.org>

BUG=370306

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

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