Add UI considerations to layers

companion fix is in external/webkit

- Add class to return view metrics.
- Draw cursor rings and find matches in proper order.

http://b/2369549
This commit is contained in:
Cary Clark
2010-01-27 17:03:05 -05:00
parent 900ec77d62
commit 855dd9e074

View File

@ -3105,11 +3105,26 @@ public class WebView extends AbsoluteLayout
}
}
private static class Metrics {
int mScrollX;
int mScrollY;
int mWidth;
int mHeight;
float mScale;
}
private Metrics getViewMetrics() {
Metrics metrics = new Metrics();
metrics.mScrollX = mScrollX;
metrics.mScrollY = computeVerticalScrollOffset();
metrics.mWidth = getWidth();
metrics.mHeight = getHeight() - getVisibleTitleHeight();
metrics.mScale = mActualScale;
return metrics;
}
private void drawLayers(Canvas canvas) {
if (mRootLayer != 0) {
int scrollY = computeVerticalScrollOffset();
int viewHeight = getHeight() - getVisibleTitleHeight();
// Currently for each draw we compute the animation values;
// We may in the future decide to do that independently.
if (nativeEvaluateLayersAnimations(mRootLayer)) {
@ -3119,9 +3134,7 @@ public class WebView extends AbsoluteLayout
}
// We can now draw the layers.
nativeDrawLayers(mRootLayer, mScrollX, scrollY,
getWidth(), viewHeight,
mActualScale, canvas);
nativeDrawLayers(mRootLayer, canvas);
}
}
@ -3209,7 +3222,15 @@ public class WebView extends AbsoluteLayout
mWebViewCore.drawContentPicture(canvas, color,
(animateZoom || mPreviewZoomOnly), animateScroll);
boolean cursorIsInLayer = nativeCursorIsInLayer();
if (drawCursorRing && !cursorIsInLayer) {
nativeDrawCursorRing(canvas);
}
// When the FindDialog is up, only draw the matches if we are not in
// the process of scrolling them into view.
if (mFindIsUp && !animateScroll) {
nativeDrawMatches(canvas);
}
drawLayers(canvas);
if (mNativeClass == 0) return;
@ -3232,12 +3253,7 @@ public class WebView extends AbsoluteLayout
LONG_PRESS_TIMEOUT);
}
}
nativeDrawCursorRing(canvas);
}
// When the FindDialog is up, only draw the matches if we are not in
// the process of scrolling them into view.
if (mFindIsUp && !animateScroll) {
nativeDrawMatches(canvas);
if (cursorIsInLayer) nativeDrawCursorRing(canvas);
}
if (mFocusSizeChanged) {
mFocusSizeChanged = false;
@ -5952,6 +5968,7 @@ public class WebView extends AbsoluteLayout
case SET_ROOT_LAYER_MSG_ID: {
int oldLayer = mRootLayer;
mRootLayer = msg.arg1;
nativeSetRootLayer(mRootLayer);
if (oldLayer > 0) {
nativeDestroyLayer(oldLayer);
}
@ -6715,6 +6732,7 @@ public class WebView extends AbsoluteLayout
/* package */ native boolean nativeCursorMatchesFocus();
private native boolean nativeCursorIntersects(Rect visibleRect);
private native boolean nativeCursorIsAnchor();
private native boolean nativeCursorIsInLayer();
private native boolean nativeCursorIsTextInput();
private native Point nativeCursorPosition();
private native String nativeCursorText();
@ -6728,10 +6746,7 @@ public class WebView extends AbsoluteLayout
private native void nativeDrawCursorRing(Canvas content);
private native void nativeDestroyLayer(int layer);
private native boolean nativeEvaluateLayersAnimations(int layer);
private native void nativeDrawLayers(int layer,
int scrollX, int scrollY,
int width, int height,
float scale, Canvas canvas);
private native void nativeDrawLayers(int layer, Canvas canvas);
private native void nativeDrawMatches(Canvas canvas);
private native void nativeDrawSelectionPointer(Canvas content,
float scale, int x, int y, boolean extendSelection);
@ -6781,6 +6796,7 @@ public class WebView extends AbsoluteLayout
private native void nativeSetFindIsUp();
private native void nativeSetFollowedLink(boolean followed);
private native void nativeSetHeightCanMeasure(boolean measure);
private native void nativeSetRootLayer(int layer);
private native int nativeTextGeneration();
// Never call this version except by updateCachedTextfield(String) -
// we always want to pass in our generation number.