From 7e883500e079a591f39278969a8f5145209e784a Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Thu, 10 Apr 2014 22:21:36 -0400 Subject: [PATCH] Bug 937713 - Replace gWindowToRedraw with a simpler mechanism, r=roc --- dom/xbl/crashtests/crashtests.list | 2 +- widget/gonk/nsWindow.cpp | 53 ++++++++++++++---------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/dom/xbl/crashtests/crashtests.list b/dom/xbl/crashtests/crashtests.list index 79081fabb3a..746a52f5671 100644 --- a/dom/xbl/crashtests/crashtests.list +++ b/dom/xbl/crashtests/crashtests.list @@ -4,7 +4,7 @@ load 226744-1.xhtml load 232095-1.xul load 277523-1.xhtml load 277950-1.xhtml -skip-if(Android||browserIsRemote) load 336744-1.html # no remote support for xul popups, bug 617653 +skip-if(Android||B2G||browserIsRemote) load 336744-1.html # no remote support for xul popups, bug 617653 asserts(0-1) load 336960-1.html # maybe bug 429586 load 342954-1.xhtml load 342954-2.xhtml diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index 4b87f8fac54..6830692edd3 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -69,7 +69,6 @@ static nsIntRect sVirtualBounds; static nsRefPtr sGLContext; static nsTArray sTopWindows; -static nsWindow *gWindowToRedraw = nullptr; static nsWindow *gFocusedWindow = nullptr; static bool sFramebufferOpen; static bool sUsingOMTC; @@ -186,20 +185,24 @@ nsWindow::DoDraw(void) return; } - if (!gWindowToRedraw) { + if (sTopWindows.IsEmpty()) { LOG(" no window to draw, bailing"); return; } - nsIntRegion region = gWindowToRedraw->mDirtyRegion; - gWindowToRedraw->mDirtyRegion.SetEmpty(); + nsWindow *targetWindow = (nsWindow *)sTopWindows[0]; + while (targetWindow->GetLastChild()) + targetWindow = (nsWindow *)targetWindow->GetLastChild(); - nsIWidgetListener* listener = gWindowToRedraw->GetWidgetListener(); + nsIntRegion region = sTopWindows[0]->mDirtyRegion; + sTopWindows[0]->mDirtyRegion.SetEmpty(); + + nsIWidgetListener* listener = targetWindow->GetWidgetListener(); if (listener) { - listener->WillPaintWindow(gWindowToRedraw); + listener->WillPaintWindow(targetWindow); } - LayerManager* lm = gWindowToRedraw->GetLayerManager(); + LayerManager* lm = targetWindow->GetLayerManager(); if (mozilla::layers::LayersBackend::LAYERS_CLIENT == lm->GetBackendType()) { // No need to do anything, the compositor will handle drawing } else if (mozilla::layers::LayersBackend::LAYERS_BASIC == lm->GetBackendType()) { @@ -218,12 +221,12 @@ nsWindow::DoDraw(void) // No double-buffering needed. AutoLayerManagerSetup setupLayerManager( - gWindowToRedraw, ctx, mozilla::layers::BufferMode::BUFFER_NONE, + targetWindow, ctx, mozilla::layers::BufferMode::BUFFER_NONE, ScreenRotation(EffectiveScreenRotation())); - listener = gWindowToRedraw->GetWidgetListener(); + listener = targetWindow->GetWidgetListener(); if (listener) { - listener->PaintWindow(gWindowToRedraw, region); + listener->PaintWindow(targetWindow, region); } } @@ -235,7 +238,7 @@ nsWindow::DoDraw(void) NS_RUNTIMEABORT("Unexpected layer manager type"); } - listener = gWindowToRedraw->GetWidgetListener(); + listener = targetWindow->GetWidgetListener(); if (listener) { listener->DidPaintWindow(); } @@ -282,11 +285,10 @@ nsWindow::Create(nsIWidget *aParent, mBounds = aRect; - nsWindow *parent = (nsWindow *)aNativeParent; - mParent = parent; + mParent = (nsWindow *)aParent; mVisible = false; - if (!aNativeParent) { + if (!aParent) { mBounds = sVirtualBounds; } @@ -304,8 +306,6 @@ nsWindow::Destroy(void) { mOnDestroyCalled = true; sTopWindows.RemoveElement(this); - if (this == gWindowToRedraw) - gWindowToRedraw = nullptr; if (this == gFocusedWindow) gFocusedWindow = nullptr; nsBaseWidget::OnDestroy(); @@ -382,8 +382,8 @@ nsWindow::Resize(double aX, if (mWidgetListener) mWidgetListener->WindowResized(this, mBounds.width, mBounds.height); - if (aRepaint && gWindowToRedraw) - gWindowToRedraw->Invalidate(sVirtualBounds); + if (aRepaint) + Invalidate(sVirtualBounds); return NS_OK; } @@ -419,14 +419,13 @@ nsWindow::ConfigureChildren(const nsTArray&) NS_IMETHODIMP nsWindow::Invalidate(const nsIntRect &aRect) { - nsWindow *parent = mParent; - while (parent && parent != sTopWindows[0]) - parent = parent->mParent; - if (parent != sTopWindows[0]) + nsWindow *top = mParent; + while (top && top->mParent) + top = top->mParent; + if (top != sTopWindows[0] && this != sTopWindows[0]) return NS_OK; mDirtyRegion.Or(mDirtyRegion, aRect); - gWindowToRedraw = this; gDrawRequest = true; mozilla::NotifyEvent(); return NS_OK; @@ -454,8 +453,6 @@ nsWindow::GetNativeData(uint32_t aDataType) switch (aDataType) { case NS_NATIVE_WINDOW: return GetGonkDisplay()->GetNativeWindow(); - case NS_NATIVE_WIDGET: - return this; } return nullptr; } @@ -768,12 +765,12 @@ nsScreenGonk::SetRotation(uint32_t aRotation) sVirtualBounds = gScreenBounds; } + nsAppShell::NotifyScreenRotation(); + for (unsigned int i = 0; i < sTopWindows.Length(); i++) sTopWindows[i]->Resize(sVirtualBounds.width, sVirtualBounds.height, - !i); - - nsAppShell::NotifyScreenRotation(); + true); return NS_OK; }