Loading core/java/android/webkit/ViewManager.java +41 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.webkit; import android.view.SurfaceView; import android.view.View; import android.widget.AbsoluteLayout; Loading @@ -27,6 +28,9 @@ class ViewManager { private boolean mHidden; private boolean mReadyToDraw; // Threshold at which a surface is prevented from further increasing in size private static final int MAX_SURFACE_THRESHOLD = 1000000; class ChildView { int x; int y; Loading @@ -34,6 +38,11 @@ class ViewManager { int height; View mView; // generic view to show /* set to true if the view is a surface and it has exceeded the pixel threshold specified in MAX_SURFACE_THRESHOLD. */ boolean isFixedSize = false; ChildView() { } Loading @@ -49,15 +58,15 @@ class ViewManager { return; } setBounds(x, y, width, height); final AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams(ctvD(width), ctvD(height), ctvX(x), ctvY(y)); mWebView.mPrivateHandler.post(new Runnable() { public void run() { // This method may be called multiple times. If the view is // already attached, just set the new LayoutParams, // otherwise attach the view and add it to the list of // children. AbsoluteLayout.LayoutParams lp = computeLayout(ChildView.this); if (mView.getParent() != null) { mView.setLayoutParams(lp); } else { Loading @@ -67,7 +76,7 @@ class ViewManager { }); } void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) { private void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) { mWebView.addView(mView, lp); mChildren.add(this); if (!mReadyToDraw) { Loading @@ -86,7 +95,7 @@ class ViewManager { }); } void removeViewOnUIThread() { private void removeViewOnUIThread() { mWebView.removeView(mView); mChildren.remove(this); } Loading Loading @@ -125,16 +134,37 @@ class ViewManager { return mWebView.contentToViewY(val); } void scaleAll() { for (ChildView v : mChildren) { View view = v.mView; /** * This should only be called from the UI thread. */ private AbsoluteLayout.LayoutParams computeLayout(ChildView v) { // if the surface has exceed a predefined threshold then fix the size // of the surface. if (!v.isFixedSize && (v.width * v.height) > MAX_SURFACE_THRESHOLD && v.mView instanceof SurfaceView) { ((SurfaceView)v.mView).getHolder().setFixedSize(v.width, v.height); v.isFixedSize = true; } AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) view.getLayoutParams(); (AbsoluteLayout.LayoutParams) v.mView.getLayoutParams(); if (lp == null) lp = new AbsoluteLayout.LayoutParams(ctvD(v.width), ctvD(v.height), ctvX(v.x), ctvY(v.y)); else { lp.width = ctvD(v.width); lp.height = ctvD(v.height); lp.x = ctvX(v.x); lp.y = ctvY(v.y); view.setLayoutParams(lp); } return lp; } void scaleAll() { for (ChildView v : mChildren) { v.mView.setLayoutParams(computeLayout(v)); } } Loading Loading
core/java/android/webkit/ViewManager.java +41 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.webkit; import android.view.SurfaceView; import android.view.View; import android.widget.AbsoluteLayout; Loading @@ -27,6 +28,9 @@ class ViewManager { private boolean mHidden; private boolean mReadyToDraw; // Threshold at which a surface is prevented from further increasing in size private static final int MAX_SURFACE_THRESHOLD = 1000000; class ChildView { int x; int y; Loading @@ -34,6 +38,11 @@ class ViewManager { int height; View mView; // generic view to show /* set to true if the view is a surface and it has exceeded the pixel threshold specified in MAX_SURFACE_THRESHOLD. */ boolean isFixedSize = false; ChildView() { } Loading @@ -49,15 +58,15 @@ class ViewManager { return; } setBounds(x, y, width, height); final AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams(ctvD(width), ctvD(height), ctvX(x), ctvY(y)); mWebView.mPrivateHandler.post(new Runnable() { public void run() { // This method may be called multiple times. If the view is // already attached, just set the new LayoutParams, // otherwise attach the view and add it to the list of // children. AbsoluteLayout.LayoutParams lp = computeLayout(ChildView.this); if (mView.getParent() != null) { mView.setLayoutParams(lp); } else { Loading @@ -67,7 +76,7 @@ class ViewManager { }); } void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) { private void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) { mWebView.addView(mView, lp); mChildren.add(this); if (!mReadyToDraw) { Loading @@ -86,7 +95,7 @@ class ViewManager { }); } void removeViewOnUIThread() { private void removeViewOnUIThread() { mWebView.removeView(mView); mChildren.remove(this); } Loading Loading @@ -125,16 +134,37 @@ class ViewManager { return mWebView.contentToViewY(val); } void scaleAll() { for (ChildView v : mChildren) { View view = v.mView; /** * This should only be called from the UI thread. */ private AbsoluteLayout.LayoutParams computeLayout(ChildView v) { // if the surface has exceed a predefined threshold then fix the size // of the surface. if (!v.isFixedSize && (v.width * v.height) > MAX_SURFACE_THRESHOLD && v.mView instanceof SurfaceView) { ((SurfaceView)v.mView).getHolder().setFixedSize(v.width, v.height); v.isFixedSize = true; } AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) view.getLayoutParams(); (AbsoluteLayout.LayoutParams) v.mView.getLayoutParams(); if (lp == null) lp = new AbsoluteLayout.LayoutParams(ctvD(v.width), ctvD(v.height), ctvX(v.x), ctvY(v.y)); else { lp.width = ctvD(v.width); lp.height = ctvD(v.height); lp.x = ctvX(v.x); lp.y = ctvY(v.y); view.setLayoutParams(lp); } return lp; } void scaleAll() { for (ChildView v : mChildren) { v.mView.setLayoutParams(computeLayout(v)); } } Loading