summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/WebView.java
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-12-23 13:57:15 -0500
committerCary Clark <cary@android.com>2010-01-05 10:31:04 -0500
commit57d2c3ad1929f0eff7e0abc47c28c09f32ac5494 (patch)
tree8b83d0a9ed1f62764329b684dd47018dbcabd7dc /core/java/android/webkit/WebView.java
parent2f389aa3ac046f3966bbd6d53a4e7c97070299ab (diff)
downloadframeworks_base-57d2c3ad1929f0eff7e0abc47c28c09f32ac5494.zip
frameworks_base-57d2c3ad1929f0eff7e0abc47c28c09f32ac5494.tar.gz
frameworks_base-57d2c3ad1929f0eff7e0abc47c28c09f32ac5494.tar.bz2
extract selected text from the picture
This deletes the messages between WebView and WebViewCore that pass a region and extracts the rendered text and returns the selected text from WebView directly. This requires companion changes in external/webkit, which in turn is dependent on changes to external/skia. Fixes http://b/2166748
Diffstat (limited to 'core/java/android/webkit/WebView.java')
-rw-r--r--core/java/android/webkit/WebView.java35
1 files changed, 15 insertions, 20 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index f58446a..b301d31 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -486,7 +486,7 @@ public class WebView extends AbsoluteLayout
static final int MOVE_OUT_OF_PLUGIN = 19;
static final int CLEAR_TEXT_ENTRY = 20;
static final int UPDATE_TEXT_SELECTION_MSG_ID = 21;
- static final int UPDATE_CLIPBOARD = 22;
+
static final int LONG_PRESS_CENTER = 23;
static final int PREVENT_TOUCH_ID = 24;
static final int WEBCORE_NEED_TOUCH_EVENTS = 25;
@@ -522,7 +522,7 @@ public class WebView extends AbsoluteLayout
"MOVE_OUT_OF_PLUGIN", // = 19;
"CLEAR_TEXT_ENTRY", // = 20;
"UPDATE_TEXT_SELECTION_MSG_ID", // = 21;
- "UPDATE_CLIPBOARD", // = 22;
+ "22", // = 22;
"LONG_PRESS_CENTER", // = 23;
"PREVENT_TOUCH_ID", // = 24;
"WEBCORE_NEED_TOUCH_EVENTS", // = 25;
@@ -3661,14 +3661,22 @@ public class WebView extends AbsoluteLayout
private boolean commitCopy() {
boolean copiedSomething = false;
if (mExtendSelection) {
- // copy region so core operates on copy without touching orig.
- Region selection = new Region(nativeGetSelection());
- if (selection.isEmpty() == false) {
+ String selection = nativeGetSelection();
+ if (selection != "") {
+ if (DebugFlags.WEB_VIEW) {
+ Log.v(LOGTAG, "commitCopy \"" + selection + "\"");
+ }
Toast.makeText(mContext
, com.android.internal.R.string.text_copied
, Toast.LENGTH_SHORT).show();
- mWebViewCore.sendMessage(EventHub.GET_SELECTION, selection);
copiedSomething = true;
+ try {
+ IClipboard clip = IClipboard.Stub.asInterface(
+ ServiceManager.getService("clipboard"));
+ clip.setClipboardText(selection);
+ } catch (android.os.RemoteException e) {
+ Log.e(LOGTAG, "Clipboard failed", e);
+ }
}
mExtendSelection = false;
}
@@ -5655,19 +5663,6 @@ public class WebView extends AbsoluteLayout
mWebTextView.setAdapterCustom(adapter);
}
break;
- case UPDATE_CLIPBOARD:
- String str = (String) msg.obj;
- if (DebugFlags.WEB_VIEW) {
- Log.v(LOGTAG, "UPDATE_CLIPBOARD " + str);
- }
- try {
- IClipboard clip = IClipboard.Stub.asInterface(
- ServiceManager.getService("clipboard"));
- clip.setClipboardText(str);
- } catch (android.os.RemoteException e) {
- Log.e(LOGTAG, "Clipboard failed", e);
- }
- break;
case RESUME_WEBCORE_UPDATE:
WebViewCore.resumeUpdate(mWebViewCore);
break;
@@ -6369,7 +6364,7 @@ public class WebView extends AbsoluteLayout
private native boolean nativeFocusIsPlugin();
/* package */ native int nativeFocusNodePointer();
private native Rect nativeGetCursorRingBounds();
- private native Region nativeGetSelection();
+ private native String nativeGetSelection();
private native boolean nativeHasCursorNode();
private native boolean nativeHasFocusNode();
private native void nativeHideCursor();