зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1346542 - [1.2] Move state holder to GeckoView::Window and set ready state when reattaching to window. r=jchen
This commit is contained in:
Родитель
b3137a6749
Коммит
80710c9297
|
@ -55,7 +55,7 @@ public final class EventDispatcher extends JNIObject {
|
||||||
new HashMap<String, List<BundleEventListener>>(DEFAULT_BACKGROUND_EVENTS_COUNT);
|
new HashMap<String, List<BundleEventListener>>(DEFAULT_BACKGROUND_EVENTS_COUNT);
|
||||||
|
|
||||||
private boolean mAttachedToGecko;
|
private boolean mAttachedToGecko;
|
||||||
private final StateHolder mStateHolder;
|
private volatile StateHolder mStateHolder;
|
||||||
|
|
||||||
@ReflectionTarget
|
@ReflectionTarget
|
||||||
@WrapForJNI(calledFrom = "gecko")
|
@WrapForJNI(calledFrom = "gecko")
|
||||||
|
@ -71,6 +71,12 @@ public final class EventDispatcher extends JNIObject {
|
||||||
mStateHolder = stateHolder;
|
mStateHolder = stateHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* package */ void setStateHolder(final NativeQueue.StateHolder stateHolder) {
|
||||||
|
mStateHolder = stateHolder;
|
||||||
|
// Force queue flushing.
|
||||||
|
mStateHolder.setState(mStateHolder.getState());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isReadyForDispatchingToGecko() {
|
private boolean isReadyForDispatchingToGecko() {
|
||||||
return mStateHolder.isReady();
|
return mStateHolder.isReady();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,16 +67,11 @@ public class GeckoView extends LayerView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final StateHolder mStateHolder =
|
private static final StateHolder sDummyStateHolder =
|
||||||
new StateHolder(State.INITIAL, State.READY);
|
new StateHolder(State.INITIAL, State.READY);
|
||||||
|
|
||||||
@WrapForJNI(calledFrom = "gecko")
|
|
||||||
private void setState(final State newState) {
|
|
||||||
mStateHolder.setState(newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final EventDispatcher mEventDispatcher =
|
private final EventDispatcher mEventDispatcher =
|
||||||
new EventDispatcher(mStateHolder);
|
new EventDispatcher(sDummyStateHolder);
|
||||||
|
|
||||||
private ChromeDelegate mChromeDelegate;
|
private ChromeDelegate mChromeDelegate;
|
||||||
/* package */ ContentListener mContentListener;
|
/* package */ ContentListener mContentListener;
|
||||||
|
@ -92,6 +87,10 @@ public class GeckoView extends LayerView
|
||||||
|
|
||||||
@WrapForJNI(dispatchTo = "proxy")
|
@WrapForJNI(dispatchTo = "proxy")
|
||||||
protected static final class Window extends JNIObject {
|
protected static final class Window extends JNIObject {
|
||||||
|
@WrapForJNI(skip = true)
|
||||||
|
/* package */ final StateHolder mStateHolder =
|
||||||
|
new StateHolder(State.INITIAL, State.READY);
|
||||||
|
|
||||||
@WrapForJNI(skip = true)
|
@WrapForJNI(skip = true)
|
||||||
/* package */ Window() {}
|
/* package */ Window() {}
|
||||||
|
|
||||||
|
@ -101,9 +100,18 @@ public class GeckoView extends LayerView
|
||||||
int screenId);
|
int screenId);
|
||||||
|
|
||||||
@Override protected native void disposeNative();
|
@Override protected native void disposeNative();
|
||||||
|
|
||||||
native void close();
|
native void close();
|
||||||
native void reattach(GeckoView view, Object compositor, EventDispatcher dispatcher);
|
|
||||||
|
native void reattach(GeckoView view, Object compositor,
|
||||||
|
EventDispatcher dispatcher);
|
||||||
|
|
||||||
native void loadUri(String uri, int flags);
|
native void loadUri(String uri, int flags);
|
||||||
|
|
||||||
|
@WrapForJNI(calledFrom = "gecko")
|
||||||
|
private void setState(final State newState) {
|
||||||
|
mStateHolder.setState(newState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object to hold onto our nsWindow connection when GeckoView gets destroyed.
|
// Object to hold onto our nsWindow connection when GeckoView gets destroyed.
|
||||||
|
@ -244,7 +252,7 @@ public class GeckoView extends LayerView
|
||||||
final StateBinder stateBinder = (StateBinder) state;
|
final StateBinder stateBinder = (StateBinder) state;
|
||||||
|
|
||||||
if (stateBinder.window != null) {
|
if (stateBinder.window != null) {
|
||||||
this.window = stateBinder.window;
|
window = stateBinder.window;
|
||||||
}
|
}
|
||||||
stateSaved = false;
|
stateSaved = false;
|
||||||
|
|
||||||
|
@ -279,6 +287,8 @@ public class GeckoView extends LayerView
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reattachWindow() {
|
protected void reattachWindow() {
|
||||||
|
mEventDispatcher.setStateHolder(mWindow.mStateHolder);
|
||||||
|
|
||||||
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
|
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
|
||||||
window.reattach(this, getCompositor(), mEventDispatcher);
|
window.reattach(this, getCompositor(), mEventDispatcher);
|
||||||
} else {
|
} else {
|
||||||
|
@ -295,6 +305,7 @@ public class GeckoView extends LayerView
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
// Open a new nsWindow if we didn't have one from before.
|
// Open a new nsWindow if we didn't have one from before.
|
||||||
window = new Window();
|
window = new Window();
|
||||||
|
mEventDispatcher.setStateHolder(window.mStateHolder);
|
||||||
openWindow();
|
openWindow();
|
||||||
} else {
|
} else {
|
||||||
reattachWindow();
|
reattachWindow();
|
||||||
|
@ -325,6 +336,7 @@ public class GeckoView extends LayerView
|
||||||
window, "disposeNative");
|
window, "disposeNative");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mEventDispatcher.setStateHolder(sDummyStateHolder);
|
||||||
mOnAttachedToWindowCalled = false;
|
mOnAttachedToWindowCalled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -967,14 +967,6 @@ auto GeckoThread::State::RUNNING() -> State::LocalRef
|
||||||
const char GeckoView::name[] =
|
const char GeckoView::name[] =
|
||||||
"org/mozilla/gecko/GeckoView";
|
"org/mozilla/gecko/GeckoView";
|
||||||
|
|
||||||
constexpr char GeckoView::SetState_t::name[];
|
|
||||||
constexpr char GeckoView::SetState_t::signature[];
|
|
||||||
|
|
||||||
auto GeckoView::SetState(mozilla::jni::Object::Param a0) const -> void
|
|
||||||
{
|
|
||||||
return mozilla::jni::Method<SetState_t>::Call(GeckoView::mCtx, nullptr, a0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char GeckoView::State::name[] =
|
const char GeckoView::State::name[] =
|
||||||
"org/mozilla/gecko/GeckoView$State";
|
"org/mozilla/gecko/GeckoView$State";
|
||||||
|
|
||||||
|
@ -1012,6 +1004,14 @@ constexpr char GeckoView::Window::Open_t::signature[];
|
||||||
constexpr char GeckoView::Window::Reattach_t::name[];
|
constexpr char GeckoView::Window::Reattach_t::name[];
|
||||||
constexpr char GeckoView::Window::Reattach_t::signature[];
|
constexpr char GeckoView::Window::Reattach_t::signature[];
|
||||||
|
|
||||||
|
constexpr char GeckoView::Window::SetState_t::name[];
|
||||||
|
constexpr char GeckoView::Window::SetState_t::signature[];
|
||||||
|
|
||||||
|
auto GeckoView::Window::SetState(mozilla::jni::Object::Param a0) const -> void
|
||||||
|
{
|
||||||
|
return mozilla::jni::Method<SetState_t>::Call(Window::mCtx, nullptr, a0);
|
||||||
|
}
|
||||||
|
|
||||||
const char PrefsHelper::name[] =
|
const char PrefsHelper::name[] =
|
||||||
"org/mozilla/gecko/PrefsHelper";
|
"org/mozilla/gecko/PrefsHelper";
|
||||||
|
|
||||||
|
|
|
@ -2883,26 +2883,6 @@ public:
|
||||||
class State;
|
class State;
|
||||||
class Window;
|
class Window;
|
||||||
|
|
||||||
struct SetState_t {
|
|
||||||
typedef GeckoView Owner;
|
|
||||||
typedef void ReturnType;
|
|
||||||
typedef void SetterType;
|
|
||||||
typedef mozilla::jni::Args<
|
|
||||||
mozilla::jni::Object::Param> Args;
|
|
||||||
static constexpr char name[] = "setState";
|
|
||||||
static constexpr char signature[] =
|
|
||||||
"(Lorg/mozilla/gecko/GeckoView$State;)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 SetState(mozilla::jni::Object::Param) const -> void;
|
|
||||||
|
|
||||||
static const int32_t LOAD_DEFAULT = 0;
|
static const int32_t LOAD_DEFAULT = 0;
|
||||||
|
|
||||||
static const int32_t LOAD_NEW_TAB = 1;
|
static const int32_t LOAD_NEW_TAB = 1;
|
||||||
|
@ -2910,7 +2890,7 @@ public:
|
||||||
static const int32_t LOAD_SWITCH_TAB = 2;
|
static const int32_t LOAD_SWITCH_TAB = 2;
|
||||||
|
|
||||||
static const mozilla::jni::CallingThread callingThread =
|
static const mozilla::jni::CallingThread callingThread =
|
||||||
mozilla::jni::CallingThread::GECKO;
|
mozilla::jni::CallingThread::ANY;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3068,6 +3048,26 @@ public:
|
||||||
mozilla::jni::DispatchTarget::PROXY;
|
mozilla::jni::DispatchTarget::PROXY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SetState_t {
|
||||||
|
typedef Window Owner;
|
||||||
|
typedef void ReturnType;
|
||||||
|
typedef void SetterType;
|
||||||
|
typedef mozilla::jni::Args<
|
||||||
|
mozilla::jni::Object::Param> Args;
|
||||||
|
static constexpr char name[] = "setState";
|
||||||
|
static constexpr char signature[] =
|
||||||
|
"(Lorg/mozilla/gecko/GeckoView$State;)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 SetState(mozilla::jni::Object::Param) const -> void;
|
||||||
|
|
||||||
static const mozilla::jni::CallingThread callingThread =
|
static const mozilla::jni::CallingThread callingThread =
|
||||||
mozilla::jni::CallingThread::ANY;
|
mozilla::jni::CallingThread::ANY;
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ class nsWindow::GeckoViewSupport final
|
||||||
, public SupportsWeakPtr<GeckoViewSupport>
|
, public SupportsWeakPtr<GeckoViewSupport>
|
||||||
{
|
{
|
||||||
nsWindow& window;
|
nsWindow& window;
|
||||||
GeckoView::GlobalRef mView;
|
GeckoView::Window::GlobalRef mGeckoViewWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef GeckoView::Window::Natives<GeckoViewSupport> Base;
|
typedef GeckoView::Window::Natives<GeckoViewSupport> Base;
|
||||||
|
@ -265,10 +265,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoViewSupport(nsWindow* aWindow,
|
GeckoViewSupport(nsWindow* aWindow,
|
||||||
const GeckoView::Window::LocalRef& aInstance,
|
const GeckoView::Window::LocalRef& aInstance)
|
||||||
GeckoView::Param aView)
|
|
||||||
: window(*aWindow)
|
: window(*aWindow)
|
||||||
, mView(aView)
|
, mGeckoViewWindow(aInstance)
|
||||||
{
|
{
|
||||||
Base::AttachNative(aInstance, static_cast<SupportsWeakPtr*>(this));
|
Base::AttachNative(aInstance, static_cast<SupportsWeakPtr*>(this));
|
||||||
}
|
}
|
||||||
|
@ -1252,7 +1251,7 @@ nsWindow::GeckoViewSupport::Open(const jni::Class::LocalRef& aCls,
|
||||||
|
|
||||||
// Attach a new GeckoView support object to the new window.
|
// Attach a new GeckoView support object to the new window.
|
||||||
window->mGeckoViewSupport = mozilla::MakeUnique<GeckoViewSupport>(
|
window->mGeckoViewSupport = mozilla::MakeUnique<GeckoViewSupport>(
|
||||||
window, GeckoView::Window::LocalRef(aCls.Env(), aWindow), aView);
|
window, (GeckoView::Window::LocalRef(aCls.Env(), aWindow)));
|
||||||
|
|
||||||
window->mGeckoViewSupport->mDOMWindow = pdomWindow;
|
window->mGeckoViewSupport->mDOMWindow = pdomWindow;
|
||||||
|
|
||||||
|
@ -1297,6 +1296,7 @@ nsWindow::GeckoViewSupport::Close()
|
||||||
|
|
||||||
mDOMWindow->ForceClose();
|
mDOMWindow->ForceClose();
|
||||||
mDOMWindow = nullptr;
|
mDOMWindow = nullptr;
|
||||||
|
mGeckoViewWindow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2078,8 +2078,10 @@ nsWindow::GetEventTimeStamp(int64_t aEventTime)
|
||||||
void
|
void
|
||||||
nsWindow::GeckoViewSupport::EnableEventDispatcher()
|
nsWindow::GeckoViewSupport::EnableEventDispatcher()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mView);
|
if (!mGeckoViewWindow) {
|
||||||
mView->SetState(GeckoView::State::READY());
|
return;
|
||||||
|
}
|
||||||
|
mGeckoViewWindow->SetState(GeckoView::State::READY());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Загрузка…
Ссылка в новой задаче