mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1243070 - Remove obsolete size-change code; r=snorp
Remove obsolete SIZE_CHANGED event and its handler in nsWindow. Also remove some other supporting code (such as gAndroidBounds and the FORCED_RESIZE event) that should be unnecessary by now.
This commit is contained in:
parent
f25839a719
commit
6c833a3654
@ -68,12 +68,11 @@ public class GeckoEvent {
|
||||
// Make sure to keep these values in sync with the enum in
|
||||
// AndroidGeckoEvent in widget/android/AndroidJavaWrappers.h
|
||||
@JNITarget
|
||||
private enum NativeGeckoEvent {
|
||||
public enum NativeGeckoEvent {
|
||||
NATIVE_POKE(0),
|
||||
MOTION_EVENT(2),
|
||||
SENSOR_EVENT(3),
|
||||
LOCATION_EVENT(5),
|
||||
SIZE_CHANGED(8),
|
||||
APP_BACKGROUNDING(9),
|
||||
APP_FOREGROUNDING(10),
|
||||
LOAD_URI(12),
|
||||
@ -470,14 +469,6 @@ public class GeckoEvent {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static GeckoEvent createSizeChangedEvent(int w, int h, int screenw, int screenh) {
|
||||
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.SIZE_CHANGED);
|
||||
event.mPoints = new Point[2];
|
||||
event.mPoints[0] = new Point(w, h);
|
||||
event.mPoints[1] = new Point(screenw, screenh);
|
||||
return event;
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
public static GeckoEvent createBroadcastEvent(String subject, String data) {
|
||||
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.BROADCAST);
|
||||
|
@ -344,10 +344,6 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
||||
mAckNeeded = jenv->GetBooleanField(jobj, jAckNeededField);
|
||||
|
||||
switch (mType) {
|
||||
case SIZE_CHANGED:
|
||||
ReadPointArray(mPoints, jenv, jPoints, 2);
|
||||
break;
|
||||
|
||||
case NATIVE_GESTURE_EVENT:
|
||||
mTime = jenv->GetLongField(jobj, jTimeField);
|
||||
mMetaState = jenv->GetIntField(jobj, jMetaStateField);
|
||||
@ -520,17 +516,6 @@ AndroidGeckoEvent::Init(int aType)
|
||||
mAckNeeded = false;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::Init(AndroidGeckoEvent *aResizeEvent)
|
||||
{
|
||||
NS_ASSERTION(aResizeEvent->Type() == SIZE_CHANGED, "Init called on non-SIZE_CHANGED event");
|
||||
|
||||
mType = FORCED_RESIZE;
|
||||
mAckNeeded = false;
|
||||
mTime = aResizeEvent->mTime;
|
||||
mPoints = aResizeEvent->mPoints; // x,y coordinates
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidGeckoEvent::CanCoalesceWith(AndroidGeckoEvent* ae)
|
||||
{
|
||||
|
@ -428,7 +428,6 @@ private:
|
||||
|
||||
void Init(JNIEnv *jenv, jobject jobj);
|
||||
void Init(int aType);
|
||||
void Init(AndroidGeckoEvent *aResizeEvent);
|
||||
|
||||
public:
|
||||
static void InitGeckoEventClass(JNIEnv *jEnv);
|
||||
@ -445,12 +444,6 @@ public:
|
||||
return event;
|
||||
}
|
||||
|
||||
static AndroidGeckoEvent* CopyResizeEvent(AndroidGeckoEvent *aResizeEvent) {
|
||||
AndroidGeckoEvent *event = new AndroidGeckoEvent();
|
||||
event->Init(aResizeEvent);
|
||||
return event;
|
||||
}
|
||||
|
||||
static AndroidGeckoEvent* MakeBroadcastEvent(const nsCString& topic, const nsCString& data) {
|
||||
AndroidGeckoEvent* event = new AndroidGeckoEvent();
|
||||
event->Init(BROADCAST);
|
||||
@ -643,12 +636,10 @@ public:
|
||||
MOTION_EVENT = 2,
|
||||
SENSOR_EVENT = 3,
|
||||
LOCATION_EVENT = 5,
|
||||
SIZE_CHANGED = 8,
|
||||
APP_BACKGROUNDING = 9,
|
||||
APP_FOREGROUNDING = 10,
|
||||
LOAD_URI = 12,
|
||||
NOOP = 15,
|
||||
FORCED_RESIZE = 16, // used internally in nsAppShell/nsWindow
|
||||
APZ_INPUT_EVENT = 17, // used internally in AndroidJNI/nsAppShell/nsWindow
|
||||
BROADCAST = 19,
|
||||
VIEWPORT = 20,
|
||||
|
@ -735,15 +735,6 @@ nsAppShell::LegacyGeckoEvent::Run()
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::SIZE_CHANGED: {
|
||||
// store the last resize event to dispatch it to new windows with a FORCED_RESIZE event
|
||||
if (curEvent.get() != gLastSizeChange) {
|
||||
gLastSizeChange = AndroidGeckoEvent::CopyResizeEvent(curEvent.get());
|
||||
}
|
||||
nsWindow::OnGlobalAndroidEvent(curEvent.get());
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::VISITED: {
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
||||
@ -953,13 +944,6 @@ nsAppShell::LegacyGeckoEvent::PostTo(mozilla::LinkedList<Event>& queue)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsAppShell::ResendLastResizeEvent(nsWindow* aDest) {
|
||||
if (gLastSizeChange) {
|
||||
nsWindow::OnGlobalAndroidEvent(gLastSizeChange);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAppShell::AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver)
|
||||
{
|
||||
|
@ -139,8 +139,6 @@ public:
|
||||
mozilla::UniquePtr<Event>(*eventFactory)(
|
||||
mozilla::UniquePtr<Event>&&) = nullptr);
|
||||
|
||||
void ResendLastResizeEvent(nsWindow* aDest);
|
||||
|
||||
void SetBrowserApp(nsIAndroidBrowserApp* aBrowserApp) {
|
||||
mBrowserApp = aBrowserApp;
|
||||
}
|
||||
|
@ -89,8 +89,6 @@ using namespace mozilla::layers;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
|
||||
|
||||
// The dimensions of the current android view
|
||||
static gfx::IntSize gAndroidBounds = gfx::IntSize(0, 0);
|
||||
static gfx::IntSize gAndroidScreenBounds;
|
||||
|
||||
#include "mozilla/layers/CompositorChild.h"
|
||||
@ -141,7 +139,7 @@ NS_IMPL_ISUPPORTS(ContentCreationNotifier,
|
||||
nsIObserver)
|
||||
|
||||
// All the toplevel windows that have been created; these are in
|
||||
// stacking order, so the window at gAndroidBounds[0] is the topmost
|
||||
// stacking order, so the window at gTopLevelWindows[0] is the topmost
|
||||
// one.
|
||||
static nsTArray<nsWindow*> gTopLevelWindows;
|
||||
|
||||
@ -1155,11 +1153,15 @@ nsWindow::Create(nsIWidget* aParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
nsWidgetInitData* aInitData)
|
||||
{
|
||||
ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent,
|
||||
aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
|
||||
nsWindow *parent = (nsWindow*) aParent;
|
||||
if (aNativeParent) {
|
||||
if (parent) {
|
||||
ALOG("Ignoring native parent on Android window [%p], since parent was specified (%p %p)", (void*)this, (void*)aNativeParent, (void*)aParent);
|
||||
ALOG("Ignoring native parent on Android window [%p], "
|
||||
"since parent was specified (%p %p)", (void*)this,
|
||||
(void*)aNativeParent, (void*)aParent);
|
||||
} else {
|
||||
parent = (nsWindow*) aNativeParent;
|
||||
}
|
||||
@ -1167,23 +1169,15 @@ nsWindow::Create(nsIWidget* aParent,
|
||||
|
||||
mBounds = aRect;
|
||||
|
||||
// for toplevel windows, bounds are fixed to full screen size
|
||||
if (!parent) {
|
||||
mBounds.x = 0;
|
||||
mBounds.y = 0;
|
||||
mBounds.width = gAndroidBounds.width;
|
||||
mBounds.height = gAndroidBounds.height;
|
||||
}
|
||||
|
||||
BaseCreate(nullptr, aInitData);
|
||||
|
||||
NS_ASSERTION(IsTopLevel() || parent, "non top level windowdoesn't have a parent!");
|
||||
NS_ASSERTION(IsTopLevel() || parent,
|
||||
"non-top-level window doesn't have a parent!");
|
||||
|
||||
if (IsTopLevel()) {
|
||||
gTopLevelWindows.AppendElement(this);
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
} else if (parent) {
|
||||
parent->mChildren.AppendElement(this);
|
||||
mParent = parent;
|
||||
}
|
||||
@ -1337,10 +1331,9 @@ nsWindow::Show(bool aState)
|
||||
// if Show() is the right place to do this, though.
|
||||
|
||||
if (aState) {
|
||||
// It just became visible, so send a resize update if necessary
|
||||
// and bring it to the front.
|
||||
Resize(0, 0, gAndroidBounds.width, gAndroidBounds.height, false);
|
||||
// It just became visible, so bring it to the front.
|
||||
BringToFront();
|
||||
|
||||
} else if (nsWindow::TopWindow() == this) {
|
||||
// find the next visible window to show
|
||||
unsigned int i;
|
||||
@ -1546,9 +1539,9 @@ nsWindow::BringToFront()
|
||||
RefPtr<nsWindow> kungFuDeathGrip(this);
|
||||
|
||||
nsWindow *oldTop = nullptr;
|
||||
nsWindow *newTop = this;
|
||||
if (!gTopLevelWindows.IsEmpty())
|
||||
if (!gTopLevelWindows.IsEmpty()) {
|
||||
oldTop = gTopLevelWindows[0];
|
||||
}
|
||||
|
||||
gTopLevelWindows.RemoveElement(this);
|
||||
gTopLevelWindows.InsertElementAt(0, this);
|
||||
@ -1560,21 +1553,10 @@ nsWindow::BringToFront()
|
||||
}
|
||||
}
|
||||
|
||||
if (Destroyed()) {
|
||||
// somehow the deactivate event handler destroyed this window.
|
||||
// try to recover by grabbing the next window in line and activating
|
||||
// that instead
|
||||
if (gTopLevelWindows.IsEmpty())
|
||||
return;
|
||||
newTop = gTopLevelWindows[0];
|
||||
}
|
||||
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->WindowActivated();
|
||||
}
|
||||
|
||||
// force a window resize
|
||||
nsAppShell::Get()->ResendLastResizeEvent(newTop);
|
||||
RedrawAll();
|
||||
}
|
||||
|
||||
@ -1691,76 +1673,6 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
||||
return;
|
||||
|
||||
switch (ae->Type()) {
|
||||
case AndroidGeckoEvent::FORCED_RESIZE:
|
||||
win->mBounds.width = 0;
|
||||
win->mBounds.height = 0;
|
||||
// also resize the children
|
||||
for (uint32_t i = 0; i < win->mChildren.Length(); i++) {
|
||||
win->mChildren[i]->mBounds.width = 0;
|
||||
win->mChildren[i]->mBounds.height = 0;
|
||||
}
|
||||
case AndroidGeckoEvent::SIZE_CHANGED: {
|
||||
const nsTArray<nsIntPoint>& points = ae->Points();
|
||||
NS_ASSERTION(points.Length() == 2, "Size changed does not have enough coordinates");
|
||||
|
||||
int nw = points[0].x;
|
||||
int nh = points[0].y;
|
||||
|
||||
if (ae->Type() == AndroidGeckoEvent::FORCED_RESIZE || nw != gAndroidBounds.width ||
|
||||
nh != gAndroidBounds.height) {
|
||||
gAndroidBounds.width = nw;
|
||||
gAndroidBounds.height = nh;
|
||||
|
||||
// tell all the windows about the new size
|
||||
for (size_t i = 0; i < gTopLevelWindows.Length(); ++i) {
|
||||
if (gTopLevelWindows[i]->mIsVisible)
|
||||
gTopLevelWindows[i]->Resize(gAndroidBounds.width,
|
||||
gAndroidBounds.height,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
int newScreenWidth = points[1].x;
|
||||
int newScreenHeight = points[1].y;
|
||||
|
||||
if (newScreenWidth == gAndroidScreenBounds.width &&
|
||||
newScreenHeight == gAndroidScreenBounds.height)
|
||||
break;
|
||||
|
||||
gAndroidScreenBounds.width = newScreenWidth;
|
||||
gAndroidScreenBounds.height = newScreenHeight;
|
||||
|
||||
if (!XRE_IsParentProcess() &&
|
||||
!Preferences::GetBool("browser.tabs.remote.desktopbehavior", false)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// 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)
|
||||
break;
|
||||
|
||||
// If the content process is not created yet, wait until it's
|
||||
// created and then tell it the screen size.
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService();
|
||||
if (!obs)
|
||||
break;
|
||||
|
||||
RefPtr<ContentCreationNotifier> notifier = new ContentCreationNotifier;
|
||||
if (NS_SUCCEEDED(obs->AddObserver(notifier, "ipc:content-created", false))) {
|
||||
if (NS_SUCCEEDED(obs->AddObserver(notifier, "xpcom-shutdown", false)))
|
||||
gContentCreationNotifier = notifier;
|
||||
else
|
||||
obs->RemoveObserver(notifier, "ipc:content-created");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::APZ_INPUT_EVENT: {
|
||||
win->UserActivity();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user