зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1215139 - Separate out nsWindow closing from disposeNative; r=snorp
This patch adds a separate close() call to nsWindow, and let the GeckoView decide whether to make that call or not. This lets us use the static version of disposeNative. If nsWindow is destroyed in the meantime, we still want to call disposeNative, which would only be possible using the static version of disposeNative.
This commit is contained in:
Родитель
be2a6f1785
Коммит
1b57167834
|
@ -118,6 +118,7 @@ public class GeckoView extends LayerView
|
|||
static native void open(Window instance, GeckoView view, int width, int height);
|
||||
static native void setLayerClient(Object client);
|
||||
@Override protected native void disposeNative();
|
||||
native void close();
|
||||
}
|
||||
|
||||
private final Window window = new Window();
|
||||
|
@ -238,9 +239,16 @@ public class GeckoView extends LayerView
|
|||
{
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
// FIXME: because we don't support separate nsWindow for each GeckoView
|
||||
// yet, we have to keep this window around in case another GeckoView
|
||||
// wants to attach. So don't call window.close() for now.
|
||||
|
||||
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
|
||||
// window.close();
|
||||
window.disposeNative();
|
||||
} else {
|
||||
// GeckoThread.queueNativeCallUntil(GeckoThread.State.PROFILE_READY,
|
||||
// window, "close");
|
||||
GeckoThread.queueNativeCallUntil(GeckoThread.State.PROFILE_READY,
|
||||
window, "disposeNative");
|
||||
}
|
||||
|
|
|
@ -169,6 +169,10 @@ class GeckoView::Window::Natives : public mozilla::jni::NativeImpl<Window, Impl>
|
|||
public:
|
||||
static constexpr JNINativeMethod methods[] = {
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoView::Window::Close_t>(
|
||||
mozilla::jni::NativeStub<GeckoView::Window::Close_t, Impl>
|
||||
::template Wrap<&Impl::Close>),
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoView::Window::DisposeNative_t>(
|
||||
mozilla::jni::NativeStub<GeckoView::Window::DisposeNative_t, Impl>
|
||||
::template Wrap<&Impl::DisposeNative>),
|
||||
|
|
|
@ -1070,6 +1070,9 @@ auto GeckoView::Window::New() -> Window::LocalRef
|
|||
return mozilla::jni::Constructor<New_t>::Call(nullptr, nullptr);
|
||||
}
|
||||
|
||||
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[];
|
||||
|
||||
|
|
|
@ -2802,6 +2802,21 @@ public:
|
|||
|
||||
static auto New() -> Window::LocalRef;
|
||||
|
||||
public:
|
||||
struct Close_t {
|
||||
typedef Window Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "close";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
public:
|
||||
struct DisposeNative_t {
|
||||
typedef Window Owner;
|
||||
|
|
|
@ -28,12 +28,14 @@ using mozilla::unused;
|
|||
|
||||
#include "nsWindow.h"
|
||||
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISelection.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWidgetListener.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIXULWindow.h"
|
||||
|
||||
#include "nsAppShell.h"
|
||||
#include "nsFocusManager.h"
|
||||
|
@ -184,8 +186,7 @@ public:
|
|||
/**
|
||||
* GeckoView methods
|
||||
*/
|
||||
// Detach and destroy the window that we created in Open().
|
||||
void DisposeNative(const GeckoView::Window::LocalRef& aInstance);
|
||||
using Base::DisposeNative;
|
||||
|
||||
// Create and attach a window.
|
||||
static void Open(const jni::ClassObject::LocalRef& aCls,
|
||||
|
@ -201,6 +202,9 @@ public:
|
|||
widget::GeckoLayerClient::Ref::From(aClient.Get()));
|
||||
}
|
||||
|
||||
// Close and destroy the nsWindow.
|
||||
void Close();
|
||||
|
||||
/**
|
||||
* GeckoEditable methods
|
||||
*/
|
||||
|
@ -288,22 +292,22 @@ nsWindow::Natives::Open(const jni::ClassObject::LocalRef& aCls,
|
|||
}
|
||||
|
||||
void
|
||||
nsWindow::Natives::DisposeNative(const GeckoView::Window::LocalRef& aInstance)
|
||||
nsWindow::Natives::Close()
|
||||
{
|
||||
// FIXME: because we don't support separate nsWindow for each GeckoView
|
||||
// yet, we have to keep this window around in case another GeckoView
|
||||
// wants to attach.
|
||||
/*
|
||||
if (mWidgetListener) {
|
||||
nsCOMPtr<nsIXULWindow> xulWindow(mWidgetListener->GetXULWindow());
|
||||
// GeckoView-created top-level windows should be a XUL window.
|
||||
MOZ_ASSERT(xulWindow);
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(xulWindow));
|
||||
MOZ_ASSERT(baseWindow);
|
||||
baseWindow->Destroy();
|
||||
nsIWidgetListener* const widgetListener = window.mWidgetListener;
|
||||
|
||||
if (!widgetListener) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
Base::DisposeNative(aInstance);
|
||||
|
||||
nsCOMPtr<nsIXULWindow> xulWindow(widgetListener->GetXULWindow());
|
||||
// GeckoView-created top-level windows should be a XUL window.
|
||||
MOZ_ASSERT(xulWindow);
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(xulWindow));
|
||||
MOZ_ASSERT(baseWindow);
|
||||
|
||||
baseWindow->Destroy();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче