Bug 1351169 - [1.2] Update GeckoView's state after finishing window reattachment. r=jchen

This commit is contained in:
Eugen Sawin 2017-04-12 21:51:00 +02:00
parent 6a6d84470c
commit f6e5f80eca
5 changed files with 42 additions and 8 deletions

View File

@ -237,7 +237,8 @@ public final class EventDispatcher extends JNIObject {
public void dispatch(final String type, final GeckoBundle message,
final EventCallback callback) {
synchronized (this) {
if (isReadyForDispatchingToGecko() && hasGeckoListener(type)) {
if (isReadyForDispatchingToGecko() && mAttachedToGecko &&
hasGeckoListener(type)) {
dispatchToGecko(type, message, JavaCallbackDelegate.wrap(callback));
return;
}

View File

@ -110,6 +110,16 @@ public class GeckoView extends LayerView
private synchronized void setState(final State newState) {
mNativeQueue.setState(newState);
}
@WrapForJNI(calledFrom = "gecko")
private synchronized void onReattach(final GeckoView view) {
if (view.mNativeQueue == mNativeQueue) {
return;
}
view.mNativeQueue.setState(mNativeQueue.getState());
mNativeQueue = view.mNativeQueue;
}
}
// Object to hold onto our nsWindow connection when GeckoView gets destroyed.
@ -299,13 +309,6 @@ public class GeckoView extends LayerView
}
protected void reattachWindow() {
synchronized (mWindow) {
if (mNativeQueue != mWindow.mNativeQueue) {
mNativeQueue.setState(mWindow.mNativeQueue.getState());
mWindow.mNativeQueue = mNativeQueue;
}
}
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
mWindow.reattach(this, getCompositor(), mEventDispatcher);
} else {

View File

@ -998,6 +998,14 @@ constexpr char GeckoView::Window::DisposeNative_t::signature[];
constexpr char GeckoView::Window::LoadUri_t::name[];
constexpr char GeckoView::Window::LoadUri_t::signature[];
constexpr char GeckoView::Window::OnReattach_t::name[];
constexpr char GeckoView::Window::OnReattach_t::signature[];
auto GeckoView::Window::OnReattach(GeckoView::Param a0) const -> void
{
return mozilla::jni::Method<OnReattach_t>::Call(Window::mCtx, nullptr, a0);
}
constexpr char GeckoView::Window::Open_t::name[];
constexpr char GeckoView::Window::Open_t::signature[];

View File

@ -3004,6 +3004,26 @@ public:
mozilla::jni::DispatchTarget::PROXY;
};
struct OnReattach_t {
typedef Window Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
GeckoView::Param> Args;
static constexpr char name[] = "onReattach";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/GeckoView;)V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::GECKO;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto OnReattach(GeckoView::Param) const -> void;
struct Open_t {
typedef Window Owner;
typedef void ReturnType;

View File

@ -1332,6 +1332,8 @@ nsWindow::GeckoViewSupport::Reattach(const GeckoView::Window::LocalRef& inst,
MOZ_ASSERT(window.mAndroidView);
window.mAndroidView->mEventDispatcher->Attach(
java::EventDispatcher::Ref::From(aDispatcher), mDOMWindow);
mGeckoViewWindow->OnReattach(aView);
}
void