summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-10-05 14:22:59 -0400
committerCary Clark <cary@android.com>2009-10-05 14:50:00 -0400
commitfe996bf0a6c5c16a852ae7484bd74421d2492e15 (patch)
tree76ca1559d7c21e07c9f34ddbaa242f3eae20d51e /WebKit
parent62575aed26064570189ef0852283c3fc6bb4e960 (diff)
downloadexternal_webkit-fe996bf0a6c5c16a852ae7484bd74421d2492e15.zip
external_webkit-fe996bf0a6c5c16a852ae7484bd74421d2492e15.tar.gz
external_webkit-fe996bf0a6c5c16a852ae7484bd74421d2492e15.tar.bz2
fix select text if multiple lines are the same width
Text selection works by building a region on the UI side, then finding the text that matches the rectangles making up the decomposed region on the webkit side. If multiple consecutive lines of text are the same width, the region will combine them into a single rectangle instead of one rectangle per line. If the rectangle chooses a single line, it's safe to pick the center of the line in Y, and that's what the old code does. The new code also tries the top and bottom of the rectangle, in case the rectangle spans multiple lines of text, but falls back to the old behavior so not to regress. fixes http://b/issue?id=2166748
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index d81499b..d294cfa 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1528,25 +1528,35 @@ WebCore::String WebViewCore::getSelection(SkRegion* selRgn)
DBG_NAV_LOGD("rect=(%d, %d, %d, %d)", rect.fLeft, rect.fTop,
rect.fRight, rect.fBottom);
int cy = centerY(rect);
- WebCore::IntPoint startPt = WebCore::IntPoint(rect.fLeft + 1, cy);
- WebCore::HitTestResult hitTestResult = m_mainFrame->eventHandler()->
- hitTestResultAtPoint(startPt, false);
- WebCore::Node* node = hitTestResult.innerNode();
+ WebCore::IntPoint startPt, endPt;
+ WebCore::Node* node, * endNode;
+ for (int top = rect.fTop + 1; top != cy; top = cy) {
+ startPt = WebCore::IntPoint(rect.fLeft + 1, top);
+ WebCore::HitTestResult hitTestResult = m_mainFrame->eventHandler()->
+ hitTestResultAtPoint(startPt, false);
+ node = hitTestResult.innerNode();
+ if (node)
+ break;
+ DBG_NAV_LOGD("!node (%s)", top != cy ? "top+1" : "cy");
+ }
if (!node) {
DBG_NAV_LOG("!node");
return result;
}
- WebCore::IntPoint endPt = WebCore::IntPoint(rect.fRight - 1, cy);
- hitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(endPt, false);
- WebCore::Node* endNode = hitTestResult.innerNode();
- if (!endNode) {
- DBG_NAV_LOG("!endNode (right-1)");
- endPt = WebCore::IntPoint(rect.fRight - 2, cy);
- hitTestResult = m_mainFrame->eventHandler()->hitTestResultAtPoint(endPt, false);
- endNode = hitTestResult.innerNode();
+ for (int bottom = rect.fBottom - 1; bottom != cy; bottom = cy) {
+ for (int right = rect.fRight - 1; right != rect.fRight-2; --right) {
+ endPt = WebCore::IntPoint(right, bottom);
+ WebCore::HitTestResult hitTestResult = m_mainFrame->
+ eventHandler()->hitTestResultAtPoint(endPt, false);
+ endNode = hitTestResult.innerNode();
+ if (endNode)
+ break;
+ DBG_NAV_LOGD("!endNode (%s) (right-%d)",
+ bottom != cy ? "bottom-1" : "cy", rect.fRight - right);
+ }
}
if (!endNode) {
- DBG_NAV_LOG("!endNode (right-2)");
+ DBG_NAV_LOG("!endNode");
return result;
}
int start = findTextBoxIndex(node, startPt);