Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 22849016: Implement clearView to match classic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add clipping and invalidation Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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());
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();
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 nativeEnableOnNewPicture(mNativeAwContents, true);
joth 2013/08/16 21:41:04 invalidate();
Kristian Monsen 2013/08/16 22:57:10 Done.
740 }
741
732 /** 742 /**
733 * Enable the onNewPicture callback. 743 * Enable the onNewPicture callback.
734 * @param enabled Flag to enable the callback. 744 * @param enabled Flag to enable the callback.
735 * @param invalidationOnly Flag to call back only on invalidation without pr oviding a picture. 745 * @param invalidationOnly Flag to call back only on invalidation without pr oviding a picture.
736 */ 746 */
737 public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) { 747 public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) {
738 if (invalidationOnly) { 748 if (invalidationOnly) {
739 mPictureListenerContentProvider = null; 749 mPictureListenerContentProvider = null;
740 } else if (enabled && mPictureListenerContentProvider == null) { 750 } else if (enabled && mPictureListenerContentProvider == null) {
741 mPictureListenerContentProvider = new Callable<Picture>() { 751 mPictureListenerContentProvider = new Callable<Picture>() {
742 @Override 752 @Override
743 public Picture call() { 753 public Picture call() {
744 return capturePicture(); 754 return capturePicture();
745 } 755 }
746 }; 756 };
747 } 757 }
758 mPictureListenerEnabled = enabled;
759 if (mClearViewActive) {
760 enabled = true;
761 }
748 nativeEnableOnNewPicture(mNativeAwContents, enabled); 762 nativeEnableOnNewPicture(mNativeAwContents, enabled);
joth 2013/08/16 21:41:04 suggest collecting all three nativeEnableOnNewPict
Kristian Monsen 2013/08/16 22:57:10 Done.
749 } 763 }
750 764
751 public void findAllAsync(String searchString) { 765 public void findAllAsync(String searchString) {
752 if (mNativeAwContents == 0) return; 766 if (mNativeAwContents == 0) return;
753 nativeFindAllAsync(mNativeAwContents, searchString); 767 nativeFindAllAsync(mNativeAwContents, searchString);
754 } 768 }
755 769
756 public void findNext(boolean forward) { 770 public void findNext(boolean forward) {
757 if (mNativeAwContents == 0) return; 771 if (mNativeAwContents == 0) return;
758 nativeFindNext(mNativeAwContents, forward); 772 nativeFindNext(mNativeAwContents, forward);
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 } 1692 }
1679 1693
1680 @CalledByNative 1694 @CalledByNative
1681 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches , 1695 public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches ,
1682 boolean isDoneCounting) { 1696 boolean isDoneCounting) {
1683 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches , isDoneCounting); 1697 mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches , isDoneCounting);
1684 } 1698 }
1685 1699
1686 @CalledByNative 1700 @CalledByNative
1687 public void onNewPicture() { 1701 public void onNewPicture() {
1702 // Clear up any results from a previous clearView call
1703 mClearViewActive = false;
joth 2013/08/16 21:41:04 if (mClearViewActive) { invalidate(); mClearVi
Kristian Monsen 2013/08/16 22:57:10 Done.
1704 nativeEnableOnNewPicture(mNativeAwContents, mPictureListenerEnabled);
1705
1688 // Don't call capturePicture() here but instead defer it until the poste d task runs within 1706 // 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 1707 // 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. 1708 // of the notification it is sending up to here.
1691 mContentsClient.getCallbackHelper().postOnNewPicture(mPictureListenerCon tentProvider); 1709 mContentsClient.getCallbackHelper().postOnNewPicture(mPictureListenerCon tentProvider);
1692 } 1710 }
1693 1711
1694 // Called as a result of nativeUpdateLastHitTestData. 1712 // Called as a result of nativeUpdateLastHitTestData.
1695 @CalledByNative 1713 @CalledByNative
1696 private void updateHitTestData( 1714 private void updateHitTestData(
1697 int type, String extra, String href, String anchorText, String imgSr c) { 1715 int type, String extra, String href, String anchorText, String imgSr c) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 private native void nativeFocusFirstNode(int nativeAwContents); 1886 private native void nativeFocusFirstNode(int nativeAwContents);
1869 private native void nativeSetBackgroundColor(int nativeAwContents, int color ); 1887 private native void nativeSetBackgroundColor(int nativeAwContents, int color );
1870 1888
1871 private native int nativeGetAwDrawGLViewContext(int nativeAwContents); 1889 private native int nativeGetAwDrawGLViewContext(int nativeAwContents);
1872 private native int nativeCapturePicture(int nativeAwContents, int width, int height); 1890 private native int nativeCapturePicture(int nativeAwContents, int width, int height);
1873 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e nabled); 1891 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e nabled);
1874 1892
1875 private native void nativeInvokeGeolocationCallback( 1893 private native void nativeInvokeGeolocationCallback(
1876 int nativeAwContents, boolean value, String requestingFrame); 1894 int nativeAwContents, boolean value, String requestingFrame);
1877 } 1895 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698