check to see if nav cache is up to date on tap
Pass point to click in three steps. 1) See if point corresponds to cached node. 2) If so,send a message to webkit to see if the node is good. 3) Call webkit with point, and good/bad info. This is a two-part change with external/webkit. Fixes http://b/2249425
This commit is contained in:
@@ -486,6 +486,7 @@ public class WebView extends AbsoluteLayout
|
||||
// obj=Rect in doc coordinates
|
||||
static final int INVAL_RECT_MSG_ID = 26;
|
||||
static final int REQUEST_KEYBOARD = 27;
|
||||
static final int DO_MOTION_UP = 28;
|
||||
|
||||
static final String[] HandlerDebugString = {
|
||||
"REMEMBER_PASSWORD", // = 1;
|
||||
@@ -514,7 +515,8 @@ public class WebView extends AbsoluteLayout
|
||||
"PREVENT_TOUCH_ID", // = 24;
|
||||
"WEBCORE_NEED_TOUCH_EVENTS", // = 25;
|
||||
"INVAL_RECT_MSG_ID", // = 26;
|
||||
"REQUEST_KEYBOARD" // = 27;
|
||||
"REQUEST_KEYBOARD", // = 27;
|
||||
"DO_MOTION_UP" // = 28;
|
||||
};
|
||||
|
||||
// If the site doesn't use the viewport meta tag to specify the viewport,
|
||||
@@ -4852,7 +4854,23 @@ public class WebView extends AbsoluteLayout
|
||||
// mLastTouchX and mLastTouchY are the point in the current viewport
|
||||
int contentX = viewToContentX((int) mLastTouchX + mScrollX);
|
||||
int contentY = viewToContentY((int) mLastTouchY + mScrollY);
|
||||
if (nativeMotionUp(contentX, contentY, mNavSlop)) {
|
||||
if (nativePointInNavCache(contentX, contentY, mNavSlop)) {
|
||||
WebViewCore.MotionUpData motionUpData = new WebViewCore
|
||||
.MotionUpData();
|
||||
motionUpData.mFrame = nativeCacheHitFramePointer();
|
||||
motionUpData.mNode = nativeCacheHitNodePointer();
|
||||
motionUpData.mBounds = nativeCacheHitNodeBounds();
|
||||
motionUpData.mX = contentX;
|
||||
motionUpData.mY = contentY;
|
||||
mWebViewCore.sendMessageAtFrontOfQueue(EventHub.VALID_NODE_BOUNDS,
|
||||
motionUpData);
|
||||
} else {
|
||||
doMotionUp(contentX, contentY, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void doMotionUp(int contentX, int contentY, boolean useNavCache) {
|
||||
if (nativeMotionUp(contentX, contentY, useNavCache ? mNavSlop : 0)) {
|
||||
if (mLogEvent) {
|
||||
Checkin.updateStats(mContext.getContentResolver(),
|
||||
Checkin.Stats.Tag.BROWSER_SNAP_CENTER, 1, 0.0);
|
||||
@@ -5097,7 +5115,7 @@ public class WebView extends AbsoluteLayout
|
||||
// exclude INVAL_RECT_MSG_ID since it is frequently output
|
||||
if (DebugFlags.WEB_VIEW && msg.what != INVAL_RECT_MSG_ID) {
|
||||
Log.v(LOGTAG, msg.what < REMEMBER_PASSWORD || msg.what
|
||||
> REQUEST_KEYBOARD ? Integer.toString(msg.what)
|
||||
> DO_MOTION_UP ? Integer.toString(msg.what)
|
||||
: HandlerDebugString[msg.what - REMEMBER_PASSWORD]);
|
||||
}
|
||||
if (mWebViewCore == null) {
|
||||
@@ -5443,6 +5461,11 @@ public class WebView extends AbsoluteLayout
|
||||
ViewConfiguration.getScrollDefaultDelay());
|
||||
}
|
||||
break;
|
||||
|
||||
case DO_MOTION_UP:
|
||||
doMotionUp(msg.arg1, msg.arg2, (Boolean) msg.obj);
|
||||
break;
|
||||
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
break;
|
||||
@@ -5931,6 +5954,9 @@ public class WebView extends AbsoluteLayout
|
||||
nativeUpdateCachedTextfield(updatedText, mTextGeneration);
|
||||
}
|
||||
|
||||
private native int nativeCacheHitFramePointer();
|
||||
private native Rect nativeCacheHitNodeBounds();
|
||||
private native int nativeCacheHitNodePointer();
|
||||
/* package */ native void nativeClearCursor();
|
||||
private native void nativeCreate(int ptr);
|
||||
private native int nativeCursorFramePointer();
|
||||
@@ -5992,6 +6018,7 @@ public class WebView extends AbsoluteLayout
|
||||
private native int nativeMoveGeneration();
|
||||
private native void nativeMoveSelection(int x, int y,
|
||||
boolean extendSelection);
|
||||
private native boolean nativePointInNavCache(int x, int y, int slop);
|
||||
// Like many other of our native methods, you must make sure that
|
||||
// mNativeClass is not null before calling this method.
|
||||
private native void nativeRecordButtons(boolean focused,
|
||||
|
||||
@@ -683,6 +683,14 @@ final class WebViewCore {
|
||||
KeyEvent mEvent;
|
||||
}
|
||||
|
||||
static class MotionUpData {
|
||||
int mFrame;
|
||||
int mNode;
|
||||
Rect mBounds;
|
||||
int mX;
|
||||
int mY;
|
||||
}
|
||||
|
||||
static class PostUrlData {
|
||||
String mUrl;
|
||||
byte[] mPostData;
|
||||
@@ -778,6 +786,7 @@ final class WebViewCore {
|
||||
"ON_PAUSE", // = 143
|
||||
"ON_RESUME", // = 144
|
||||
"FREE_MEMORY", // = 145
|
||||
"VALID_NODE_BOUNDS", // = 146
|
||||
};
|
||||
|
||||
class EventHub {
|
||||
@@ -841,6 +850,7 @@ final class WebViewCore {
|
||||
static final int ON_PAUSE = 143;
|
||||
static final int ON_RESUME = 144;
|
||||
static final int FREE_MEMORY = 145;
|
||||
static final int VALID_NODE_BOUNDS = 146;
|
||||
|
||||
// Network-based messaging
|
||||
static final int CLEAR_SSL_PREF_TABLE = 150;
|
||||
@@ -893,7 +903,7 @@ final class WebViewCore {
|
||||
if (DebugFlags.WEB_VIEW_CORE) {
|
||||
Log.v(LOGTAG, (msg.what < UPDATE_FRAME_CACHE_IF_LOADING
|
||||
|| msg.what
|
||||
> FREE_MEMORY ? Integer.toString(msg.what)
|
||||
> VALID_NODE_BOUNDS ? Integer.toString(msg.what)
|
||||
: HandlerDebugString[msg.what
|
||||
- UPDATE_FRAME_CACHE_IF_LOADING])
|
||||
+ " arg1=" + msg.arg1 + " arg2=" + msg.arg2
|
||||
@@ -1289,6 +1299,20 @@ final class WebViewCore {
|
||||
case POPULATE_VISITED_LINKS:
|
||||
nativeProvideVisitedHistory((String[])msg.obj);
|
||||
break;
|
||||
|
||||
case VALID_NODE_BOUNDS: {
|
||||
MotionUpData motionUpData = (MotionUpData) msg.obj;
|
||||
boolean result = nativeValidNodeAndBounds(
|
||||
motionUpData.mFrame, motionUpData.mNode,
|
||||
motionUpData.mBounds);
|
||||
Message message = mWebView.mPrivateHandler
|
||||
.obtainMessage(WebView.DO_MOTION_UP,
|
||||
motionUpData.mX, motionUpData.mY,
|
||||
new Boolean(result));
|
||||
mWebView.mPrivateHandler.sendMessageAtFrontOfQueue(
|
||||
message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1432,6 +1456,11 @@ final class WebViewCore {
|
||||
mEventHub.sendMessage(Message.obtain(null, what, arg1, arg2, obj));
|
||||
}
|
||||
|
||||
void sendMessageAtFrontOfQueue(int what, Object obj) {
|
||||
mEventHub.sendMessageAtFrontOfQueue(Message.obtain(
|
||||
null, what, obj));
|
||||
}
|
||||
|
||||
void sendMessageDelayed(int what, Object obj, long delay) {
|
||||
mEventHub.sendMessageDelayed(Message.obtain(null, what, obj), delay);
|
||||
}
|
||||
@@ -2275,4 +2304,7 @@ final class WebViewCore {
|
||||
private native void nativeResume();
|
||||
private native void nativeFreeMemory();
|
||||
private native void nativeFullScreenPluginHidden(int npp);
|
||||
private native boolean nativeValidNodeAndBounds(int frame, int node,
|
||||
Rect bounds);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user