summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2010-11-05 15:42:22 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2010-11-16 16:37:37 -0800
commit9b756acfbd55b901e37766b034e7af3ad08dc757 (patch)
treefa371c12a07cdc9fc46e7c915d4556385edacc12
parent0dcea08af30465407201a77d660a8b7500a024b5 (diff)
downloadframeworks_base-9b756acfbd55b901e37766b034e7af3ad08dc757.zip
frameworks_base-9b756acfbd55b901e37766b034e7af3ad08dc757.tar.gz
frameworks_base-9b756acfbd55b901e37766b034e7af3ad08dc757.tar.bz2
Metakeys incorrectly delivered to JavaScript
Change-Id: I373eee0c4eb44c2dfd1e8534f5cb241e0c04a473
-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 06800d5..f987a49 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -4185,9 +4185,8 @@ public class WebView extends AbsoluteLayout
if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
|| keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
- if (pageShouldHandleShiftAndArrows()) {
- mShiftIsPressed = true;
- } else if (!nativeCursorWantsKeyEvents() && !mSelectingText) {
+ if (!pageShouldHandleShiftAndArrows() && !nativeCursorWantsKeyEvents()
+ && !mSelectingText) {
setUpSelect();
}
}
@@ -4206,7 +4205,7 @@ public class WebView extends AbsoluteLayout
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
switchOutDrawHistory();
if (pageShouldHandleShiftAndArrows()) {
- letPageHandleNavKey(keyCode, event.getEventTime(), true);
+ letPageHandleNavKey(keyCode, event.getEventTime(), true, event.getMetaState());
return true;
}
if (mSelectingText) {
@@ -4248,7 +4247,6 @@ public class WebView extends AbsoluteLayout
&& keyCode != KeyEvent.KEYCODE_SHIFT_RIGHT) {
// turn off copy select if a shift-key combo is pressed
selectionDone();
- mShiftIsPressed = false;
}
if (getSettings().getNavDump()) {
@@ -4339,9 +4337,7 @@ public class WebView extends AbsoluteLayout
if (keyCode == KeyEvent.KEYCODE_SHIFT_LEFT
|| keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT) {
- if (pageShouldHandleShiftAndArrows()) {
- mShiftIsPressed = false;
- } else if (copySelection()) {
+ if (!pageShouldHandleShiftAndArrows() && copySelection()) {
selectionDone();
return true;
}
@@ -4350,7 +4346,7 @@ public class WebView extends AbsoluteLayout
if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
if (pageShouldHandleShiftAndArrows()) {
- letPageHandleNavKey(keyCode, event.getEventTime(), false);
+ letPageHandleNavKey(keyCode, event.getEventTime(), false, event.getMetaState());
return true;
}
// always handle the navigation keys in the UI thread
@@ -4592,7 +4588,6 @@ public class WebView extends AbsoluteLayout
mDrawCursorRing = false;
}
mGotKeyDown = false;
- mShiftIsPressed = false;
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
mTouchMode = TOUCH_DONE_MODE;
if (mNativeClass != 0) {
@@ -5529,7 +5524,6 @@ public class WebView extends AbsoluteLayout
private int mSelectX = 0;
private int mSelectY = 0;
private boolean mFocusSizeChanged = false;
- private boolean mShiftIsPressed = false;
private boolean mTrackballDown = false;
private long mTrackballUpTime = 0;
private long mLastCursorTime = 0;
@@ -5600,7 +5594,7 @@ public class WebView extends AbsoluteLayout
}
return false; // let common code in onKeyUp at it
}
- if ((mMapTrackballToArrowKeys && mShiftIsPressed == false) ||
+ if ((mMapTrackballToArrowKeys && (ev.getMetaState() & KeyEvent.META_SHIFT_ON) == 0) ||
(mAccessibilityInjector != null || mAccessibilityScriptInjected)) {
if (DebugFlags.WEB_VIEW) Log.v(LOGTAG, "onTrackballEvent gmail quit");
return false;
@@ -5629,7 +5623,7 @@ public class WebView extends AbsoluteLayout
}
mTrackballRemainsX += ev.getX();
mTrackballRemainsY += ev.getY();
- doTrackball(time);
+ doTrackball(time, ev.getMetaState());
return true;
}
@@ -5713,7 +5707,7 @@ public class WebView extends AbsoluteLayout
"KEYCODE_DPAD_LEFT}.");
}
- private void doTrackball(long time) {
+ private void doTrackball(long time, int metaState) {
int elapsed = (int) (mTrackballLastTime - mTrackballFirstTime);
if (elapsed == 0) {
elapsed = TRACKBALL_TIMEOUT;
@@ -5771,9 +5765,9 @@ public class WebView extends AbsoluteLayout
}
if (mNativeClass != 0 && nativePageShouldHandleShiftAndArrows()) {
for (int i = 0; i < count; i++) {
- letPageHandleNavKey(selectKeyCode, time, true);
+ letPageHandleNavKey(selectKeyCode, time, true, metaState);
}
- letPageHandleNavKey(selectKeyCode, time, false);
+ letPageHandleNavKey(selectKeyCode, time, false, metaState);
} else if (navHandledKey(selectKeyCode, count, false, time)) {
playSoundEffect(keyCodeToSoundsEffect(selectKeyCode));
}
@@ -7282,7 +7276,7 @@ public class WebView extends AbsoluteLayout
* Pass the key directly to the page. This assumes that
* nativePageShouldHandleShiftAndArrows() returned true.
*/
- private void letPageHandleNavKey(int keyCode, long time, boolean down) {
+ private void letPageHandleNavKey(int keyCode, long time, boolean down, int metaState) {
int keyEventAction;
int eventHubAction;
if (down) {
@@ -7293,10 +7287,11 @@ public class WebView extends AbsoluteLayout
keyEventAction = KeyEvent.ACTION_UP;
eventHubAction = EventHub.KEY_UP;
}
+
KeyEvent event = new KeyEvent(time, time, keyEventAction, keyCode,
- 1, (mShiftIsPressed ? KeyEvent.META_SHIFT_ON : 0)
- | (false ? KeyEvent.META_ALT_ON : 0) // FIXME
- | (false ? KeyEvent.META_SYM_ON : 0) // FIXME
+ 1, (metaState & KeyEvent.META_SHIFT_ON)
+ | (metaState & KeyEvent.META_ALT_ON)
+ | (metaState & KeyEvent.META_SYM_ON)
, 0, 0, 0);
mWebViewCore.sendMessage(eventHubAction, event);
}