am 6ed525ec: When a WebView starts, we may get first layout before viewSizeChanged() ever get called. Call WebView\'s getViewWidth() to get the current UI width. If it is still 0, log a warning.
Merge commit '6ed525ecee76541aa60ca95598330e990fa16ffa' into eclair-plus-aosp * commit '6ed525ecee76541aa60ca95598330e990fa16ffa': When a WebView starts, we may get first layout before viewSizeChanged()
This commit is contained in:
@@ -905,8 +905,9 @@ public class WebView extends AbsoluteLayout
|
|||||||
/*
|
/*
|
||||||
* Return the width of the view where the content of WebView should render
|
* Return the width of the view where the content of WebView should render
|
||||||
* to.
|
* to.
|
||||||
|
* Note: this can be called from WebCoreThread.
|
||||||
*/
|
*/
|
||||||
private int getViewWidth() {
|
/* package */ int getViewWidth() {
|
||||||
if (!isVerticalScrollBarEnabled() || mOverlayVerticalScrollbar) {
|
if (!isVerticalScrollBarEnabled() || mOverlayVerticalScrollbar) {
|
||||||
return getWidth();
|
return getWidth();
|
||||||
} else {
|
} else {
|
||||||
@@ -932,8 +933,9 @@ public class WebView extends AbsoluteLayout
|
|||||||
/*
|
/*
|
||||||
* Return the height of the view where the content of WebView should render
|
* Return the height of the view where the content of WebView should render
|
||||||
* to. Note that this excludes mTitleBar, if there is one.
|
* to. Note that this excludes mTitleBar, if there is one.
|
||||||
|
* Note: this can be called from WebCoreThread.
|
||||||
*/
|
*/
|
||||||
private int getViewHeight() {
|
/* package */ int getViewHeight() {
|
||||||
int height = getHeight();
|
int height = getHeight();
|
||||||
if (isHorizontalScrollBarEnabled() && !mOverlayHorizontalScrollbar) {
|
if (isHorizontalScrollBarEnabled() && !mOverlayHorizontalScrollbar) {
|
||||||
height -= getHorizontalScrollbarHeight();
|
height -= getHorizontalScrollbarHeight();
|
||||||
|
|||||||
@@ -1890,7 +1890,22 @@ final class WebViewCore {
|
|||||||
if (mViewportWidth != 0 && !updateRestoreState) return;
|
if (mViewportWidth != 0 && !updateRestoreState) return;
|
||||||
|
|
||||||
// now notify webview
|
// now notify webview
|
||||||
int webViewWidth = Math.round(mCurrentViewWidth * mCurrentViewScale);
|
// webViewWidth refers to the width in the view system
|
||||||
|
int webViewWidth;
|
||||||
|
// viewportWidth refers to the width in the document system
|
||||||
|
int viewportWidth = mCurrentViewWidth;
|
||||||
|
if (viewportWidth == 0) {
|
||||||
|
// this may happen when WebView just starts. This is not perfect as
|
||||||
|
// we call WebView method from WebCore thread. But not perfect
|
||||||
|
// reference is better than no reference.
|
||||||
|
webViewWidth = mWebView.getViewWidth();
|
||||||
|
viewportWidth = webViewWidth * 100 / WebView.DEFAULT_SCALE_PERCENT;
|
||||||
|
if (viewportWidth == 0) {
|
||||||
|
Log.w(LOGTAG, "Can't get the viewWidth after the first layout");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
webViewWidth = Math.round(viewportWidth * mCurrentViewScale);
|
||||||
|
}
|
||||||
mRestoreState = new RestoreState();
|
mRestoreState = new RestoreState();
|
||||||
mRestoreState.mMinScale = mViewportMinimumScale / 100.0f;
|
mRestoreState.mMinScale = mViewportMinimumScale / 100.0f;
|
||||||
mRestoreState.mMaxScale = mViewportMaximumScale / 100.0f;
|
mRestoreState.mMaxScale = mViewportMaximumScale / 100.0f;
|
||||||
@@ -1942,7 +1957,7 @@ final class WebViewCore {
|
|||||||
mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,
|
mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null,
|
||||||
EventHub.VIEW_SIZE_CHANGED, data));
|
EventHub.VIEW_SIZE_CHANGED, data));
|
||||||
} else if (mSettings.getUseWideViewPort()) {
|
} else if (mSettings.getUseWideViewPort()) {
|
||||||
if (mCurrentViewWidth == 0) {
|
if (viewportWidth == 0) {
|
||||||
// Trick to ensure VIEW_SIZE_CHANGED will be sent from WebView
|
// Trick to ensure VIEW_SIZE_CHANGED will be sent from WebView
|
||||||
// to WebViewCore
|
// to WebViewCore
|
||||||
mWebView.mLastWidthSent = 0;
|
mWebView.mLastWidthSent = 0;
|
||||||
@@ -1956,8 +1971,7 @@ final class WebViewCore {
|
|||||||
: mRestoreState.mTextWrapScale)
|
: mRestoreState.mTextWrapScale)
|
||||||
: mRestoreState.mViewScale;
|
: mRestoreState.mViewScale;
|
||||||
data.mWidth = Math.round(webViewWidth / data.mScale);
|
data.mWidth = Math.round(webViewWidth / data.mScale);
|
||||||
data.mHeight = mCurrentViewHeight * data.mWidth
|
data.mHeight = mCurrentViewHeight * data.mWidth / viewportWidth;
|
||||||
/ mCurrentViewWidth;
|
|
||||||
data.mTextWrapWidth = Math.round(webViewWidth
|
data.mTextWrapWidth = Math.round(webViewWidth
|
||||||
/ mRestoreState.mTextWrapScale);
|
/ mRestoreState.mTextWrapScale);
|
||||||
data.mIgnoreHeight = false;
|
data.mIgnoreHeight = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user