From 0f5d4355d7a384679722338d55f65bbb92350cfc Mon Sep 17 00:00:00 2001 From: Naiem Shaik Date: Thu, 19 Jul 2012 10:45:56 -0700 Subject: DOM Optimizations DOM traversal optimizations DOM Core optimizations Prefetch optimization for DOM Tree Traversal Conflicts: Source/WebKit/android/jni/WebViewCore.cpp Change-Id: Icbb8a7229ee9cff1a5401b57c8181f18b9a6d6e0 --- Source/WebCore/html/HTMLAllCollection.cpp | 43 ++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'Source/WebCore/html/HTMLAllCollection.cpp') diff --git a/Source/WebCore/html/HTMLAllCollection.cpp b/Source/WebCore/html/HTMLAllCollection.cpp index dbfed28..8c92a00 100644 --- a/Source/WebCore/html/HTMLAllCollection.cpp +++ b/Source/WebCore/html/HTMLAllCollection.cpp @@ -26,17 +26,18 @@ #include "config.h" #include "HTMLAllCollection.h" +#include "Element.h" #include "Node.h" namespace WebCore { -PassRefPtr HTMLAllCollection::create(PassRefPtr base) +PassRefPtr HTMLAllCollection::create(PassRefPtr base, CollectionType type) { - return adoptRef(new HTMLAllCollection(base)); + return adoptRef(new HTMLAllCollection(base, type)); } -HTMLAllCollection::HTMLAllCollection(PassRefPtr base) - : HTMLCollection(base, DocAll) +HTMLAllCollection::HTMLAllCollection(PassRefPtr base, CollectionType type) + : HTMLCollection(base, type) { } @@ -44,4 +45,38 @@ HTMLAllCollection::~HTMLAllCollection() { } +Element* HTMLAllCollection::itemAfter(Element* previous) const +{ + bool includeChildren = (type() == DocAll); + Node* current; + Node* root = base(); + if (!previous) + current = root->firstChild(); + else + current = includeChildren ? previous->traverseNextNode(root) : previous->traverseNextSibling(root); + + if (includeChildren) { + Node * lastDecendant = info()->lastDecendantOfBase; + if (!lastDecendant) { + info()->lastDecendantOfBase = root->lastDescendantNode(); + lastDecendant = info()->lastDecendantOfBase; + } + + for (; current; current = current->traverseNextNodeFastPath()) { + if (current->isElementNode()) + return static_cast(current); + if (current == lastDecendant) + break; + } + } else { + for (; current; current = current->traverseNextSibling(root)) { + if (current->isElementNode()) + return static_cast(current); + } + } + + return 0; +} + + } // namespace WebCore -- cgit v1.1