summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/nav')
-rw-r--r--WebKit/android/nav/CacheBuilder.cpp45
-rw-r--r--WebKit/android/nav/CacheBuilder.h5
-rw-r--r--WebKit/android/nav/CachedDebug.h11
-rw-r--r--WebKit/android/nav/CachedFrame.cpp12
-rw-r--r--WebKit/android/nav/CachedHistory.cpp10
-rw-r--r--WebKit/android/nav/CachedHistory.h2
-rw-r--r--WebKit/android/nav/CachedNode.cpp6
-rw-r--r--WebKit/android/nav/CachedNode.h4
-rw-r--r--WebKit/android/nav/CachedRoot.cpp32
-rw-r--r--WebKit/android/nav/CachedRoot.h4
-rw-r--r--WebKit/android/nav/WebView.cpp53
11 files changed, 116 insertions, 68 deletions
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp
index 1323581..9efcbd7 100644
--- a/WebKit/android/nav/CacheBuilder.cpp
+++ b/WebKit/android/nav/CacheBuilder.cpp
@@ -453,14 +453,16 @@ void CacheBuilder::Debug::groups() {
} else
print("\"\"");
RenderObject* renderer = node->renderer();
+ int tabindex = node->isElementNode() ? node->tabIndex() : 0;
if (renderer) {
const IntRect& absB = renderer->absoluteBoundingBoxRect();
- snprintf(scratch, sizeof(scratch), ", {%d, %d, %d, %d}, %s},",
- absB.x(), absB.y(), absB.width(), absB.height(),
- renderer->hasOverflowClip() ? "true" : "false");
+ snprintf(scratch, sizeof(scratch), ", {%d, %d, %d, %d}, %s"
+ ", %d},",absB.x(), absB.y(), absB.width(), absB.height(),
+ renderer->hasOverflowClip() ? "true" : "false", tabindex);
print(scratch);
} else
- print(", {0, 0, 0, 0}, false},");
+ print(", {0, 0, 0, 0}, false, 0},");
+
flush();
snprintf(scratch, sizeof(scratch), "// %d: ", count);
mPrefix = "\n// ";
@@ -945,6 +947,11 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
ClipColumnTracker* baseTracker = clipTracker.data(); // sentinel
bzero(baseTracker, sizeof(ClipColumnTracker));
}
+ WTF::Vector<TabIndexTracker> tabIndexTracker(1);
+ {
+ TabIndexTracker* baseTracker = tabIndexTracker.data(); // sentinel
+ bzero(baseTracker, sizeof(TabIndexTracker));
+ }
#if DUMP_NAV_CACHE
char* frameNamePtr = cachedFrame->mDebug.mFrameName;
Builder(frame)->mDebug.frameName(frameNamePtr, frameNamePtr +
@@ -964,8 +971,10 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
Node* node = parent;
int cacheIndex = 1;
Node* focused = doc->focusedNode();
- if (focused)
+ if (focused) {
setLastFocus(focused);
+ cachedRoot->setFocusBounds(mLastKnownFocusBounds);
+ }
int globalOffsetX, globalOffsetY;
GetGlobalOffset(frame, &globalOffsetX, &globalOffsetY);
while (walk.mMore || (node = node->traverseNextNode()) != NULL) {
@@ -989,6 +998,12 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
break;
clipTracker.removeLast();
} while (true);
+ do {
+ const TabIndexTracker* lastTabIndex = &tabIndexTracker.last();
+ if (node != lastTabIndex->mLastChild)
+ break;
+ tabIndexTracker.removeLast();
+ } while (true);
Frame* child = HasFrame(node);
CachedNode cachedNode;
if (child != NULL) {
@@ -1014,6 +1029,17 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
BuildFrame(root, child, cachedRoot, childPtr);
continue;
}
+ int tabIndex = node->tabIndex();
+ Node* lastChild = node->lastChild();
+ if (tabIndex <= 0)
+ tabIndex = tabIndexTracker.last().mTabIndex;
+ else if (tabIndex > 0 && lastChild) {
+ DBG_NAV_LOGD("tabIndex=%d node=%p", tabIndex, node);
+ tabIndexTracker.grow(tabIndexTracker.size() + 1);
+ TabIndexTracker& indexTracker = tabIndexTracker.last();
+ indexTracker.mTabIndex = tabIndex;
+ indexTracker.mLastChild = OneAfter(lastChild);
+ }
RenderObject* nodeRenderer = node->renderer();
bool isTransparent = false;
bool hasFocusRing = true;
@@ -1066,7 +1092,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
CachedNodeType type = NORMAL_CACHEDNODETYPE;
IntRect bounds;
IntRect absBounds;
- Node* lastChild = node->lastChild();
WTF::Vector<IntRect>* columns = NULL;
if (isArea) {
HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
@@ -1171,7 +1196,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
else if (node->hasTagName(HTMLNames::aTag)) {
const HTMLAnchorElement* anchorNode =
(const HTMLAnchorElement*) node;
- if (anchorNode->isFocusable() == false)
+ if (!anchorNode->isFocusable() && !HasTriggerEvent(node))
continue;
EventTargetNode* target = (EventTargetNode*) node;
if (target->disabled())
@@ -1290,6 +1315,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
if (last->mParentLastChild == NULL)
last->mParentLastChild = OneAfter(node->parentNode()->lastChild());
cachedNode.setParentGroup(last->mParentLastChild);
+ cachedNode.setTabIndex(tabIndex);
cachedNode.setTextSize(textSize);
cachedNode.setType(type);
cachedNode.setWantsKeyEvents(wantsKeyEvents);
@@ -1316,8 +1342,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
}
}
cacheIndex++;
-tryNextNode:
- ;
}
while (tracker.size() > 1) {
Tracker* last = &tracker.last();
@@ -2961,7 +2985,8 @@ bool CacheBuilder::ConstructPartRects(Node* node, const IntRect& bounds,
clip.mNode = test;
} while (test != last && (test = test->traverseNextNode()) != NULL);
}
- if (result->size() == 0) {
+ if (result->size() == 0 || focusBounds->width() < MINIMUM_FOCUSABLE_WIDTH
+ || focusBounds->height() < MINIMUM_FOCUSABLE_HEIGHT) {
if (bounds.width() < MINIMUM_FOCUSABLE_WIDTH)
return false;
if (bounds.height() < MINIMUM_FOCUSABLE_HEIGHT)
diff --git a/WebKit/android/nav/CacheBuilder.h b/WebKit/android/nav/CacheBuilder.h
index 7d5404d..07040e2 100644
--- a/WebKit/android/nav/CacheBuilder.h
+++ b/WebKit/android/nav/CacheBuilder.h
@@ -177,8 +177,13 @@ private:
TextDirection mDirection;
bool mHasClip;
};
+ struct TabIndexTracker {
+ int mTabIndex;
+ Node* mLastChild;
+ };
struct Tracker {
int mCachedNodeIndex;
+ int mTabIndex;
Node* mLastChild;
Node* mParentLastChild;
bool mSomeParentTakesFocus;
diff --git a/WebKit/android/nav/CachedDebug.h b/WebKit/android/nav/CachedDebug.h
index 42c6363..3127112 100644
--- a/WebKit/android/nav/CachedDebug.h
+++ b/WebKit/android/nav/CachedDebug.h
@@ -43,19 +43,8 @@
#endif
#if DEBUG_NAV_UI
-#define DBG_NAV_LOGD_NO_PARAM 0 /* needed so we can call (format, ...) */
-#define DBG_NAV_LOG_THROTTLE_INTERVAL 1000
#define DBG_NAV_LOG(message) LOGD("%s %s", __FUNCTION__, message)
#define DBG_NAV_LOGD(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__)
-#define DBG_NAV_LOGD_THROTTLE(format, ...) \
-do { \
- static uint32_t gPrevLogTime = 0; \
- uint32_t curTime = SkTime::GetMSecs(); \
- if (curTime - gPrevLogTime > DBG_NAV_LOG_THROTTLE_INTERVAL) { \
- LOGD("%s " format, __FUNCTION__, __VA_ARGS__); \
- gPrevLogTime = curTime; \
- } \
-} while (false)
#define DEBUG_NAV_UI_LOGD(...) LOGD(__VA_ARGS__)
#else
#define DBG_NAV_LOG(message) ((void)0)
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp
index 0231394..4db9e40 100644
--- a/WebKit/android/nav/CachedFrame.cpp
+++ b/WebKit/android/nav/CachedFrame.cpp
@@ -125,6 +125,14 @@ void CachedFrame::clearFocus()
// returns 0 if test is preferable to best, 1 if not preferable, or -1 if unknown
int CachedFrame::compare(BestData& testData, const BestData& bestData, const CachedNode* focus) const
{
+ if (testData.mNode->tabIndex() != bestData.mNode->tabIndex()) {
+ if (testData.mNode->tabIndex() < bestData.mNode->tabIndex()
+ || (focus && focus->tabIndex() < bestData.mNode->tabIndex())) {
+ testData.mNode->setCondition(CachedNode::HIGHER_TAB_INDEX);
+ return REJECT_TEST;
+ }
+ return TEST_IS_BEST;
+ }
// start here;
// if the test minor axis line intersects the line segment between focus center and best center, choose it
// give more weight to exact major axis alignment (rows, columns)
@@ -662,7 +670,7 @@ int CachedFrame::frameNodeCommon(BestData& testData, const CachedNode* test, Bes
testData.mNode->setCondition(CachedNode::NOT_FOCUS_NODE);
return REJECT_TEST;
}
-// if (test->bounds().contains(history()->focusBounds())) {
+// if (test->bounds().contains(mRoot->focusBounds())) {
// testData.mNode->setCondition(CachedNode::NOT_ENCLOSING_FOCUS);
// return REJECT_TEST;
// }
@@ -733,7 +741,7 @@ int CachedFrame::frameNodeCommon(BestData& testData, const CachedNode* test, Bes
int CachedFrame::framePartCommon(BestData& testData,
const CachedNode* test, BestData* bestData, const CachedNode* focus) const
{
- if (testData.mNodeBounds.contains(history()->focusBounds())) {
+ if (testData.mNodeBounds.contains(mRoot->focusBounds())) {
testData.mNode->setCondition(CachedNode::NOT_ENCLOSING_FOCUS);
return REJECT_TEST;
}
diff --git a/WebKit/android/nav/CachedHistory.cpp b/WebKit/android/nav/CachedHistory.cpp
index ba94c72..f75f237 100644
--- a/WebKit/android/nav/CachedHistory.cpp
+++ b/WebKit/android/nav/CachedHistory.cpp
@@ -82,7 +82,7 @@ void CachedHistory::reset()
{
memset(mVisited, 0, sizeof(mVisited));
// mLastScroll = 0;
- mPriorBounds = mFocusBounds = WebCore::IntRect(0, 0, 0, 0);
+ mPriorBounds = WebCore::IntRect(0, 0, 0, 0);
mDirectionChange = false;
mFocusIsInput = false;
mPriorIsInput = false;
@@ -107,12 +107,11 @@ void CachedHistory::setWorking(CachedFrame::Direction newMove,
if (focus != NULL) {
WebCore::IntRect focusBounds;
focus->getBounds(&focusBounds);
- if (focusBounds.isEmpty() == false && focusBounds != mFocusBounds)
- mNavBounds = mFocusBounds = focusBounds;
+ if (focusBounds.isEmpty() == false)
+ mNavBounds = focusBounds;
mPriorIsInput = mFocusIsInput;
mFocusIsInput = focus->isInput(); // focus->localName() == "input";
- } else
- mFocusBounds = WebCore::IntRect(0, 0, 0, 0);
+ }
if (change) { // uninitialized or change in direction
if (lastAxis != CachedFrame::LEFT && navBounds->height() > 0) {
mMinWorkingHorizontal = navBounds->y();
@@ -177,7 +176,6 @@ void CachedHistory::Debug::print(CachedRoot* root) const
}
DUMP_NAV_LOGD("// };\n");
// DUMP_NAV_LOGD("// int mLastScroll=%d;\n", b->mLastScroll);
- DEBUG_PRINT_RECT(mFocusBounds);
DEBUG_PRINT_RECT(mNavBounds);
DEBUG_PRINT_RECT(mPriorBounds);
DEBUG_PRINT_BOOL(mDirectionChange);
diff --git a/WebKit/android/nav/CachedHistory.h b/WebKit/android/nav/CachedHistory.h
index 490ed67..e48d44b 100644
--- a/WebKit/android/nav/CachedHistory.h
+++ b/WebKit/android/nav/CachedHistory.h
@@ -43,7 +43,6 @@ public:
bool checkVisited(const CachedNode* , CachedFrame::Direction ) const;
bool didFirstLayout() const { return mDidFirstLayout; }
bool directionChange() const { return mDirectionChange; }
- const WebCore::IntRect& focusBounds() const { return mFocusBounds; }
int minWorkingHorizontal() const { return mMinWorkingHorizontal; }
int minWorkingVertical() const { return mMinWorkingVertical; }
int maxWorkingHorizontal() const { return mMaxWorkingHorizontal; }
@@ -61,7 +60,6 @@ private:
const CachedNode* mNode;
CachedFrame::Direction mDirection;
} mVisited[NAVIGATION_VISIT_DEPTH];
- WebCore::IntRect mFocusBounds; // chosen focus ring
WebCore::IntRect mMouseBounds; // constricted bounds, if focus ring is partially visible
WebCore::IntRect mNavBounds; // focus ring bounds plus optional keystroke movement
WebCore::IntRect mPriorBounds; // prior chosen focus ring (for reversing narrowing)
diff --git a/WebKit/android/nav/CachedNode.cpp b/WebKit/android/nav/CachedNode.cpp
index e6ade3e..b786677 100644
--- a/WebKit/android/nav/CachedNode.cpp
+++ b/WebKit/android/nav/CachedNode.cpp
@@ -263,6 +263,7 @@ const char* CachedNode::Debug::condition(Condition t) const
case BEST_DIRECTION: return "BEST_DIRECTION"; break;
case CHILD: return "CHILD"; break;
case DISABLED: return "DISABLED"; break;
+ case HIGHER_TAB_INDEX: return "HIGHER_TAB_INDEX"; break;
case IN_FOCUS: return "IN_FOCUS"; break;
case IN_FOCUS_CHILDREN: return "IN_FOCUS_CHILDREN"; break;
case NOT_ENCLOSING_FOCUS: return "NOT_ENCLOSING_FOCUS"; break;
@@ -300,6 +301,7 @@ void CachedNode::Debug::print() const
scratch[index++] = *ch++;
DUMP_NAV_LOGD("%.*s\"\n", index, scratch);
DEBUG_PRINT_RECT(mBounds);
+ DEBUG_PRINT_RECT(mHitBounds);
const WTF::Vector<WebCore::IntRect>& rects = b->focusRings();
size_t size = rects.size();
DUMP_NAV_LOGD("// IntRect focusRings={ // size=%d\n", size);
@@ -315,11 +317,13 @@ void CachedNode::Debug::print() const
DUMP_NAV_LOGD("// int mNavableRects=%d;\n", b->mNavableRects);
DUMP_NAV_LOGD("// int mParentIndex=%d;\n", b->mParentIndex);
DUMP_NAV_LOGD("// int mTextSize=%d;\n", b->mTextSize);
+ DUMP_NAV_LOGD("// int mTabIndex=%d;\n", b->mTabIndex);
DUMP_NAV_LOGD("// Condition mCondition=%s;\n", condition(b->mCondition));
DUMP_NAV_LOGD("// Type mType=%s;\n", type(b->mType));
DEBUG_PRINT_BOOL(mClippedOut);
DEBUG_PRINT_BOOL(mDisabled);
DEBUG_PRINT_BOOL(mFixedUpFocusRects);
+ DEBUG_PRINT_BOOL(mHasFocusRing);
DEBUG_PRINT_BOOL(mHasMouseOver);
DEBUG_PRINT_BOOL(mIsAnchor);
DEBUG_PRINT_BOOL(mIsArea);
@@ -327,11 +331,13 @@ void CachedNode::Debug::print() const
DEBUG_PRINT_BOOL(mIsInput);
DEBUG_PRINT_BOOL(mIsParentAnchor);
DEBUG_PRINT_BOOL(mIsPassword);
+ DEBUG_PRINT_BOOL(mIsRtlText);
DEBUG_PRINT_BOOL(mIsTextArea);
DEBUG_PRINT_BOOL(mIsTextField);
DEBUG_PRINT_BOOL(mIsTransparent);
DEBUG_PRINT_BOOL(mIsUnclipped);
DEBUG_PRINT_BOOL(mLast);
+ DEBUG_PRINT_BOOL(mWantsKeyEvents);
DUMP_NAV_LOGD("\n");
}
diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h
index 6cb1ca3..aa64982 100644
--- a/WebKit/android/nav/CachedNode.h
+++ b/WebKit/android/nav/CachedNode.h
@@ -69,6 +69,7 @@ public:
BEST_DIRECTION, // can be reached by another direction
CHILD,
DISABLED,
+ HIGHER_TAB_INDEX,
IN_FOCUS,
IN_FOCUS_CHILDREN,
NOT_ENCLOSING_FOCUS,
@@ -160,9 +161,11 @@ public:
void setNavableRects() { mNavableRects = mFocusRing.size(); }
void setParentGroup(void* group) { mParentGroup = group; }
void setParentIndex(int parent) { mParentIndex = parent; }
+ void setTabIndex(int index) { mTabIndex = index; }
void setTextSize(int textSize) { mTextSize = textSize; }
void setType(CachedNodeType type) { mType = type; }
void setWantsKeyEvents(bool wantsKeys) { mWantsKeyEvents = wantsKeys; }
+ int tabIndex() const { return mTabIndex; }
const CachedNode* traverseNextNode() const { return mLast ? NULL : &this[1]; }
int textSize() const { return mTextSize; }
CachedNodeType type() const { return mType; }
@@ -180,6 +183,7 @@ private:
int mNavableRects; // FIXME: could be bitfield once I limit max number of rects
int mParentIndex;
int mTextSize;
+ int mTabIndex;
mutable Condition mCondition : 5; // why the node was not chosen on the first pass
CachedNodeType mType : 3;
bool mClippedOut : 1;
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp
index 8e0833d..4a50c80 100644
--- a/WebKit/android/nav/CachedRoot.cpp
+++ b/WebKit/android/nav/CachedRoot.cpp
@@ -670,8 +670,8 @@ bool CachedRoot::innerDown(const CachedNode* test, BestData* bestData) const
mScrolledBounds.setHeight(mScrolledBounds.height() + mMaxYScroll);
int testTop = mScrolledBounds.y();
int viewBottom = mViewBounds.bottom();
- if (mHistory->mFocusBounds.isEmpty() == false &&
- mHistory->mFocusBounds.bottom() > viewBottom && viewBottom < mContents.height())
+ if (mFocusBounds.isEmpty() == false &&
+ mFocusBounds.bottom() > viewBottom && viewBottom < mContents.height())
return false;
if (mHistory->mNavBounds.isEmpty() == false) {
int navTop = mHistory->mNavBounds.y();
@@ -694,8 +694,8 @@ bool CachedRoot::innerLeft(const CachedNode* test, BestData* bestData) const
mScrolledBounds.setWidth(mScrolledBounds.width() + mMaxXScroll);
int testRight = mScrolledBounds.right();
int viewLeft = mViewBounds.x();
- if (mHistory->mFocusBounds.isEmpty() == false &&
- mHistory->mFocusBounds.x() < viewLeft && viewLeft > mContents.x())
+ if (mFocusBounds.isEmpty() == false &&
+ mFocusBounds.x() < viewLeft && viewLeft > mContents.x())
return false;
if (mHistory->mNavBounds.isEmpty() == false) {
int navRight = mHistory->mNavBounds.right();
@@ -721,7 +721,11 @@ void CachedRoot::innerMove(const CachedNode* node, BestData* bestData,
#endif
if (firstTime)
mHistory->reset();
- mHistory->setWorking(direction, currentFocus(), mViewBounds);
+ const CachedNode* focus = currentFocus();
+ mHistory->setWorking(direction, focus, mViewBounds);
+ mFocusBounds = WebCore::IntRect(0, 0, 0, 0);
+ if (focus != NULL)
+ focus->getBounds(&mFocusBounds);
bool findClosest = false;
if (mScrollOnly == false) {
switch (direction) {
@@ -761,7 +765,7 @@ void CachedRoot::innerMove(const CachedNode* node, BestData* bestData,
return;
if (bestData->mNode != NULL) {
mHistory->addToVisited(bestData->mNode, direction);
- mHistory->mNavBounds = mHistory->mFocusBounds = bestData->mNodeBounds;
+ mHistory->mNavBounds = mFocusBounds = bestData->mNodeBounds;
mHistory->mMouseBounds = bestData->mMouseBounds;
} else if (scroll->x() != 0 || scroll->y() != 0) {
WebCore::IntRect newBounds = mHistory->mNavBounds;
@@ -790,8 +794,8 @@ bool CachedRoot::innerRight(const CachedNode* test, BestData* bestData) const
mScrolledBounds.setWidth(mScrolledBounds.width() + mMaxXScroll);
int testLeft = mScrolledBounds.x();
int viewRight = mViewBounds.right();
- if (mHistory->mFocusBounds.isEmpty() == false &&
- mHistory->mFocusBounds.right() > viewRight && viewRight < mContents.width())
+ if (mFocusBounds.isEmpty() == false &&
+ mFocusBounds.right() > viewRight && viewRight < mContents.width())
return false;
if (mHistory->mNavBounds.isEmpty() == false) {
int navLeft = mHistory->mNavBounds.x();
@@ -814,8 +818,8 @@ bool CachedRoot::innerUp(const CachedNode* test, BestData* bestData) const
mScrolledBounds.setHeight(mScrolledBounds.height() + mMaxYScroll);
int testBottom = mScrolledBounds.bottom();
int viewTop = mViewBounds.y();
- if (mHistory->mFocusBounds.isEmpty() == false &&
- mHistory->mFocusBounds.y() < viewTop && viewTop > mContents.y())
+ if (mFocusBounds.isEmpty() == false &&
+ mFocusBounds.y() < viewTop && viewTop > mContents.y())
return false;
if (mHistory->mNavBounds.isEmpty() == false) {
int navBottom = mHistory->mNavBounds.bottom();
@@ -972,7 +976,7 @@ void CachedRoot::reset()
mMaxXScroll = mMaxYScroll = 0;
mSelectionStart = mSelectionEnd = -1;
mScrollOnly = false;
-// resetNavClipBounds();
+ mFocusBounds = WebCore::IntRect(0, 0, 0, 0);
}
bool CachedRoot::scrollDelta(WebCore::IntRect& newOutset, Direction direction, int* delta)
@@ -1046,6 +1050,11 @@ void CachedRoot::setupScrolledBounds() const
#define DEBUG_PRINT_BOOL(field) \
DUMP_NAV_LOGD("// bool " #field "=%s;\n", b->field ? "true" : "false")
+#define DEBUG_PRINT_RECT(field) \
+ { const WebCore::IntRect& r = b->field; \
+ DUMP_NAV_LOGD("// IntRect " #field "={%d, %d, %d, %d};\n", \
+ r.x(), r.y(), r.width(), r.height()); }
+
CachedRoot* CachedRoot::Debug::base() const {
CachedRoot* nav = (CachedRoot*) ((char*) this - OFFSETOF(CachedRoot, mDebug));
return nav;
@@ -1061,6 +1070,7 @@ void CachedRoot::Debug::print() const
CachedRoot* b = base();
b->CachedFrame::mDebug.print();
b->mHistory->mDebug.print(b);
+ DEBUG_PRINT_RECT(mFocusBounds);
DUMP_NAV_LOGD("// int mMaxXScroll=%d, mMaxYScroll=%d;\n",
b->mMaxXScroll, b->mMaxYScroll);
DEBUG_PRINT_BOOL(mFocusChild);
diff --git a/WebKit/android/nav/CachedRoot.h b/WebKit/android/nav/CachedRoot.h
index 85ddf95..ab1b823 100644
--- a/WebKit/android/nav/CachedRoot.h
+++ b/WebKit/android/nav/CachedRoot.h
@@ -47,6 +47,7 @@ public:
int documentWidth() { return mContents.width(); }
const CachedNode* findAt(const WebCore::IntRect& , const CachedFrame** ,
int* x, int* y) const;
+ const WebCore::IntRect& focusBounds() const { return mFocusBounds; }
bool focusChild() const { return mFocusChild; }
WebCore::IntPoint focusLocation() const;
int generation() const { return mGeneration; }
@@ -72,6 +73,7 @@ public:
bool scrollDelta(WebCore::IntRect& focusRingBounds, Direction , int* delta);
const WebCore::IntRect& scrolledBounds() const { return mScrolledBounds; }
void setCachedFocus(CachedFrame* , CachedNode* );
+ void setFocusBounds(const WebCore::IntRect& r) { mFocusBounds = r; }
void setGeneration(int generation) { mGeneration = generation; }
void setTextGeneration(int textGeneration) { mTextGeneration = textGeneration; }
void setFocusChild(bool state) const { mFocusChild = state; }
@@ -87,7 +89,7 @@ public:
private:
CachedHistory* mHistory;
SkPicture* mPicture;
- // WebCore::IntRect mClippedBounds;
+ WebCore::IntRect mFocusBounds; // chosen focus ring
mutable WebCore::IntRect mScrolledBounds; // view bounds + amount visible as result of scroll
int mGeneration;
int mTextGeneration;
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 64876ab..fc34c84 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -191,8 +191,11 @@ int count()
m_start += triggerSize();
if (m_start == m_end)
break;
- if (m_start >= limit)
- m_start -= sizeof(m_buffer);
+ if (m_start < limit)
+ continue;
+ m_start -= sizeof(m_buffer);
+ if (m_start == m_end)
+ break;
}
m_start = saveStart;
DBG_NAV_LOGD("count=%d", result);
@@ -671,24 +674,23 @@ void drawFocusRing(SkCanvas* canvas)
{
const CachedRoot* root = getFrameCache(AllowNewer);
if (!root) {
- DBG_NAV_LOGD_THROTTLE("!root", DBG_NAV_LOGD_NO_PARAM);
+ DBG_NAV_LOG("!root");
m_followedLink = false;
return;
}
const CachedNode* node = root->currentFocus();
if (!node) {
- DBG_NAV_LOGD_THROTTLE("!node", DBG_NAV_LOGD_NO_PARAM);
+ DBG_NAV_LOG("!node");
m_followedLink = false;
return;
}
if (!node->hasFocusRing()) {
- DBG_NAV_LOGD_THROTTLE("!node->hasFocusRing()",
- DBG_NAV_LOGD_NO_PARAM);
+ DBG_NAV_LOG("!node->hasFocusRing()");
return;
}
const WTF::Vector<WebCore::IntRect>& rings = node->focusRings();
if (!rings.size()) {
- DBG_NAV_LOGD_THROTTLE("!rings.size()", DBG_NAV_LOGD_NO_PARAM);
+ DBG_NAV_LOG("!rings.size()");
return;
}
@@ -714,7 +716,8 @@ void drawFocusRing(SkCanvas* canvas)
SkRect sbounds;
android_setrect(&sbounds, bounds);
if (canvas->quickReject(sbounds, SkCanvas::kAA_EdgeType)) {
- DBG_NAV_LOGD_THROTTLE("canvas->quickReject", DBG_NAV_LOGD_NO_PARAM);
+ DBG_NAV_LOG("canvas->quickReject");
+ m_followedLink = false;
return;
}
FocusRing::Flavor flavor = FocusRing::NORMAL_FLAVOR;
@@ -727,7 +730,7 @@ void drawFocusRing(SkCanvas* canvas)
}
#if DEBUG_NAV_UI
const WebCore::IntRect& ring = rings[0];
- DBG_NAV_LOGD_THROTTLE("cachedFocusNode=%d (nodePointer=%p) flavor=%s rings=%d"
+ DBG_NAV_LOGD("cachedFocusNode=%d (nodePointer=%p) flavor=%s rings=%d"
" (%d, %d, %d, %d)", node->index(), node->nodePointer(),
flavor == FocusRing::FAKE_FLAVOR ? "FAKE_FLAVOR" :
flavor == FocusRing::INVALID_FLAVOR ? "INVALID_FLAVOR" :
@@ -773,9 +776,16 @@ OutOfFocusFix fixOutOfDateFocus(bool useReplay)
if (uiWidth != webWidth) {
DBG_NAV_LOGD("uiWidth=%d webWidth=%d", uiWidth, webWidth);
} else {
- const WebCore::IntRect& cachedBounds = m_frameCacheUI->rootHistory()->focusBounds();
+ const WebCore::IntRect& cachedBounds = m_frameCacheUI->focusBounds();
const CachedFrame* webFrame = 0;
const CachedNode* webFocusNode = webRoot->currentFocus(&webFrame);
+ DBG_NAV_LOGD("cachedBounds=(%d,%d,w=%d,h=%d) cachedFrame=%p (%d)"
+ " webFocusNode=%p (%d) webFrame=%p (%d)",
+ cachedBounds.x(), cachedBounds.y(),
+ cachedBounds.width(), cachedBounds.height(),
+ cachedFrame, cachedFrame ? cachedFrame->indexInParent() : -1,
+ webFocusNode, webFocusNode ? webFocusNode->index() : -1,
+ webFrame, webFrame ? webFrame->indexInParent() : -1);
if (webFocusNode && webFrame && webFrame->sameFrame(cachedFrame)) {
if (useReplay && !m_replay.count()) {
DBG_NAV_LOG("!m_replay.count()");
@@ -785,7 +795,10 @@ OutOfFocusFix fixOutOfDateFocus(bool useReplay)
DBG_NAV_LOG("index ==");
return DoNothing;
}
- const WebCore::IntRect& webBounds = webRoot->rootHistory()->focusBounds();
+ const WebCore::IntRect& webBounds = webRoot->focusBounds();
+ DBG_NAV_LOGD("webBounds=(%d,%d,w=%d,h=%d)",
+ webBounds.x(), webBounds.y(),
+ webBounds.width(), webBounds.height());
if (cachedBounds.contains(webBounds)) {
DBG_NAV_LOG("contains");
return DoNothing;
@@ -794,18 +807,7 @@ OutOfFocusFix fixOutOfDateFocus(bool useReplay)
DBG_NAV_LOG("webBounds contains");
return DoNothing;
}
- DBG_NAV_LOGD("cachedBounds=(%d,%d,w=%d,h=%d) webBounds=(%d,%d,w=%d,"
- "%h=d)", cachedBounds.x(), cachedBounds.y(),
- cachedBounds.width(), cachedBounds.height(), webBounds.x(),
- webBounds.y(), webBounds.width(), webBounds.height());
- } else
- DBG_NAV_LOGD("cachedBounds=(%d,%d,w=%d,h=%d) cachedFrame=%p (%d)"
- " webFocusNode=%p (%d) webFrame=%p (%d)",
- cachedBounds.x(), cachedBounds.y(),
- cachedBounds.width(), cachedBounds.height(),
- cachedFrame, cachedFrame ? cachedFrame->indexInParent() : -1,
- webFocusNode, webFocusNode ? webFocusNode->index() : -1,
- webFrame, webFrame ? webFrame->indexInParent() : -1);
+ }
const CachedFrame* foundFrame = 0;
int x, y;
const CachedNode* found = findAt(webRoot, cachedBounds, &foundFrame, &x, &y);
@@ -1023,7 +1025,8 @@ bool moveFocus(int keyCode, int count, bool ignoreScroll, bool inval,
int dx = 0;
int dy = 0;
int counter = count;
- root->setScrollOnly(m_followedLink);
+ if (!focus || !focus->isInput() || !m_followedLink)
+ root->setScrollOnly(m_followedLink);
while (--counter >= 0) {
WebCore::IntPoint scroll = WebCore::IntPoint(0, 0);
cachedNode = root->moveFocus(direction, &cachedFrame, &scroll);
@@ -1086,7 +1089,7 @@ bool moveFocus(int keyCode, int count, bool ignoreScroll, bool inval,
m_replay.add(params.d.d, sizeof(params));
}
} else {
- if (visibleRect.intersects(root->rootHistory()->focusBounds()) == false) {
+ if (visibleRect.intersects(root->focusBounds()) == false) {
setFocusData(root->generation(), 0, 0, 0, 0, true);
sendKitFocus(); // will build cache and retry
}