Bug 1508457 - Add GeckoView API to get first composite callback after a compositor start. r=snorp,droeh

Differential Revision: https://phabricator.services.mozilla.com/D12357

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Randall Barker 2018-11-20 18:18:24 +00:00
parent 5abd4e194d
commit 0fa2594f1c
3 changed files with 39 additions and 0 deletions

View File

@ -324,6 +324,7 @@ package org.mozilla.geckoview {
method public void onContextMenu(org.mozilla.geckoview.GeckoSession, int, int, java.lang.String, int, java.lang.String);
method public void onCrash(org.mozilla.geckoview.GeckoSession);
method public void onExternalResponse(org.mozilla.geckoview.GeckoSession, org.mozilla.geckoview.GeckoSession.WebResponseInfo);
method public void onFirstComposite(org.mozilla.geckoview.GeckoSession);
method public void onFocusRequest(org.mozilla.geckoview.GeckoSession);
method public void onFullScreen(org.mozilla.geckoview.GeckoSession, boolean);
method public void onTitleChange(org.mozilla.geckoview.GeckoSession, java.lang.String);

View File

@ -5,8 +5,10 @@
package org.mozilla.geckoview.test
import android.app.assist.AssistStructure
import android.graphics.SurfaceTexture
import android.os.Build
import org.mozilla.geckoview.AllowOrDeny
import org.mozilla.geckoview.GeckoDisplay
import org.mozilla.geckoview.GeckoResult
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoSession.NavigationDelegate.LoadRequest
@ -24,6 +26,7 @@ import android.support.test.filters.SdkSuppress
import android.support.test.runner.AndroidJUnit4
import android.text.InputType
import android.util.SparseArray
import android.view.Surface
import android.view.View
import android.view.ViewStructure
import android.widget.EditText
@ -479,4 +482,27 @@ class ContentDelegateTest : BaseSessionTest() {
mainSession.exitFullScreen()
waitForFullscreenExit()
}
@Test fun firstComposite() {
val display = mainSession.acquireDisplay()
val texture = SurfaceTexture(0)
texture.setDefaultBufferSize(100, 100)
val surface = Surface(texture)
display.surfaceChanged(surface, 100, 100)
mainSession.loadTestPath(HELLO_HTML_PATH)
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onFirstComposite(session: GeckoSession) {
}
})
display.surfaceDestroyed()
display.surfaceChanged(surface, 100, 100)
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
@AssertCalled(count = 1)
override fun onFirstComposite(session: GeckoSession) {
}
})
display.surfaceDestroyed()
mainSession.releaseDisplay(display)
}
}

View File

@ -2593,6 +2593,14 @@ public class GeckoSession implements Parcelable {
* @param session The GeckoSession that crashed.
*/
void onCrash(GeckoSession session);
/**
* Notification that the first content composition has occurred.
* This callback is invoked for the first content composite after either
* a start or a restart of the compositor.
* @param session The GeckoSession that had a first paint event.
*/
default void onFirstComposite(GeckoSession session) {}
}
public interface SelectionActionDelegate {
@ -4115,6 +4123,10 @@ public class GeckoSession implements Parcelable {
if (mController != null) {
mController.onFirstPaint();
}
ContentDelegate delegate = mContentHandler.getDelegate();
if (delegate != null) {
delegate.onFirstComposite(this);
}
break;
}