Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
| 6 | 6 |
| 7 import android.content.pm.PackageManager; | 7 import android.content.pm.PackageManager; |
| 8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
| 9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 10 import android.graphics.Canvas; | 10 import android.graphics.Canvas; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 | 173 |
| 174 private DefaultVideoPosterRequestHandler mDefaultVideoPosterRequestHandler; | 174 private DefaultVideoPosterRequestHandler mDefaultVideoPosterRequestHandler; |
| 175 | 175 |
| 176 // Bound method for suppling Picture instances to the AwContentsClient. Will be null if the | 176 // Bound method for suppling Picture instances to the AwContentsClient. Will be null if the |
| 177 // picture listener API has not yet been enabled, or if it is using invalida tion-only mode. | 177 // picture listener API has not yet been enabled, or if it is using invalida tion-only mode. |
| 178 private Callable<Picture> mPictureListenerContentProvider; | 178 private Callable<Picture> mPictureListenerContentProvider; |
| 179 | 179 |
| 180 private boolean mContainerViewFocused; | 180 private boolean mContainerViewFocused; |
| 181 private boolean mWindowFocused; | 181 private boolean mWindowFocused; |
| 182 | 182 |
| 183 private boolean mClearViewActive; | |
| 184 private boolean mPictureListenerEnabled; | |
| 185 | |
| 183 private AwAutofillManagerDelegate mAwAutofillManagerDelegate; | 186 private AwAutofillManagerDelegate mAwAutofillManagerDelegate; |
| 184 | 187 |
| 185 private static final class DestroyRunnable implements Runnable { | 188 private static final class DestroyRunnable implements Runnable { |
| 186 private int mNativeAwContents; | 189 private int mNativeAwContents; |
| 187 private DestroyRunnable(int nativeAwContents) { | 190 private DestroyRunnable(int nativeAwContents) { |
| 188 mNativeAwContents = nativeAwContents; | 191 mNativeAwContents = nativeAwContents; |
| 189 } | 192 } |
| 190 @Override | 193 @Override |
| 191 public void run() { | 194 public void run() { |
| 192 // This is a no-op if not currently attached. | 195 // This is a no-op if not currently attached. |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 // Only valid within onDraw(). | 690 // Only valid within onDraw(). |
| 688 private final Rect mClipBoundsTemporary = new Rect(); | 691 private final Rect mClipBoundsTemporary = new Rect(); |
| 689 | 692 |
| 690 public void onDraw(Canvas canvas) { | 693 public void onDraw(Canvas canvas) { |
| 691 if (mNativeAwContents == 0) { | 694 if (mNativeAwContents == 0) { |
| 692 canvas.drawColor(getEffectiveBackgroundColor()); | 695 canvas.drawColor(getEffectiveBackgroundColor()); |
| 693 return; | 696 return; |
| 694 } | 697 } |
| 695 | 698 |
| 696 mScrollOffsetManager.syncScrollOffsetFromOnDraw(); | 699 mScrollOffsetManager.syncScrollOffsetFromOnDraw(); |
| 700 canvas.getClipBounds(mClipBoundsTemporary); | |
| 697 | 701 |
| 698 canvas.getClipBounds(mClipBoundsTemporary); | 702 if (mClearViewActive) { |
| 699 if (!nativeOnDraw(mNativeAwContents, canvas, canvas.isHardwareAccelerate d(), | 703 canvas.drawColor(getEffectiveBackgroundColor()); |
|
boliu
2013/09/20 20:55:49
Documentation says draws white background, not wha
Kristian Monsen
2013/09/20 21:15:17
Classic actually does the background color as well
| |
| 700 mContainerView.getScrollX(), mContainerView.getScrollY(), | 704 } else if (!nativeOnDraw(mNativeAwContents, canvas, canvas.isHardwareAcc elerated(), |
| 701 mClipBoundsTemporary.left, mClipBoundsTemporary.top, | 705 mContainerView.getScrollX(), mContainerView.getScrollY(), |
| 702 mClipBoundsTemporary.right, mClipBoundsTemporary.bottom)) { | 706 mClipBoundsTemporary.left, mClipBoundsTemporary.top, |
| 707 mClipBoundsTemporary.right, mClipBoundsTemporary.bottom)) { | |
| 703 Log.w(TAG, "nativeOnDraw failed; clearing to background color."); | 708 Log.w(TAG, "nativeOnDraw failed; clearing to background color."); |
| 704 canvas.drawColor(getEffectiveBackgroundColor()); | 709 canvas.drawColor(getEffectiveBackgroundColor()); |
| 705 } | 710 } |
| 706 | 711 |
| 707 if (mOverScrollGlow != null && mOverScrollGlow.drawEdgeGlows(canvas, | 712 if (mOverScrollGlow != null && mOverScrollGlow.drawEdgeGlows(canvas, |
| 708 mScrollOffsetManager.computeMaximumHorizontalScrollOffset(), | 713 mScrollOffsetManager.computeMaximumHorizontalScrollOffset(), |
| 709 mScrollOffsetManager.computeMaximumVerticalScrollOffset())) { | 714 mScrollOffsetManager.computeMaximumVerticalScrollOffset())) { |
| 710 mContainerView.invalidate(); | 715 mContainerView.invalidate(); |
|
boliu
2013/08/16 23:04:55
Badness right there...should let InProcessViewRend
mkosiba (inactive)
2013/08/19 16:14:14
could you elaborate why invalidating the view is b
boliu
2013/08/19 16:21:49
InProcessViewRenderer has logic for triggering/thr
mkosiba (inactive)
2013/08/19 16:30:17
yeath, but this isn't an invalidate for the conten
Kristian Monsen
2013/09/20 19:35:56
Not related to this change :-)
| |
| 711 } | 716 } |
| 712 } | 717 } |
| 713 | 718 |
| 714 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | 719 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 715 mLayoutSizer.onMeasure(widthMeasureSpec, heightMeasureSpec); | 720 mLayoutSizer.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 716 } | 721 } |
| 717 | 722 |
| 718 public int getContentHeightCss() { | 723 public int getContentHeightCss() { |
| 719 return (int) Math.ceil(mContentViewCore.getContentHeightCss()); | 724 return (int) Math.ceil(mContentViewCore.getContentHeightCss()); |
| 720 } | 725 } |
| 721 | 726 |
| 722 public int getContentWidthCss() { | 727 public int getContentWidthCss() { |
| 723 return (int) Math.ceil(mContentViewCore.getContentWidthCss()); | 728 return (int) Math.ceil(mContentViewCore.getContentWidthCss()); |
| 724 } | 729 } |
| 725 | 730 |
| 726 public Picture capturePicture() { | 731 public Picture capturePicture() { |
| 727 return new AwPicture(nativeCapturePicture(mNativeAwContents, | 732 return new AwPicture(nativeCapturePicture(mNativeAwContents, |
| 728 mScrollOffsetManager.computeHorizontalScrollRange(), | 733 mScrollOffsetManager.computeHorizontalScrollRange(), |
| 729 mScrollOffsetManager.computeVerticalScrollRange())); | 734 mScrollOffsetManager.computeVerticalScrollRange())); |
| 730 } | 735 } |
| 731 | 736 |
| 737 public void clearView() { | |
| 738 mClearViewActive = true; | |
| 739 syncOnNewPictureStateToNative(); | |
| 740 mContainerView.invalidate(); | |
|
boliu
2013/08/16 23:04:55
Is this invalidate needed? Documentation only says
Kristian Monsen
2013/09/20 19:35:56
The behavior we are trying to match is pretty much
| |
| 741 } | |
| 742 | |
| 732 /** | 743 /** |
| 733 * Enable the onNewPicture callback. | 744 * Enable the onNewPicture callback. |
| 734 * @param enabled Flag to enable the callback. | 745 * @param enabled Flag to enable the callback. |
| 735 * @param invalidationOnly Flag to call back only on invalidation without pr oviding a picture. | 746 * @param invalidationOnly Flag to call back only on invalidation without pr oviding a picture. |
| 736 */ | 747 */ |
| 737 public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) { | 748 public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) { |
| 738 if (invalidationOnly) { | 749 if (invalidationOnly) { |
| 739 mPictureListenerContentProvider = null; | 750 mPictureListenerContentProvider = null; |
| 740 } else if (enabled && mPictureListenerContentProvider == null) { | 751 } else if (enabled && mPictureListenerContentProvider == null) { |
| 741 mPictureListenerContentProvider = new Callable<Picture>() { | 752 mPictureListenerContentProvider = new Callable<Picture>() { |
| 742 @Override | 753 @Override |
| 743 public Picture call() { | 754 public Picture call() { |
| 744 return capturePicture(); | 755 return capturePicture(); |
| 745 } | 756 } |
| 746 }; | 757 }; |
| 747 } | 758 } |
| 748 nativeEnableOnNewPicture(mNativeAwContents, enabled); | 759 mPictureListenerEnabled = enabled; |
| 760 syncOnNewPictureStateToNative(); | |
| 761 } | |
| 762 | |
| 763 private void syncOnNewPictureStateToNative() { | |
| 764 nativeEnableOnNewPicture(mNativeAwContents, mPictureListenerEnabled || m ClearViewActive); | |
| 749 } | 765 } |
| 750 | 766 |
| 751 public void findAllAsync(String searchString) { | 767 public void findAllAsync(String searchString) { |
| 752 if (mNativeAwContents == 0) return; | 768 if (mNativeAwContents == 0) return; |
| 753 nativeFindAllAsync(mNativeAwContents, searchString); | 769 nativeFindAllAsync(mNativeAwContents, searchString); |
| 754 } | 770 } |
| 755 | 771 |
| 756 public void findNext(boolean forward) { | 772 public void findNext(boolean forward) { |
| 757 if (mNativeAwContents == 0) return; | 773 if (mNativeAwContents == 0) return; |
| 758 nativeFindNext(mNativeAwContents, forward); | 774 nativeFindNext(mNativeAwContents, forward); |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1678 } | 1694 } |
| 1679 | 1695 |
| 1680 @CalledByNative | 1696 @CalledByNative |
| 1681 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches , | 1697 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches , |
| 1682 boolean isDoneCounting) { | 1698 boolean isDoneCounting) { |
| 1683 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches , isDoneCounting); | 1699 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches , isDoneCounting); |
| 1684 } | 1700 } |
| 1685 | 1701 |
| 1686 @CalledByNative | 1702 @CalledByNative |
| 1687 public void onNewPicture() { | 1703 public void onNewPicture() { |
| 1704 // Clear up any results from a previous clearView call | |
| 1705 if (mClearViewActive) { | |
| 1706 mClearViewActive = false; | |
| 1707 mContainerView.invalidate(); | |
|
boliu
2013/08/16 23:04:55
Again is this needed? If cc activates, it should s
Kristian Monsen
2013/09/20 19:35:56
I think it is safe to keep it in? Remember this is
| |
| 1708 syncOnNewPictureStateToNative(); | |
| 1709 } | |
| 1710 | |
| 1688 // Don't call capturePicture() here but instead defer it until the poste d task runs within | 1711 // Don't call capturePicture() here but instead defer it until the poste d task runs within |
| 1689 // the callback helper, to avoid doubling back into the renderer composi tor in the middle | 1712 // the callback helper, to avoid doubling back into the renderer composi tor in the middle |
| 1690 // of the notification it is sending up to here. | 1713 // of the notification it is sending up to here. |
| 1691 mContentsClient.getCallbackHelper().postOnNewPicture(mPictureListenerCon tentProvider); | 1714 mContentsClient.getCallbackHelper().postOnNewPicture(mPictureListenerCon tentProvider); |
| 1692 } | 1715 } |
| 1693 | 1716 |
| 1694 // Called as a result of nativeUpdateLastHitTestData. | 1717 // Called as a result of nativeUpdateLastHitTestData. |
| 1695 @CalledByNative | 1718 @CalledByNative |
| 1696 private void updateHitTestData( | 1719 private void updateHitTestData( |
| 1697 int type, String extra, String href, String anchorText, String imgSr c) { | 1720 int type, String extra, String href, String anchorText, String imgSr c) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1868 private native void nativeFocusFirstNode(int nativeAwContents); | 1891 private native void nativeFocusFirstNode(int nativeAwContents); |
| 1869 private native void nativeSetBackgroundColor(int nativeAwContents, int color ); | 1892 private native void nativeSetBackgroundColor(int nativeAwContents, int color ); |
| 1870 | 1893 |
| 1871 private native int nativeGetAwDrawGLViewContext(int nativeAwContents); | 1894 private native int nativeGetAwDrawGLViewContext(int nativeAwContents); |
| 1872 private native int nativeCapturePicture(int nativeAwContents, int width, int height); | 1895 private native int nativeCapturePicture(int nativeAwContents, int width, int height); |
| 1873 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e nabled); | 1896 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e nabled); |
| 1874 | 1897 |
| 1875 private native void nativeInvokeGeolocationCallback( | 1898 private native void nativeInvokeGeolocationCallback( |
| 1876 int nativeAwContents, boolean value, String requestingFrame); | 1899 int nativeAwContents, boolean value, String requestingFrame); |
| 1877 } | 1900 } |
| OLD | NEW |