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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index ba765d90d4e4bd47760dae2fd8f8d39eda30bfc3..ca6e70c613d732955944c9505eb67d7c15e060ff 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -181,6 +181,15 @@ public class AwContents implements SmartClipProvider {
}
}
+ /**
+ * Callback used when flushing the visual state, see {@link #flushVisualState}.
+ */
+ @VisibleForTesting
+ public abstract static class VisualStateFlushCallback {
+ public abstract void onComplete();
+ public abstract void onFailure();
+ }
+
private long mNativeAwContents;
private final AwBrowserContext mBrowserContext;
private ViewGroup mContainerView;
@@ -2029,6 +2038,21 @@ public class AwContents implements SmartClipProvider {
if (!isDestroyed()) nativeSetJsOnlineProperty(mNativeAwContents, networkUp);
}
+ /**
+ * Flush the visual state.
+ *
+ * Flushing the visual state means queuing a callback in Blink that will be invoked when the
+ * contents of the DOM tree at the moment that the callback was enqueued (or later) are drawn
+ * into the screen. In other words, the following events need to happen before the callback is
+ * invoked:
+ * 1. The DOM tree is committed becoming the pending tree - see ThreadProxy::BeginMainFrame
+ * 2. The pending tree is activated becoming the active tree
+ * 3. A frame swap happens that draws the active tree into the screen
+ */
+ public void flushVisualState(VisualStateFlushCallback callback) {
+ nativeFlushVisualState(mNativeAwContents, callback);
+ }
+
//--------------------------------------------------------------------------------------------
// Methods called from native via JNI
//--------------------------------------------------------------------------------------------
@@ -2132,6 +2156,28 @@ public class AwContents implements SmartClipProvider {
mContentsClient.getCallbackHelper().postOnNewPicture(mPictureListenerContentProvider);
}
+ /**
+ * Invokes the given {@link VisualStateFlushCallback}.
+ *
+ * @param result true if the flush request was successful and false otherwise
+ */
+ @CalledByNative
+ public void flushVisualStateCallback(
+ final VisualStateFlushCallback callback, final boolean result) {
+ // Posting avoids invoking the callback inside invoking_composite_
+ // (see synchronous_compositor_impl.cc and crbug/452530).
+ mContainerView.getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ if (result) {
+ callback.onComplete();
+ } else {
+ callback.onFailure();
+ }
+ }
+ });
+ }
+
// Called as a result of nativeUpdateLastHitTestData.
@CalledByNative
private void updateHitTestData(
@@ -2688,6 +2734,8 @@ public class AwContents implements SmartClipProvider {
private native long nativeGetAwDrawGLViewContext(long nativeAwContents);
private native long nativeCapturePicture(long nativeAwContents, int width, int height);
private native void nativeEnableOnNewPicture(long nativeAwContents, boolean enabled);
+ private native void nativeFlushVisualState(
+ long nativeAwContents, VisualStateFlushCallback callback);
private native void nativeClearView(long nativeAwContents);
private native void nativeSetExtraHeadersForUrl(long nativeAwContents,
String url, String extraHeaders);
« 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