зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1413698 - 1. Separate out attach() from open() in GeckoView.Window; r=snorp
Right now, `GeckoView.Window.open()` consists of opening a new Gecko nsWindow and attaching it to the opening GeckoView. This patch separates the attaching step into an `Window.attach()` function that was renamed from `Window.reattach()`. Going forward, `Window.open()` and `Window.close()` will correspond to opening and closing a session, which `Window.attach()` will correspond to attaching a display to a session. MozReview-Commit-ID: 94Un74pwizY --HG-- extra : rebase_source : a7d9c6c3227de4b05e800d77a184f1deae9af5f8
This commit is contained in:
Родитель
d57079bd3c
Коммит
6fdb886eb4
|
@ -598,7 +598,7 @@ final class GeckoEditable extends IGeckoEditableParent.Stub
|
|||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private GeckoEditable(final GeckoView v) {
|
||||
private GeckoEditable() {
|
||||
if (DEBUG) {
|
||||
// Called by nsWindow.
|
||||
ThreadUtils.assertOnGeckoThread();
|
||||
|
@ -613,8 +613,6 @@ final class GeckoEditable extends IGeckoEditableParent.Stub
|
|||
PROXY_INTERFACES, this);
|
||||
|
||||
mIcRunHandler = mIcPostHandler = ThreadUtils.getUiHandler();
|
||||
|
||||
onViewChange(v);
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
|
|
|
@ -75,7 +75,7 @@ public class GeckoView extends LayerView {
|
|||
}
|
||||
}
|
||||
|
||||
private final NativeQueue mNativeQueue =
|
||||
/* package */ final NativeQueue mNativeQueue =
|
||||
new NativeQueue(State.INITIAL, State.READY);
|
||||
|
||||
private final EventDispatcher mEventDispatcher =
|
||||
|
@ -310,25 +310,23 @@ public class GeckoView extends LayerView {
|
|||
public final String chromeUri;
|
||||
|
||||
@WrapForJNI(skip = true)
|
||||
/* package */ NativeQueue mNativeQueue;
|
||||
private NativeQueue mNativeQueue;
|
||||
|
||||
@WrapForJNI(skip = true)
|
||||
/* package */ Window(final String chromeUri, final NativeQueue queue) {
|
||||
/* package */ Window(final String chromeUri) {
|
||||
this.chromeUri = chromeUri;
|
||||
mNativeQueue = queue;
|
||||
}
|
||||
|
||||
static native void open(Window instance, GeckoView view,
|
||||
Object compositor, EventDispatcher dispatcher,
|
||||
String chromeUri, GeckoBundle settings,
|
||||
static native void open(Window instance, EventDispatcher dispatcher,
|
||||
GeckoBundle settings, String chromeUri,
|
||||
int screenId, boolean privateMode);
|
||||
|
||||
@Override protected native void disposeNative();
|
||||
|
||||
native void close();
|
||||
|
||||
native void reattach(GeckoView view, Object compositor,
|
||||
EventDispatcher dispatcher);
|
||||
native void attach(GeckoView view, Object compositor,
|
||||
EventDispatcher dispatcher);
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private synchronized void setState(final State newState) {
|
||||
|
@ -341,11 +339,12 @@ public class GeckoView extends LayerView {
|
|||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private synchronized void onReattach(final GeckoView view) {
|
||||
private synchronized void onAttach(final GeckoView view) {
|
||||
if (view.mNativeQueue == mNativeQueue) {
|
||||
return;
|
||||
} else if (mNativeQueue != null) {
|
||||
view.mNativeQueue.setState(mNativeQueue.getState());
|
||||
}
|
||||
view.mNativeQueue.setState(mNativeQueue.getState());
|
||||
mNativeQueue = view.mNativeQueue;
|
||||
}
|
||||
}
|
||||
|
@ -541,31 +540,30 @@ public class GeckoView extends LayerView {
|
|||
}
|
||||
|
||||
protected void openWindow() {
|
||||
mWindow = new Window(mChromeUri, mNativeQueue);
|
||||
mWindow = new Window(mChromeUri);
|
||||
|
||||
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
|
||||
Window.open(mWindow, this, getCompositor(), mEventDispatcher,
|
||||
mChromeUri, mSettings.asBundle(), mScreenId,
|
||||
Window.open(mWindow, mEventDispatcher, mSettings.asBundle(),
|
||||
mChromeUri, mScreenId,
|
||||
mSettings.getBoolean(GeckoViewSettings.USE_PRIVATE_MODE));
|
||||
} else {
|
||||
GeckoThread.queueNativeCallUntil(
|
||||
GeckoThread.State.PROFILE_READY,
|
||||
Window.class, "open", mWindow,
|
||||
GeckoView.class, this,
|
||||
Object.class, getCompositor(),
|
||||
Window.class, "open",
|
||||
Window.class, mWindow,
|
||||
EventDispatcher.class, mEventDispatcher,
|
||||
String.class, mChromeUri,
|
||||
GeckoBundle.class, mSettings.asBundle(),
|
||||
String.class, mChromeUri,
|
||||
mScreenId, mSettings.getBoolean(GeckoViewSettings.USE_PRIVATE_MODE));
|
||||
}
|
||||
}
|
||||
|
||||
protected void reattachWindow() {
|
||||
protected void attachView() {
|
||||
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
|
||||
mWindow.reattach(this, getCompositor(), mEventDispatcher);
|
||||
mWindow.attach(this, getCompositor(), mEventDispatcher);
|
||||
} else {
|
||||
GeckoThread.queueNativeCallUntil(GeckoThread.State.PROFILE_READY,
|
||||
mWindow, "reattach", GeckoView.class, this,
|
||||
mWindow, "attach", GeckoView.class, this,
|
||||
Object.class, getCompositor(), EventDispatcher.class, mEventDispatcher);
|
||||
}
|
||||
}
|
||||
|
@ -577,10 +575,10 @@ public class GeckoView extends LayerView {
|
|||
if (mWindow == null) {
|
||||
// Open a new nsWindow if we didn't have one from before.
|
||||
openWindow();
|
||||
} else {
|
||||
reattachWindow();
|
||||
}
|
||||
|
||||
attachView();
|
||||
|
||||
super.onAttachedToWindow();
|
||||
}
|
||||
|
||||
|
|
|
@ -267,6 +267,10 @@ public:
|
|||
template<class Impl>
|
||||
const JNINativeMethod GeckoView::Window::Natives<Impl>::methods[] = {
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoView::Window::Attach_t>(
|
||||
mozilla::jni::NativeStub<GeckoView::Window::Attach_t, Impl>
|
||||
::template Wrap<&Impl::Attach>),
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoView::Window::Close_t>(
|
||||
mozilla::jni::NativeStub<GeckoView::Window::Close_t, Impl>
|
||||
::template Wrap<&Impl::Close>),
|
||||
|
@ -277,11 +281,7 @@ const JNINativeMethod GeckoView::Window::Natives<Impl>::methods[] = {
|
|||
|
||||
mozilla::jni::MakeNativeMethod<GeckoView::Window::Open_t>(
|
||||
mozilla::jni::NativeStub<GeckoView::Window::Open_t, Impl>
|
||||
::template Wrap<&Impl::Open>),
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoView::Window::Reattach_t>(
|
||||
mozilla::jni::NativeStub<GeckoView::Window::Reattach_t, Impl>
|
||||
::template Wrap<&Impl::Reattach>)
|
||||
::template Wrap<&Impl::Open>)
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
|
|
|
@ -650,9 +650,9 @@ const char GeckoEditable::name[] =
|
|||
constexpr char GeckoEditable::New_t::name[];
|
||||
constexpr char GeckoEditable::New_t::signature[];
|
||||
|
||||
auto GeckoEditable::New(mozilla::jni::Object::Param a0) -> GeckoEditable::LocalRef
|
||||
auto GeckoEditable::New() -> GeckoEditable::LocalRef
|
||||
{
|
||||
return mozilla::jni::Constructor<New_t>::Call(GeckoEditable::Context(), nullptr, a0);
|
||||
return mozilla::jni::Constructor<New_t>::Call(GeckoEditable::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoEditable::OnViewChange_t::name[];
|
||||
|
@ -975,26 +975,26 @@ auto GeckoView::State::READY() -> State::LocalRef
|
|||
const char GeckoView::Window::name[] =
|
||||
"org/mozilla/gecko/GeckoView$Window";
|
||||
|
||||
constexpr char GeckoView::Window::Attach_t::name[];
|
||||
constexpr char GeckoView::Window::Attach_t::signature[];
|
||||
|
||||
constexpr char GeckoView::Window::Close_t::name[];
|
||||
constexpr char GeckoView::Window::Close_t::signature[];
|
||||
|
||||
constexpr char GeckoView::Window::DisposeNative_t::name[];
|
||||
constexpr char GeckoView::Window::DisposeNative_t::signature[];
|
||||
|
||||
constexpr char GeckoView::Window::OnReattach_t::name[];
|
||||
constexpr char GeckoView::Window::OnReattach_t::signature[];
|
||||
constexpr char GeckoView::Window::OnAttach_t::name[];
|
||||
constexpr char GeckoView::Window::OnAttach_t::signature[];
|
||||
|
||||
auto GeckoView::Window::OnReattach(GeckoView::Param a0) const -> void
|
||||
auto GeckoView::Window::OnAttach(GeckoView::Param a0) const -> void
|
||||
{
|
||||
return mozilla::jni::Method<OnReattach_t>::Call(Window::mCtx, nullptr, a0);
|
||||
return mozilla::jni::Method<OnAttach_t>::Call(Window::mCtx, nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoView::Window::Open_t::name[];
|
||||
constexpr char GeckoView::Window::Open_t::signature[];
|
||||
|
||||
constexpr char GeckoView::Window::Reattach_t::name[];
|
||||
constexpr char GeckoView::Window::Reattach_t::signature[];
|
||||
|
||||
constexpr char GeckoView::Window::SetState_t::name[];
|
||||
constexpr char GeckoView::Window::SetState_t::signature[];
|
||||
|
||||
|
|
|
@ -1846,11 +1846,10 @@ public:
|
|||
typedef GeckoEditable Owner;
|
||||
typedef GeckoEditable::LocalRef ReturnType;
|
||||
typedef GeckoEditable::Param SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "<init>";
|
||||
static constexpr char signature[] =
|
||||
"(Lorg/mozilla/gecko/GeckoView;)V";
|
||||
"()V";
|
||||
static const bool isStatic = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
|
@ -1860,7 +1859,7 @@ public:
|
|||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto New(mozilla::jni::Object::Param) -> GeckoEditable::LocalRef;
|
||||
static auto New() -> GeckoEditable::LocalRef;
|
||||
|
||||
struct OnViewChange_t {
|
||||
typedef GeckoEditable Owner;
|
||||
|
@ -2900,6 +2899,26 @@ public:
|
|||
|
||||
explicit Window(const Context& ctx) : ObjectBase<Window>(ctx) {}
|
||||
|
||||
struct Attach_t {
|
||||
typedef Window Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
GeckoView::Param,
|
||||
mozilla::jni::Object::Param,
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "attach";
|
||||
static constexpr char signature[] =
|
||||
"(Lorg/mozilla/gecko/GeckoView;Ljava/lang/Object;Lorg/mozilla/gecko/EventDispatcher;)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::ANY;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::PROXY;
|
||||
};
|
||||
|
||||
struct Close_t {
|
||||
typedef Window Owner;
|
||||
typedef void ReturnType;
|
||||
|
@ -2934,13 +2953,13 @@ public:
|
|||
mozilla::jni::DispatchTarget::PROXY;
|
||||
};
|
||||
|
||||
struct OnReattach_t {
|
||||
struct OnAttach_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 name[] = "onAttach";
|
||||
static constexpr char signature[] =
|
||||
"(Lorg/mozilla/gecko/GeckoView;)V";
|
||||
static const bool isStatic = false;
|
||||
|
@ -2952,7 +2971,7 @@ public:
|
|||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
auto OnReattach(GeckoView::Param) const -> void;
|
||||
auto OnAttach(GeckoView::Param) const -> void;
|
||||
|
||||
struct Open_t {
|
||||
typedef Window Owner;
|
||||
|
@ -2960,16 +2979,14 @@ public:
|
|||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
Window::Param,
|
||||
GeckoView::Param,
|
||||
mozilla::jni::Object::Param,
|
||||
mozilla::jni::Object::Param,
|
||||
mozilla::jni::String::Param,
|
||||
mozilla::jni::Object::Param,
|
||||
int32_t,
|
||||
bool> Args;
|
||||
static constexpr char name[] = "open";
|
||||
static constexpr char signature[] =
|
||||
"(Lorg/mozilla/gecko/GeckoView$Window;Lorg/mozilla/gecko/GeckoView;Ljava/lang/Object;Lorg/mozilla/gecko/EventDispatcher;Ljava/lang/String;Lorg/mozilla/gecko/util/GeckoBundle;IZ)V";
|
||||
"(Lorg/mozilla/gecko/GeckoView$Window;Lorg/mozilla/gecko/EventDispatcher;Lorg/mozilla/gecko/util/GeckoBundle;Ljava/lang/String;IZ)V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
|
@ -2979,26 +2996,6 @@ public:
|
|||
mozilla::jni::DispatchTarget::PROXY;
|
||||
};
|
||||
|
||||
struct Reattach_t {
|
||||
typedef Window Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
GeckoView::Param,
|
||||
mozilla::jni::Object::Param,
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "reattach";
|
||||
static constexpr char signature[] =
|
||||
"(Lorg/mozilla/gecko/GeckoView;Ljava/lang/Object;Lorg/mozilla/gecko/EventDispatcher;)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::ANY;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::PROXY;
|
||||
};
|
||||
|
||||
struct SetState_t {
|
||||
typedef Window Owner;
|
||||
typedef void ReturnType;
|
||||
|
|
|
@ -279,10 +279,9 @@ public:
|
|||
// Create and attach a window.
|
||||
static void Open(const jni::Class::LocalRef& aCls,
|
||||
GeckoView::Window::Param aWindow,
|
||||
GeckoView::Param aView, jni::Object::Param aCompositor,
|
||||
jni::Object::Param aDispatcher,
|
||||
jni::String::Param aChromeURI,
|
||||
jni::Object::Param aSettings,
|
||||
jni::String::Param aChromeURI,
|
||||
int32_t aScreenId,
|
||||
bool aPrivateMode);
|
||||
|
||||
|
@ -290,9 +289,9 @@ public:
|
|||
void Close();
|
||||
|
||||
// Reattach this nsWindow to a new GeckoView.
|
||||
void Reattach(const GeckoView::Window::LocalRef& inst,
|
||||
GeckoView::Param aView, jni::Object::Param aCompositor,
|
||||
jni::Object::Param aDispatcher);
|
||||
void Attach(const GeckoView::Window::LocalRef& inst,
|
||||
GeckoView::Param aView, jni::Object::Param aCompositor,
|
||||
jni::Object::Param aDispatcher);
|
||||
|
||||
void EnableEventDispatcher();
|
||||
};
|
||||
|
@ -1263,11 +1262,9 @@ nsWindow::GeckoViewSupport::~GeckoViewSupport()
|
|||
/* static */ void
|
||||
nsWindow::GeckoViewSupport::Open(const jni::Class::LocalRef& aCls,
|
||||
GeckoView::Window::Param aWindow,
|
||||
GeckoView::Param aView,
|
||||
jni::Object::Param aCompositor,
|
||||
jni::Object::Param aDispatcher,
|
||||
jni::String::Param aChromeURI,
|
||||
jni::Object::Param aSettings,
|
||||
jni::String::Param aChromeURI,
|
||||
int32_t aScreenId,
|
||||
bool aPrivateMode)
|
||||
{
|
||||
|
@ -1319,17 +1316,12 @@ nsWindow::GeckoViewSupport::Open(const jni::Class::LocalRef& aCls,
|
|||
window->mGeckoViewSupport->mDOMWindow = pdomWindow;
|
||||
|
||||
// Attach a new GeckoEditable support object to the new window.
|
||||
auto editable = GeckoEditable::New(aView);
|
||||
auto editable = GeckoEditable::New();
|
||||
auto editableChild = GeckoEditableChild::New(editable);
|
||||
editable->SetDefaultEditableChild(editableChild);
|
||||
window->mEditable = editable;
|
||||
window->mEditableSupport.Attach(editableChild, window, editableChild);
|
||||
|
||||
// Attach the Compositor to the new window.
|
||||
auto compositor = LayerView::Compositor::LocalRef(
|
||||
aCls.Env(), LayerView::Compositor::Ref::From(aCompositor));
|
||||
window->mLayerViewSupport.Attach(compositor, window, compositor);
|
||||
|
||||
// Attach again using the new window.
|
||||
androidView->mEventDispatcher->Attach(
|
||||
java::EventDispatcher::Ref::From(aDispatcher), pdomWindow);
|
||||
|
@ -1363,10 +1355,10 @@ nsWindow::GeckoViewSupport::Close()
|
|||
}
|
||||
|
||||
void
|
||||
nsWindow::GeckoViewSupport::Reattach(const GeckoView::Window::LocalRef& inst,
|
||||
GeckoView::Param aView,
|
||||
jni::Object::Param aCompositor,
|
||||
jni::Object::Param aDispatcher)
|
||||
nsWindow::GeckoViewSupport::Attach(const GeckoView::Window::LocalRef& inst,
|
||||
GeckoView::Param aView,
|
||||
jni::Object::Param aCompositor,
|
||||
jni::Object::Param aDispatcher)
|
||||
{
|
||||
// Associate our previous GeckoEditable with the new GeckoView.
|
||||
MOZ_ASSERT(window.mEditable);
|
||||
|
@ -1378,8 +1370,9 @@ nsWindow::GeckoViewSupport::Reattach(const GeckoView::Window::LocalRef& inst,
|
|||
window.mNPZCSupport.Detach();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(window.mLayerViewSupport);
|
||||
window.mLayerViewSupport.Detach();
|
||||
if (window.mLayerViewSupport) {
|
||||
window.mLayerViewSupport.Detach();
|
||||
}
|
||||
|
||||
auto compositor = LayerView::Compositor::LocalRef(
|
||||
inst.Env(), LayerView::Compositor::Ref::From(aCompositor));
|
||||
|
@ -1390,7 +1383,7 @@ nsWindow::GeckoViewSupport::Reattach(const GeckoView::Window::LocalRef& inst,
|
|||
window.mAndroidView->mEventDispatcher->Attach(
|
||||
java::EventDispatcher::Ref::From(aDispatcher), mDOMWindow);
|
||||
|
||||
mGeckoViewWindow->OnReattach(aView);
|
||||
mGeckoViewWindow->OnAttach(aView);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче