Methods Summary |
---|
void | contentDraw()
// don't update the Picture until we have an initial width and finish
// the first layout
if (mCurrentViewWidth == 0 || !mBrowserFrame.firstLayoutDone()) {
return;
}
// only fire an event if this is our first request
synchronized (this) {
if (mDrawIsPaused || mDrawIsScheduled) {
return;
}
mDrawIsScheduled = true;
mEventHub.sendMessage(Message.obtain(null, EventHub.WEBKIT_DRAW));
}
|
private void | contentScrollBy(int dx, int dy, boolean animate)
if (!mBrowserFrame.firstLayoutDone()) {
// Will this happen? If yes, we need to do something here.
return;
}
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.SCROLL_BY_MSG_ID, dx, dy,
new Boolean(animate)).sendToTarget();
}
|
private void | contentScrollTo(int x, int y)
if (!mBrowserFrame.firstLayoutDone()) {
/*
* WebKit restore state will be called before didFirstLayout(),
* remember the position as it has to be applied after restoring
* zoom factor which is controlled by screenWidth.
*/
mRestoredX = x;
mRestoredY = y;
return;
}
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.SCROLL_TO_MSG_ID, x, y).sendToTarget();
}
|
private void | contentSpawnScrollTo(int x, int y)
if (!mBrowserFrame.firstLayoutDone()) {
/*
* WebKit restore state will be called before didFirstLayout(),
* remember the position as it has to be applied after restoring
* zoom factor which is controlled by screenWidth.
*/
mRestoredX = x;
mRestoredY = y;
return;
}
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.SPAWN_SCROLL_TO_MSG_ID, x, y).sendToTarget();
}
|
android.graphics.Picture | copyContentPicture()
Picture result = new Picture();
nativeCopyContentToPicture(result);
return result;
|
void | destroy()Removes pending messages and trigger a DESTROY message to send to
WebCore.
Called from UI thread.
// We don't want anyone to post a message between removing pending
// messages and sending the destroy message.
synchronized (mEventHub) {
mEventHub.removeMessages();
mEventHub.sendMessageAtFrontOfQueue(
Message.obtain(null, EventHub.DESTROY));
mEventHub.blockMessages();
mWebView = null;
}
|
private void | didFirstLayout()
// Trick to ensure that the Picture has the exact height for the content
// by forcing to layout with 0 height after the page is ready, which is
// indicated by didFirstLayout. This is essential to get rid of the
// white space in the GMail which uses WebView for message view.
if (mWebView != null && mWebView.mHeightCanMeasure) {
mWebView.mLastHeightSent = 0;
// Send a negative scale to indicate that WebCore should reuse the
// current scale
mEventHub.sendMessage(Message.obtain(null,
EventHub.VIEW_SIZE_CHANGED, mWebView.mLastWidthSent,
mWebView.mLastHeightSent, -1.0f));
}
mBrowserFrame.didFirstLayout();
// reset the scroll position as it is a new page now
mWebkitScrollX = mWebkitScrollY = 0;
// set the viewport settings from WebKit
setViewportSettingsFromNative();
// infer the values if they are not defined.
if (mViewportWidth == 0) {
if (mViewportInitialScale == 0) {
mViewportInitialScale = 100;
}
if (mViewportMinimumScale == 0) {
mViewportMinimumScale = 100;
}
}
if (mViewportUserScalable == false) {
mViewportInitialScale = 100;
mViewportMinimumScale = 100;
mViewportMaximumScale = 100;
}
if (mViewportMinimumScale > mViewportInitialScale) {
if (mViewportInitialScale == 0) {
mViewportInitialScale = mViewportMinimumScale;
} else {
mViewportMinimumScale = mViewportInitialScale;
}
}
if (mViewportMaximumScale > 0) {
if (mViewportMaximumScale < mViewportInitialScale) {
mViewportMaximumScale = mViewportInitialScale;
} else if (mViewportInitialScale == 0) {
mViewportInitialScale = mViewportMaximumScale;
}
}
if (mViewportWidth < 0 && mViewportInitialScale == 100) {
mViewportWidth = 0;
}
// now notify webview
if (mWebView != null) {
HashMap scaleLimit = new HashMap();
scaleLimit.put("minScale", mViewportMinimumScale);
scaleLimit.put("maxScale", mViewportMaximumScale);
if (mRestoredScale > 0) {
Message.obtain(mWebView.mPrivateHandler,
WebView.DID_FIRST_LAYOUT_MSG_ID, mRestoredScale, 0,
scaleLimit).sendToTarget();
mRestoredScale = 0;
} else {
Message.obtain(mWebView.mPrivateHandler,
WebView.DID_FIRST_LAYOUT_MSG_ID, mViewportInitialScale,
mViewportWidth, scaleLimit).sendToTarget();
}
// if no restored offset, move the new page to (0, 0)
Message.obtain(mWebView.mPrivateHandler, WebView.SCROLL_TO_MSG_ID,
mRestoredX, mRestoredY).sendToTarget();
mRestoredX = mRestoredY = 0;
// force an early draw for quick feedback after the first layout
if (mCurrentViewWidth != 0) {
synchronized (this) {
if (mDrawIsScheduled) {
mEventHub.removeMessages(EventHub.WEBKIT_DRAW);
}
mDrawIsScheduled = true;
mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,
EventHub.WEBKIT_DRAW));
}
}
}
|
void | drawContentPicture(android.graphics.Canvas canvas, int color, boolean animatingZoom, boolean animatingScroll)
/* package */
DrawFilter df = null;
if (animatingZoom) {
df = mZoomFilter;
} else if (animatingScroll) {
df = mScrollFilter;
}
canvas.setDrawFilter(df);
boolean tookTooLong = nativeDrawContent(canvas, color);
canvas.setDrawFilter(null);
if (tookTooLong && mSplitPictureIsScheduled == false) {
mSplitPictureIsScheduled = true;
sendMessage(EventHub.SPLIT_PICTURE_SET);
}
|
static void | endCacheTransaction()
sWebCoreHandler.sendMessage(sWebCoreHandler
.obtainMessage(WebCoreThread.BLOCK_CACHE_TICKER));
|
BrowserFrame | getBrowserFrame()
return mBrowserFrame;
|
public WebSettings | getSettings()
return mSettings;
|
WebView | getWebView()
return mWebView;
|
private void | initialize()
/* Initialize our private BrowserFrame class to handle all
* frame-related functions. We need to create a new view which
* in turn creates a C level FrameView and attaches it to the frame.
*/
mBrowserFrame = new BrowserFrame(mContext, this, mCallbackProxy,
mSettings);
// Sync the native settings and also create the WebCore thread handler.
mSettings.syncSettingsAndCreateHandler(mBrowserFrame);
// Create the handler and transfer messages for the IconDatabase
WebIconDatabase.getInstance().createHandler();
// The transferMessages call will transfer all pending messages to the
// WebCore thread handler.
mEventHub.transferMessages();
// Send a message back to WebView to tell it that we have set up the
// WebCore thread.
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.WEBCORE_INITIALIZED_MSG_ID,
mNativeClass, 0).sendToTarget();
}
|
void | initializeSubwindow()
// Go ahead and initialize the core components.
initialize();
// Remove the INITIALIZE method so we don't try to initialize twice.
sWebCoreHandler.removeMessages(WebCoreThread.INITIALIZE, this);
|
protected void | jsAlert(java.lang.String url, java.lang.String message)Invoke a javascript alert.
mCallbackProxy.onJsAlert(url, message);
|
protected boolean | jsConfirm(java.lang.String url, java.lang.String message)Invoke a javascript confirm dialog.
return mCallbackProxy.onJsConfirm(url, message);
|
protected java.lang.String | jsPrompt(java.lang.String url, java.lang.String message, java.lang.String defaultValue)Invoke a javascript prompt dialog.
return mCallbackProxy.onJsPrompt(url, message, defaultValue);
|
protected boolean | jsUnload(java.lang.String url, java.lang.String message)Invoke a javascript before unload dialog.
return mCallbackProxy.onJsBeforeUnload(url, message);
|
private void | key(android.view.KeyEvent evt, boolean isDown)
if (LOGV_ENABLED) {
Log.v(LOGTAG, "CORE key at " + System.currentTimeMillis() + ", "
+ evt);
}
if (!nativeKey(evt.getKeyCode(), evt.getUnicodeChar(),
evt.getRepeatCount(), evt.isShiftPressed(), evt.isAltPressed(),
isDown)) {
// bubble up the event handling
mCallbackProxy.onUnhandledKeyEvent(evt);
}
|
private void | loadUrl(java.lang.String url)
if (LOGV_ENABLED) Log.v(LOGTAG, " CORE loadUrl " + url);
mBrowserFrame.loadUrl(url);
|
private native void | nativeClearContent()Empty the picture set.
|
private native boolean | nativeClick()
|
private native void | nativeCopyContentToPicture(android.graphics.Picture picture)Create a flat picture from the set of pictures.
|
private native void | nativeDeleteSelection(int frame, int node, int x, int y, int start, int end)Delete text from start to end in the focused textfield. If there is no
focus, or if start == end, silently fail. If start and end are out of
order, swap them.
|
private native boolean | nativeDrawContent(android.graphics.Canvas canvas, int color)Draw the picture set with a background color. Returns true
if some individual picture took too long to draw and can be
split into parts. Called from the UI thread.
|
private native void | nativeDumpDomTree(boolean useFile)
|
private native void | nativeDumpNavTree()
|
private native void | nativeDumpRenderTree(boolean useFile)
|
static native java.lang.String | nativeFindAddress(java.lang.String addr)
|
private native int | nativeGetContentMinPrefWidth()
|
private native java.lang.String | nativeGetSelection(android.graphics.Region sel)
|
private native boolean | nativeHandleTouchEvent(int action, int x, int y)
|
private native boolean | nativeKey(int keyCode, int unichar, int repeatCount, boolean isShift, boolean isAlt, boolean isDown)
|
private native boolean | nativeRecordContent(android.graphics.Region invalRegion, android.graphics.Point wh)Redraw a portion of the picture set. The Point wh returns the
width and height of the overall picture.
|
private native void | nativeRefreshPlugins(boolean reloadOpenPages)
|
private native void | nativeRegisterURLSchemeAsLocal(java.lang.String scheme)
|
private native void | nativeReplaceTextfieldText(int frame, int node, int x, int y, int oldStart, int oldEnd, java.lang.String replace, int newStart, int newEnd)
|
private native java.lang.String | nativeRetrieveHref(int framePtr, int nodePtr)
|
private native void | nativeSaveDocumentState(int frame)
|
private native void | nativeSendListBoxChoice(int choice)
|
private native void | nativeSendListBoxChoices(boolean[] choices, int size)
|
private native void | nativeSetBackgroundColor(int color)
|
private native void | nativeSetFinalFocus(int framePtr, int nodePtr, int x, int y, boolean block)
|
private native void | nativeSetGlobalBounds(int x, int y, int w, int h)
|
private native void | nativeSetKitFocus(int moveGeneration, int buildGeneration, int framePtr, int nodePtr, int x, int y, boolean ignoreNullFocus)
|
private native void | nativeSetScrollOffset(int dx, int dy)
|
private native void | nativeSetSelection(int frame, int node, int x, int y, int start, int end)Set the selection to (start, end) in the focused textfield. If start and
end are out of order, swap them.
|
private native void | nativeSetSize(int width, int height, int screenWidth, float scale, int realScreenWidth, int screenHeight)
|
private native void | nativeSetSnapAnchor(int x, int y)
|
private native void | nativeSnapToAnchor()
|
private native void | nativeSplitContent()Splits slow parts of the picture set. Called from the webkit
thread after nativeDrawContent returns true.
|
private native void | nativeTouchUp(int touchGeneration, int buildGeneration, int framePtr, int nodePtr, int x, int y, int size, boolean isClick, boolean retry)
|
private native void | nativeUnblockFocus()
|
private native void | nativeUpdateFrameCache()
|
private void | needTouchEvents(boolean need)
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.WEBCORE_NEED_TOUCH_EVENTS, need ? 1 : 0, 0)
.sendToTarget();
}
|
private native void | passToJs(int frame, int node, int x, int y, int gen, java.lang.String currentText, int keyCode, int keyValue, boolean down, boolean cap, boolean fn, boolean sym)
|
public static void | pauseTimers()Causes all timers to pause. This applies to all WebViews in the current
app process.
if (BrowserFrame.sJavaBridge == null) {
throw new IllegalStateException(
"No WebView has been created in this process!");
}
BrowserFrame.sJavaBridge.pause();
|
static void | pauseUpdate(android.webkit.WebViewCore core)
// remove the pending REDUCE_PRIORITY and RESUME_PRIORITY messages
sWebCoreHandler.removeMessages(WebCoreThread.REDUCE_PRIORITY);
sWebCoreHandler.removeMessages(WebCoreThread.RESUME_PRIORITY);
sWebCoreHandler.sendMessageAtFrontOfQueue(sWebCoreHandler
.obtainMessage(WebCoreThread.REDUCE_PRIORITY));
// Note: there is one possible failure mode. If pauseUpdate() is called
// from UI thread while in webcore thread WEBKIT_DRAW is just pulled out
// of the queue and about to be executed. mDrawIsScheduled may be set to
// false in webkitDraw(). So update won't be blocked. But at least the
// webcore thread priority is still lowered.
if (core != null) {
synchronized (core) {
core.mDrawIsPaused = true;
core.mEventHub.removeMessages(EventHub.WEBKIT_DRAW);
}
}
|
void | removeMessages(int what)
mEventHub.removeMessages(what);
|
void | removeMessages()
mEventHub.removeMessages();
|
private void | requestListBox(java.lang.String[] array, boolean[] enabledArray, int[] selectedArray)
if (mWebView != null) {
mWebView.requestListBox(array, enabledArray, selectedArray);
}
|
private void | requestListBox(java.lang.String[] array, boolean[] enabledArray, int selection)
if (mWebView != null) {
mWebView.requestListBox(array, enabledArray, selection);
}
|
private void | restoreScale(int scale)
if (mBrowserFrame.firstLayoutDone() == false) {
mRestoredScale = scale;
}
|
private void | restoreState(int index)
WebBackForwardList list = mCallbackProxy.getBackForwardList();
int size = list.getSize();
for (int i = 0; i < size; i++) {
list.getItemAtIndex(i).inflate(mBrowserFrame.mNativeFrame);
}
mBrowserFrame.mLoadInitFromJava = true;
list.restoreIndex(mBrowserFrame.mNativeFrame, index);
mBrowserFrame.mLoadInitFromJava = false;
|
public static void | resumeTimers()Resume all timers. This applies to all WebViews in the current process.
if (BrowserFrame.sJavaBridge == null) {
throw new IllegalStateException(
"No WebView has been created in this process!");
}
BrowserFrame.sJavaBridge.resume();
|
static void | resumeUpdate(android.webkit.WebViewCore core)
// remove the pending REDUCE_PRIORITY and RESUME_PRIORITY messages
sWebCoreHandler.removeMessages(WebCoreThread.REDUCE_PRIORITY);
sWebCoreHandler.removeMessages(WebCoreThread.RESUME_PRIORITY);
sWebCoreHandler.sendMessageAtFrontOfQueue(sWebCoreHandler
.obtainMessage(WebCoreThread.RESUME_PRIORITY));
if (core != null) {
synchronized (core) {
core.mDrawIsScheduled = false;
core.mDrawIsPaused = false;
if (LOGV_ENABLED) Log.v(LOGTAG, "resumeUpdate");
core.contentDraw();
}
}
|
private void | sendMarkNodeInvalid(int node)
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.MARK_NODE_INVALID_ID, node, 0).sendToTarget();
}
|
void | sendMessage(android.os.Message msg)
mEventHub.sendMessage(msg);
|
void | sendMessage(int what)
mEventHub.sendMessage(Message.obtain(null, what));
|
void | sendMessage(int what, java.lang.Object obj)
mEventHub.sendMessage(Message.obtain(null, what, obj));
|
void | sendMessage(int what, int arg1)
// just ignore the second argument (make it 0)
mEventHub.sendMessage(Message.obtain(null, what, arg1, 0));
|
void | sendMessage(int what, int arg1, int arg2)
mEventHub.sendMessage(Message.obtain(null, what, arg1, arg2));
|
void | sendMessage(int what, int arg1, java.lang.Object obj)
// just ignore the second argument (make it 0)
mEventHub.sendMessage(Message.obtain(null, what, arg1, 0, obj));
|
void | sendMessage(int what, int arg1, int arg2, java.lang.Object obj)
mEventHub.sendMessage(Message.obtain(null, what, arg1, arg2, obj));
|
void | sendMessageDelayed(int what, java.lang.Object obj, long delay)
mEventHub.sendMessageDelayed(Message.obtain(null, what, obj), delay);
|
private void | sendNotifyFocusSet()
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.NOTIFY_FOCUS_SET_MSG_ID).sendToTarget();
}
|
private void | sendNotifyProgressFinished()
sendUpdateTextEntry();
// as CacheManager can behave based on database transaction, we need to
// call tick() to trigger endTransaction
sWebCoreHandler.removeMessages(WebCoreThread.CACHE_TICKER);
sWebCoreHandler.sendMessage(sWebCoreHandler
.obtainMessage(WebCoreThread.CACHE_TICKER));
contentDraw();
|
private void | sendRecomputeFocus()
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.RECOMPUTE_FOCUS_MSG_ID).sendToTarget();
}
|
private void | sendUpdateTextEntry()
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.UPDATE_TEXT_ENTRY_MSG_ID).sendToTarget();
}
|
private void | sendViewInvalidate(int left, int top, int right, int bottom)
if (mWebView != null) {
Message.obtain(mWebView.mPrivateHandler,
WebView.INVAL_RECT_MSG_ID,
new Rect(left, top, right, bottom)).sendToTarget();
}
|
private native void | setViewportSettingsFromNative()
|
static void | startCacheTransaction()
sWebCoreHandler.sendMessage(sWebCoreHandler
.obtainMessage(WebCoreThread.RESUME_CACHE_TICKER));
|
void | stopLoading()
if (LOGV_ENABLED) Log.v(LOGTAG, "CORE stopLoading");
if (mBrowserFrame != null) {
mBrowserFrame.stopLoading();
}
|
private void | updateTextfield(int ptr, boolean changeToPassword, java.lang.String text, int textGeneration)
if (mWebView != null) {
Message msg = Message.obtain(mWebView.mPrivateHandler,
WebView.UPDATE_TEXTFIELD_TEXT_MSG_ID, ptr,
textGeneration, text);
msg.getData().putBoolean("password", changeToPassword);
msg.sendToTarget();
}
|
private void | viewSizeChanged(int w, int h, float scale)
// notify webkit that our virtual view size changed size (after inv-zoom)
if (LOGV_ENABLED) Log.v(LOGTAG, "CORE onSizeChanged");
if (w == 0) {
Log.w(LOGTAG, "skip viewSizeChanged as w is 0");
return;
}
if (mSettings.getUseWideViewPort()
&& (w < mViewportWidth || mViewportWidth == -1)) {
int width = mViewportWidth;
if (mViewportWidth == -1) {
if (mSettings.getLayoutAlgorithm() ==
WebSettings.LayoutAlgorithm.NORMAL) {
width = WebView.ZOOM_OUT_WIDTH;
} else {
/*
* if a page's minimum preferred width is wider than the
* given "w", use it instead to get better layout result. If
* we start a page with MAX_ZOOM_WIDTH, "w" will be always
* wider. If we start a page with screen width, due to the
* delay between {@link #didFirstLayout} and
* {@link #viewSizeChanged},
* {@link #nativeGetContentMinPrefWidth} will return a more
* accurate value than initial 0 to result a better layout.
* In the worse case, the native width will be adjusted when
* next zoom or screen orientation change happens.
*/
width = Math.max(w, nativeGetContentMinPrefWidth());
}
}
nativeSetSize(width, Math.round((float) width * h / w), w, scale,
w, h);
} else {
nativeSetSize(w, h, w, scale, w, h);
}
// Remember the current width and height
boolean needInvalidate = (mCurrentViewWidth == 0);
mCurrentViewWidth = w;
mCurrentViewHeight = h;
if (needInvalidate) {
// ensure {@link #webkitDraw} is called as we were blocking in
// {@link #contentDraw} when mCurrentViewWidth is 0
if (LOGV_ENABLED) Log.v(LOGTAG, "viewSizeChanged");
contentDraw();
}
mEventHub.sendMessage(Message.obtain(null,
EventHub.UPDATE_CACHE_AND_TEXT_ENTRY));
|
private void | webkitDraw()
mDrawIsScheduled = false;
DrawData draw = new DrawData();
if (LOGV_ENABLED) Log.v(LOGTAG, "webkitDraw start");
if (nativeRecordContent(draw.mInvalRegion, draw.mWidthHeight)
== false) {
if (LOGV_ENABLED) Log.v(LOGTAG, "webkitDraw abort");
return;
}
if (mWebView != null) {
// Send the native view size that was used during the most recent
// layout.
draw.mViewPoint = new Point(mCurrentViewWidth, mCurrentViewHeight);
if (LOGV_ENABLED) Log.v(LOGTAG, "webkitDraw NEW_PICTURE_MSG_ID");
Message.obtain(mWebView.mPrivateHandler,
WebView.NEW_PICTURE_MSG_ID, draw).sendToTarget();
if (mWebkitScrollX != 0 || mWebkitScrollY != 0) {
// as we have the new picture, try to sync the scroll position
Message.obtain(mWebView.mPrivateHandler,
WebView.SYNC_SCROLL_TO_MSG_ID, mWebkitScrollX,
mWebkitScrollY).sendToTarget();
mWebkitScrollX = mWebkitScrollY = 0;
}
// nativeSnapToAnchor() needs to be called after NEW_PICTURE_MSG_ID
// is sent, so that scroll will be based on the new content size.
nativeSnapToAnchor();
}
|