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
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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 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 @@
         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 @@
         (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 },