зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1243070 - Use native method to notify window size change; r=snorp
Convert the SIZE_CHANGED event to a native method in GLController, and carry over the SIZE_CHANGED implementation to the new implementation in GLController. Some other changes were made for correctness in handling size changes.
This commit is contained in:
Родитель
5e98c7369d
Коммит
f25839a719
|
@ -74,6 +74,10 @@ public class GLController extends JNIObject {
|
|||
/* package */ native void attachToJava(GeckoLayerClient layerClient,
|
||||
NativePanZoomController npzc);
|
||||
|
||||
@WrapForJNI
|
||||
/* package */ native void onSizeChanged(int windowWidth, int windowHeight,
|
||||
int screenWidth, int screenHeight);
|
||||
|
||||
// Gecko thread creates compositor; blocks UI thread.
|
||||
@WrapForJNI
|
||||
private native void createCompositor(int width, int height);
|
||||
|
|
|
@ -277,9 +277,8 @@ class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
|||
Log.d(LOGTAG, "Window-size changed to " + mWindowSize);
|
||||
}
|
||||
|
||||
GeckoEvent event = GeckoEvent.createSizeChangedEvent(mWindowSize.width, mWindowSize.height,
|
||||
mView.getGLController().onSizeChanged(mWindowSize.width, mWindowSize.height,
|
||||
mScreenSize.width, mScreenSize.height);
|
||||
GeckoAppShell.sendEventToGecko(event);
|
||||
|
||||
String json = "";
|
||||
try {
|
||||
|
@ -297,7 +296,7 @@ class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
|||
json = jsonObj.toString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(LOGTAG, "Unable to convert point to JSON for " + event, e);
|
||||
Log.e(LOGTAG, "Unable to convert point to JSON", e);
|
||||
}
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Window:Resize", json));
|
||||
}
|
||||
|
|
|
@ -259,6 +259,10 @@ public:
|
|||
mozilla::jni::NativeStub<GLController::DisposeNative_t, Impl>
|
||||
::template Wrap<&Impl::DisposeNative>),
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GLController::OnSizeChanged_t>(
|
||||
mozilla::jni::NativeStub<GLController::OnSizeChanged_t, Impl>
|
||||
::template Wrap<&Impl::OnSizeChanged>),
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GLController::PauseCompositor_t>(
|
||||
mozilla::jni::NativeStub<GLController::PauseCompositor_t, Impl>
|
||||
::template Wrap<&Impl::PauseCompositor>),
|
||||
|
|
|
@ -1307,6 +1307,9 @@ auto GLController::Destroy() const -> void
|
|||
constexpr char GLController::DisposeNative_t::name[];
|
||||
constexpr char GLController::DisposeNative_t::signature[];
|
||||
|
||||
constexpr char GLController::OnSizeChanged_t::name[];
|
||||
constexpr char GLController::OnSizeChanged_t::signature[];
|
||||
|
||||
constexpr char GLController::PauseCompositor_t::name[];
|
||||
constexpr char GLController::PauseCompositor_t::signature[];
|
||||
|
||||
|
|
|
@ -3582,6 +3582,25 @@ public:
|
|||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
public:
|
||||
struct OnSizeChanged_t {
|
||||
typedef GLController Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
int32_t,
|
||||
int32_t,
|
||||
int32_t,
|
||||
int32_t> Args;
|
||||
static constexpr char name[] = "onSizeChanged";
|
||||
static constexpr char signature[] =
|
||||
"(IIII)V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
public:
|
||||
struct PauseCompositor_t {
|
||||
typedef GLController Owner;
|
||||
|
|
|
@ -867,6 +867,58 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
void OnSizeChanged(int32_t aWindowWidth, int32_t aWindowHeight,
|
||||
int32_t aScreenWidth, int32_t aScreenHeight)
|
||||
{
|
||||
if (aWindowWidth != window.mBounds.width ||
|
||||
aWindowHeight != window.mBounds.height) {
|
||||
|
||||
window.Resize(aWindowWidth, aWindowHeight, /* repaint */ false);
|
||||
}
|
||||
|
||||
if (aScreenWidth == gAndroidScreenBounds.width &&
|
||||
aScreenHeight == gAndroidScreenBounds.height) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gAndroidScreenBounds.width = aScreenWidth;
|
||||
gAndroidScreenBounds.height = aScreenHeight;
|
||||
|
||||
if (!XRE_IsParentProcess() &&
|
||||
!Preferences::GetBool("browser.tabs.remote.desktopbehavior",
|
||||
false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Tell the content process the new screen size.
|
||||
nsTArray<ContentParent*> cplist;
|
||||
ContentParent::GetAll(cplist);
|
||||
for (uint32_t i = 0; i < cplist.Length(); ++i) {
|
||||
Unused << cplist[i]->SendScreenSizeChanged(gAndroidScreenBounds);
|
||||
}
|
||||
|
||||
if (gContentCreationNotifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the content process is not created yet, wait until it's
|
||||
// created and then tell it the screen size.
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (!obs) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<ContentCreationNotifier> notifier = new ContentCreationNotifier;
|
||||
if (NS_FAILED(obs->AddObserver(notifier, "xpcom-shutdown", false)) ||
|
||||
NS_FAILED(obs->AddObserver(
|
||||
notifier, "ipc:content-created", false))) {
|
||||
return;
|
||||
}
|
||||
|
||||
gContentCreationNotifier = notifier;
|
||||
}
|
||||
|
||||
void CreateCompositor(int32_t aWidth, int32_t aHeight)
|
||||
{
|
||||
window.CreateLayerManager(aWidth, aHeight);
|
||||
|
@ -965,7 +1017,7 @@ nsWindow::GeckoViewSupport::Open(const jni::ClassObject::LocalRef& aCls,
|
|||
}
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> domWindow;
|
||||
ww->OpenWindow(nullptr, url, "_blank", "chrome,dialog=no,all",
|
||||
ww->OpenWindow(nullptr, url, nullptr, "chrome,dialog=0,resizable",
|
||||
args, getter_AddRefs(domWindow));
|
||||
MOZ_ASSERT(domWindow);
|
||||
|
||||
|
@ -985,6 +1037,16 @@ nsWindow::GeckoViewSupport::Open(const jni::ClassObject::LocalRef& aCls,
|
|||
aCls.Env(), GLController::Ref::From(aGLController)));
|
||||
|
||||
gGeckoViewWindow = window;
|
||||
|
||||
if (window->mWidgetListener) {
|
||||
nsCOMPtr<nsIXULWindow> xulWindow(
|
||||
window->mWidgetListener->GetXULWindow());
|
||||
if (xulWindow) {
|
||||
// Out window is not intrinsically sized, so tell nsXULWindow to
|
||||
// not set a size for us.
|
||||
xulWindow->SetIntrinsicallySized(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1751,6 +1813,10 @@ nsWindow::OnSizeChanged(const gfx::IntSize& aSize)
|
|||
if (mWidgetListener) {
|
||||
mWidgetListener->WindowResized(this, aSize.width, aSize.height);
|
||||
}
|
||||
|
||||
if (mAttachedWidgetListener) {
|
||||
mAttachedWidgetListener->WindowResized(this, aSize.width, aSize.height);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче