summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-11-30 15:46:06 -0500
committerCary Clark <cary@android.com>2009-11-30 16:04:53 -0500
commita0428a863bd79d20e416d6d981d0120bd1569edf (patch)
treea4b4cb110e660f6a7debfa638248ccc082afb6bc /WebKit/android
parent39e2da62da0cbe8b66815b72ea0a2a3e13bda40b (diff)
downloadexternal_webkit-a0428a863bd79d20e416d6d981d0120bd1569edf.zip
external_webkit-a0428a863bd79d20e416d6d981d0120bd1569edf.tar.gz
external_webkit-a0428a863bd79d20e416d6d981d0120bd1569edf.tar.bz2
navigate preferably between children of the same parent
The nav cache attempts to take advantage of the order that the dom is walked to know when multiple nodes have the same parent. The old implementation doesn't always work, and a simpler non-cached version makes more sense. The algorithm now walks nodes until the parent has more than one child, and assigns that parent as the 'parent group'. On the other end, nodes with no parent group are never allowed to get preferential matching treatment.
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp17
-rw-r--r--WebKit/android/nav/CacheBuilder.h1
-rw-r--r--WebKit/android/nav/CachedFrame.cpp2
3 files changed, 12 insertions, 8 deletions
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index 37bdc9a..58be0e8 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -824,6 +824,16 @@ void CacheBuilder::buildCache(CachedRoot* root)
setData((CachedFrame*) root);
}
+static Node* ParentWithChildren(Node* node)
+{
+ Node* parent = node;
+ while ((parent = parent->parentNode())) {
+ if (parent->childNodeCount() > 1)
+ return parent;
+ }
+ return 0;
+}
+
static Node* OneAfter(Node* node)
{
Node* parent = node;
@@ -917,8 +927,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
lastChildIndex = last->mCachedNodeIndex;
last = &tracker.last();
}
- if (node == last->mParentLastChild)
- last->mParentLastChild = NULL;
do {
const ClipColumnTracker* lastClip = &clipTracker.last();
if (node != lastClip->mLastChild)
@@ -1211,9 +1219,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
cachedNode.setMaxLength(maxLength);
cachedNode.setName(name);
cachedNode.setParentIndex(last->mCachedNodeIndex);
- if (last->mParentLastChild == NULL)
- last->mParentLastChild = OneAfter(node->parentNode()->lastChild());
- cachedNode.setParentGroup(last->mParentLastChild);
+ cachedNode.setParentGroup(ParentWithChildren(node));
cachedNode.setTabIndex(tabIndex);
cachedNode.setTextSize(textSize);
cachedNode.setType(type);
@@ -1235,7 +1241,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
Tracker& working = tracker.last();
working.mCachedNodeIndex = lastIndex;
working.mLastChild = OneAfter(lastChild);
- working.mParentLastChild = OneAfter(node->parentNode()->lastChild());
last = &tracker.at(tracker.size() - 2);
working.mSomeParentTakesFocus = last->mSomeParentTakesFocus | takesFocus;
}
diff --git a/WebKit/android/nav/CacheBuilder.h b/WebKit/android/nav/CacheBuilder.h
index 784302c..0c12699 100644
--- a/WebKit/android/nav/CacheBuilder.h
+++ b/WebKit/android/nav/CacheBuilder.h
@@ -200,7 +200,6 @@ private:
int mCachedNodeIndex;
int mTabIndex;
Node* mLastChild;
- Node* mParentLastChild;
bool mSomeParentTakesFocus;
};
void adjustForColumns(const ClipColumnTracker& track,
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp
index 953eed4..54c295d 100644
--- a/WebKit/android/nav/CachedFrame.cpp
+++ b/WebKit/android/nav/CachedFrame.cpp
@@ -687,7 +687,7 @@ int CachedFrame::frameNodeCommon(BestData& testData, const CachedNode* test, Bes
// return REJECT_TEST;
// }
void* par = cursor ? cursor->parentGroup() : NULL;
- testData.mCursorChild = test->parentGroup() == par;
+ testData.mCursorChild = par ? test->parentGroup() == par : false;
#if 0 // not debugged
if (cursor && cursor->hasMouseOver() && test->hasMouseOver() == false &&
cursor->bounds().contains(test->bounds()))