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:
Jim Chen
2016-02-01 17:38:14 -05:00
parent 7f399ced34
commit 408f9ac1e8
6 changed files with 15 additions and 154 deletions

View File

@@ -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();