summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav/CachedFrame.cpp
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-01-06 10:49:08 -0500
committerLeon Scroggins <scroggo@google.com>2010-01-06 14:43:13 -0500
commite5e9720d88df20ad1116d709ec078cec419ffcf4 (patch)
tree358f786db7eee325604410e6aef71889555b9b71 /WebKit/android/nav/CachedFrame.cpp
parent62d9c8e597ebe68adce93008597730a41a1d716b (diff)
downloadexternal_webkit-e5e9720d88df20ad1116d709ec078cec419ffcf4.zip
external_webkit-e5e9720d88df20ad1116d709ec078cec419ffcf4.tar.gz
external_webkit-e5e9720d88df20ad1116d709ec078cec419ffcf4.tar.bz2
In findBestHitAt, set x and y to the intersection of slop and cursor.
Fixes http://b/issue?id=2201866
Diffstat (limited to 'WebKit/android/nav/CachedFrame.cpp')
-rw-r--r--WebKit/android/nav/CachedFrame.cpp50
1 files changed, 22 insertions, 28 deletions
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp
index a95a401..299dc53 100644
--- a/WebKit/android/nav/CachedFrame.cpp
+++ b/WebKit/android/nav/CachedFrame.cpp
@@ -441,14 +441,18 @@ const CachedFrame* CachedFrame::findBestFrameAt(int x, int y) const
}
const CachedNode* CachedFrame::findBestHitAt(const WebCore::IntRect& rect,
- int* best, const CachedFrame** framePtr, int* x, int* y) const
+ const CachedFrame** framePtr, int* x, int* y) const
{
- const CachedNode* result = NULL;
- int rectWidth = rect.width();
- WebCore::IntPoint center = WebCore::IntPoint(rect.x() + (rectWidth >> 1),
- rect.y() + (rect.height() >> 1));
mRoot->setupScrolledBounds();
- for (const CachedNode* test = mCachedNodes.begin(); test != mCachedNodes.end(); test++) {
+ for (const CachedFrame* frame = mCachedFrames.end() - 1;
+ frame != mCachedFrames.begin() - 1; frame--) {
+ const CachedNode* frameResult = frame->findBestHitAt(rect,
+ framePtr, x, y);
+ if (NULL != frameResult)
+ return frameResult;
+ }
+ for (const CachedNode* test = mCachedNodes.end() - 1;
+ test != mCachedNodes.begin() - 1; test--) {
if (test->disabled())
continue;
const WebCore::IntRect& testRect = test->hitBounds();
@@ -459,29 +463,19 @@ const CachedNode* CachedFrame::findBestHitAt(const WebCore::IntRect& rect,
testData.mMouseBounds = testData.mNodeBounds = testRect;
if (mRoot->maskIfHidden(&testData) == true)
continue;
- const WebCore::IntRect& bounds = testData.mMouseBounds;
- WebCore::IntPoint testCenter = WebCore::IntPoint(bounds.x() +
- (bounds.width() >> 1), bounds.y() + (bounds.height() >> 1));
- int dx = testCenter.x() - center.x();
- int dy = testCenter.y() - center.y();
- int distance = dx * dx + dy * dy;
- if (*best < distance)
- continue;
- *best = distance;
- result = test;
- *framePtr = this;
- const WebCore::IntRect& cursorRect = test->cursorRings().at(0);
- *x = cursorRect.x() + (cursorRect.width() >> 1);
- *y = cursorRect.y() + (cursorRect.height() >> 1);
- }
- for (const CachedFrame* frame = mCachedFrames.begin();
- frame != mCachedFrames.end(); frame++) {
- const CachedNode* frameResult = frame->findBestHitAt(rect, best,
- framePtr, x, y);
- if (NULL != frameResult)
- result = frameResult;
+ for (unsigned i = 0; i < test->cursorRings().size(); i++) {
+ const WebCore::IntRect& cursorRect = test->cursorRings().at(i);
+ if (cursorRect.intersects(rect)) {
+ WebCore::IntRect intersection(cursorRect);
+ intersection.intersect(rect);
+ *x = intersection.x() + (intersection.width() >> 1);
+ *y = intersection.y() + (intersection.height() >> 1);
+ *framePtr = this;
+ return test;
+ }
+ }
}
- return result;
+ return NULL;
}
void CachedFrame::findClosest(BestData* bestData, Direction originalDirection,