summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-10-15 13:22:12 -0400
committerCary Clark <cary@android.com>2009-10-15 13:54:50 -0400
commit31f7153b80559d0b0580ce91bd1465aea7588aa2 (patch)
treef6908504d1da55df7095796bcd76c52be9e3d159 /WebKit/android/nav
parent734b5134dfb8de1717b5772d41dd8fdcc093980e (diff)
downloadexternal_webkit-31f7153b80559d0b0580ce91bd1465aea7588aa2.zip
external_webkit-31f7153b80559d0b0580ce91bd1465aea7588aa2.tar.gz
external_webkit-31f7153b80559d0b0580ce91bd1465aea7588aa2.tar.bz2
fix copy/paste using trackball on passion
This fix should be considered for passion mr1, but does not affect sholes -- this is a trackball only bug. The selection caret and arrow now take the scale factor and the height of the title bar into account when preparing the canvas for drawing. Also, simply call to CopyPaste::findClosest, and remove logic to attempt to pin the arrow to the current cursor. Requires a companion fix in framework/base Fixes http://b/issue?id=2187591
Diffstat (limited to 'WebKit/android/nav')
-rw-r--r--WebKit/android/nav/WebView.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 37342d2..23a1ec0 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -1086,10 +1086,9 @@ void moveSelection(int x, int y, bool extendSelection)
getVisibleRect(&r);
SkIRect area;
area.set(r.x(), r.y(), r.right(), r.bottom());
+ m_selEnd = CopyPaste::findClosest(picture, area, x, y);
if (!extendSelection)
- m_selStart = m_selEnd = CopyPaste::findClosest(picture, area, x, y);
- else
- m_selEnd = CopyPaste::findClosest(picture, area, x, y);
+ m_selStart = m_selEnd;
DBG_NAV_LOGD("x=%d y=%d extendSelection=%s m_selStart=(%d, %d, %d, %d)"
" m_selEnd=(%d, %d, %d, %d)", x, y, extendSelection ? "true" : "false",
m_selStart.fLeft, m_selStart.fTop, m_selStart.fRight, m_selStart.fBottom,
@@ -1101,23 +1100,14 @@ const SkRegion& getSelection()
return m_selRegion;
}
-void drawSelection(SkCanvas* canvas, int x, int y, bool extendSelection)
+void drawSelection(SkCanvas* canvas, float scale, int offset, int x, int y,
+ bool extendSelection)
{
if (!extendSelection) {
- int dx = x - m_selStart.fLeft;
- dx *= dx;
- int otherX = x - m_selStart.fRight;
- if (dx > (otherX *= otherX))
- dx = otherX;
- int dy = y - m_selStart.fTop;
- int dist = dx * dx + dy * dy;
- if (dist > MIN_ARROW_DISTANCE)
- drawSelectionArrow(canvas, x, y);
- else
- drawSelectionPointer(canvas, x, y, true);
+ drawSelectionArrow(canvas, scale, x, y - offset);
} else {
drawSelectionRegion(canvas);
- drawSelectionPointer(canvas, x, y, false);
+ drawSelectionPointer(canvas, scale, offset, x, y, false);
}
}
@@ -1140,7 +1130,8 @@ void drawSelectionRegion(SkCanvas* canvas)
canvas->drawPath(path, paint);
}
-void drawSelectionPointer(SkCanvas* canvas, int x, int y, bool gridded)
+void drawSelectionPointer(SkCanvas* canvas, float scale, int offset,
+ int x, int y, bool gridded)
{
SkPath path;
getSelectionCaret(&path);
@@ -1151,6 +1142,8 @@ void drawSelectionPointer(SkCanvas* canvas, int x, int y, bool gridded)
SkPixelXorXfermode xorMode(SK_ColorWHITE);
paint.setXfermode(&xorMode);
int sc = canvas->save();
+ canvas->scale(scale, scale);
+ canvas->translate(0, -SkIntToScalar(offset));
if (gridded) {
bool useLeft = x <= (m_selStart.fLeft + m_selStart.fRight) >> 1;
canvas->translate(SkIntToScalar(useLeft ? m_selStart.fLeft :
@@ -1161,7 +1154,7 @@ void drawSelectionPointer(SkCanvas* canvas, int x, int y, bool gridded)
canvas->restoreToCount(sc);
}
-void drawSelectionArrow(SkCanvas* canvas, int x, int y)
+void drawSelectionArrow(SkCanvas* canvas, float scale, int x, int y)
{
SkPath path;
getSelectionArrow(&path);
@@ -1171,6 +1164,7 @@ void drawSelectionArrow(SkCanvas* canvas, int x, int y)
paint.setColor(SK_ColorBLACK);
paint.setStrokeWidth(SK_Scalar1 * 2);
int sc = canvas->save();
+ canvas->scale(scale, scale);
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
canvas->drawPath(path, paint);
paint.setStyle(SkPaint::kFill_Style);
@@ -1623,7 +1617,7 @@ static void nativeDrawCursorRing(JNIEnv *env, jobject obj, jobject canv)
}
static void nativeDrawSelection(JNIEnv *env, jobject obj,
- jobject canv, jint x, jint y, bool ex)
+ jobject canv, jfloat scale, jint offset, jint x, jint y, bool ex)
{
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv);
if (!canv) {
@@ -1635,7 +1629,7 @@ static void nativeDrawSelection(JNIEnv *env, jobject obj,
DBG_NAV_LOG("!view");
return;
}
- view->drawSelection(canvas, x, y, ex);
+ view->drawSelection(canvas, scale, offset, x, y, ex);
}
static void nativeDrawSelectionRegion(JNIEnv *env, jobject obj, jobject canv)
@@ -2116,7 +2110,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeDrawCursorRing },
{ "nativeDrawMatches", "(Landroid/graphics/Canvas;)V",
(void*) nativeDrawMatches },
- { "nativeDrawSelection", "(Landroid/graphics/Canvas;IIZ)V",
+ { "nativeDrawSelection", "(Landroid/graphics/Canvas;FIIIZ)V",
(void*) nativeDrawSelection },
{ "nativeDrawSelectionRegion", "(Landroid/graphics/Canvas;)V",
(void*) nativeDrawSelectionRegion },