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

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

Issue 831903004: [WebView] Add a new flushVisualState API to AwContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: int -> uint62 everywhere for real. Created 5 years, 10 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
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.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.content.ComponentCallbacks2; 9 import android.content.ComponentCallbacks2;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 public AwLayoutSizer createLayoutSizer() { 174 public AwLayoutSizer createLayoutSizer() {
175 return new AwLayoutSizer(); 175 return new AwLayoutSizer();
176 } 176 }
177 177
178 public AwScrollOffsetManager createScrollOffsetManager( 178 public AwScrollOffsetManager createScrollOffsetManager(
179 AwScrollOffsetManager.Delegate delegate, OverScroller overScroll er) { 179 AwScrollOffsetManager.Delegate delegate, OverScroller overScroll er) {
180 return new AwScrollOffsetManager(delegate, overScroller); 180 return new AwScrollOffsetManager(delegate, overScroller);
181 } 181 }
182 } 182 }
183 183
184 /**
185 * Callback used when flushing the visual state, see {@link #flushVisualStat e}.
186 */
187 @VisibleForTesting
188 public abstract static class VisualStateFlushCallback {
189 public abstract void onComplete();
190 public abstract void onFailure();
191 }
192
184 private long mNativeAwContents; 193 private long mNativeAwContents;
185 private final AwBrowserContext mBrowserContext; 194 private final AwBrowserContext mBrowserContext;
186 private ViewGroup mContainerView; 195 private ViewGroup mContainerView;
187 private final AwLayoutChangeListener mLayoutChangeListener; 196 private final AwLayoutChangeListener mLayoutChangeListener;
188 private final Context mContext; 197 private final Context mContext;
189 private ContentViewCore mContentViewCore; 198 private ContentViewCore mContentViewCore;
190 private WindowAndroid mWindowAndroid; 199 private WindowAndroid mWindowAndroid;
191 private WebContents mWebContents; 200 private WebContents mWebContents;
192 private NavigationController mNavigationController; 201 private NavigationController mNavigationController;
193 private final AwContentsClient mContentsClient; 202 private final AwContentsClient mContentsClient;
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 public void hideAutofillPopup() { 2031 public void hideAutofillPopup() {
2023 if (mAwAutofillClient != null) { 2032 if (mAwAutofillClient != null) {
2024 mAwAutofillClient.hideAutofillPopup(); 2033 mAwAutofillClient.hideAutofillPopup();
2025 } 2034 }
2026 } 2035 }
2027 2036
2028 public void setNetworkAvailable(boolean networkUp) { 2037 public void setNetworkAvailable(boolean networkUp) {
2029 if (!isDestroyed()) nativeSetJsOnlineProperty(mNativeAwContents, network Up); 2038 if (!isDestroyed()) nativeSetJsOnlineProperty(mNativeAwContents, network Up);
2030 } 2039 }
2031 2040
2041 /**
2042 * Flush the visual state.
2043 *
2044 * Flushing the visual state means queuing a callback in Blink that will be invoked when the
2045 * contents of the DOM tree at the moment that the callback was enqueued (or later) are drawn
2046 * into the screen. In other words, the following events need to happen befo re the callback is
2047 * invoked:
2048 * 1. The DOM tree is committed becoming the pending tree - see ThreadProxy: :BeginMainFrame
2049 * 2. The pending tree is activated becoming the active tree
2050 * 3. A frame swap happens that draws the active tree into the screen
2051 */
2052 public void flushVisualState(VisualStateFlushCallback callback) {
2053 nativeFlushVisualState(mNativeAwContents, callback);
2054 }
2055
2032 //-------------------------------------------------------------------------- ------------------ 2056 //-------------------------------------------------------------------------- ------------------
2033 // Methods called from native via JNI 2057 // Methods called from native via JNI
2034 //-------------------------------------------------------------------------- ------------------ 2058 //-------------------------------------------------------------------------- ------------------
2035 2059
2036 @CalledByNative 2060 @CalledByNative
2037 private static void onDocumentHasImagesResponse(boolean result, Message mess age) { 2061 private static void onDocumentHasImagesResponse(boolean result, Message mess age) {
2038 message.arg1 = result ? 1 : 0; 2062 message.arg1 = result ? 1 : 0;
2039 message.sendToTarget(); 2063 message.sendToTarget();
2040 } 2064 }
2041 2065
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 } 2149 }
2126 2150
2127 @CalledByNative 2151 @CalledByNative
2128 public void onNewPicture() { 2152 public void onNewPicture() {
2129 // Don't call capturePicture() here but instead defer it until the poste d task runs within 2153 // Don't call capturePicture() here but instead defer it until the poste d task runs within
2130 // the callback helper, to avoid doubling back into the renderer composi tor in the middle 2154 // the callback helper, to avoid doubling back into the renderer composi tor in the middle
2131 // of the notification it is sending up to here. 2155 // of the notification it is sending up to here.
2132 mContentsClient.getCallbackHelper().postOnNewPicture(mPictureListenerCon tentProvider); 2156 mContentsClient.getCallbackHelper().postOnNewPicture(mPictureListenerCon tentProvider);
2133 } 2157 }
2134 2158
2159 /**
2160 * Invokes the given {@link VisualStateFlushCallback}.
2161 *
2162 * @param result true if the flush request was successful and false otherwis e
2163 */
2164 @CalledByNative
2165 public void flushVisualStateCallback(
2166 final VisualStateFlushCallback callback, final boolean result) {
2167 // Posting avoids invoking the callback inside invoking_composite_
2168 // (see synchronous_compositor_impl.cc and crbug/452530).
2169 mContainerView.getHandler().post(new Runnable() {
2170 @Override
2171 public void run() {
2172 if (result) {
2173 callback.onComplete();
2174 } else {
2175 callback.onFailure();
2176 }
2177 }
2178 });
2179 }
2180
2135 // Called as a result of nativeUpdateLastHitTestData. 2181 // Called as a result of nativeUpdateLastHitTestData.
2136 @CalledByNative 2182 @CalledByNative
2137 private void updateHitTestData( 2183 private void updateHitTestData(
2138 int type, String extra, String href, String anchorText, String imgSr c) { 2184 int type, String extra, String href, String anchorText, String imgSr c) {
2139 mPossiblyStaleHitTestData.hitTestResultType = type; 2185 mPossiblyStaleHitTestData.hitTestResultType = type;
2140 mPossiblyStaleHitTestData.hitTestResultExtraData = extra; 2186 mPossiblyStaleHitTestData.hitTestResultExtraData = extra;
2141 mPossiblyStaleHitTestData.href = href; 2187 mPossiblyStaleHitTestData.href = href;
2142 mPossiblyStaleHitTestData.anchorText = anchorText; 2188 mPossiblyStaleHitTestData.anchorText = anchorText;
2143 mPossiblyStaleHitTestData.imgSrc = imgSrc; 2189 mPossiblyStaleHitTestData.imgSrc = imgSrc;
2144 } 2190 }
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 // Returns false if restore state fails. 2727 // Returns false if restore state fails.
2682 private native boolean nativeRestoreFromOpaqueState(long nativeAwContents, b yte[] state); 2728 private native boolean nativeRestoreFromOpaqueState(long nativeAwContents, b yte[] state);
2683 2729
2684 private native long nativeReleasePopupAwContents(long nativeAwContents); 2730 private native long nativeReleasePopupAwContents(long nativeAwContents);
2685 private native void nativeFocusFirstNode(long nativeAwContents); 2731 private native void nativeFocusFirstNode(long nativeAwContents);
2686 private native void nativeSetBackgroundColor(long nativeAwContents, int colo r); 2732 private native void nativeSetBackgroundColor(long nativeAwContents, int colo r);
2687 2733
2688 private native long nativeGetAwDrawGLViewContext(long nativeAwContents); 2734 private native long nativeGetAwDrawGLViewContext(long nativeAwContents);
2689 private native long nativeCapturePicture(long nativeAwContents, int width, i nt height); 2735 private native long nativeCapturePicture(long nativeAwContents, int width, i nt height);
2690 private native void nativeEnableOnNewPicture(long nativeAwContents, boolean enabled); 2736 private native void nativeEnableOnNewPicture(long nativeAwContents, boolean enabled);
2737 private native void nativeFlushVisualState(
2738 long nativeAwContents, VisualStateFlushCallback callback);
2691 private native void nativeClearView(long nativeAwContents); 2739 private native void nativeClearView(long nativeAwContents);
2692 private native void nativeSetExtraHeadersForUrl(long nativeAwContents, 2740 private native void nativeSetExtraHeadersForUrl(long nativeAwContents,
2693 String url, String extraHeaders); 2741 String url, String extraHeaders);
2694 2742
2695 private native void nativeInvokeGeolocationCallback( 2743 private native void nativeInvokeGeolocationCallback(
2696 long nativeAwContents, boolean value, String requestingFrame); 2744 long nativeAwContents, boolean value, String requestingFrame);
2697 2745
2698 private native void nativeSetJsOnlineProperty(long nativeAwContents, boolean networkUp); 2746 private native void nativeSetJsOnlineProperty(long nativeAwContents, boolean networkUp);
2699 2747
2700 private native void nativeTrimMemory(long nativeAwContents, int level, boole an visible); 2748 private native void nativeTrimMemory(long nativeAwContents, int level, boole an visible);
2701 2749
2702 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); 2750 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter);
2703 2751
2704 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, 2752 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin,
2705 long resources); 2753 long resources);
2706 2754
2707 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, 2755 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId,
2708 String message, String sourceOrigin, String targetOrigin, int[] msgP orts); 2756 String message, String sourceOrigin, String targetOrigin, int[] msgP orts);
2709 2757
2710 private native void nativeCreateMessageChannel(long nativeAwContents, 2758 private native void nativeCreateMessageChannel(long nativeAwContents,
2711 ValueCallback<MessageChannel> callback); 2759 ValueCallback<MessageChannel> callback);
2712 } 2760 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698