Skip to content

Commit

Permalink
Backout rev 4fe82d0824d1 (bug 946658) for suspected Tp5 regression. r=me
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsPalmgren committed Mar 7, 2014
1 parent f0319b7 commit d65d6b0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 82 deletions.
5 changes: 0 additions & 5 deletions view/public/nsViewManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "nsCRT.h"
#include "nsVoidArray.h"
#include "nsDeviceContext.h"
#include "nsTArray.h"
#include "mozilla/EventForwards.h"

class nsIWidget;
Expand Down Expand Up @@ -328,10 +327,6 @@ class nsViewManager MOZ_FINAL

void ProcessPendingUpdatesForView(nsView *aView,
bool aFlushDirtyRegion = true);
void ProcessPendingUpdatesRecurse(nsView* aView,
nsTArray<nsCOMPtr<nsIWidget> >& aWidgets);
void ProcessPendingUpdatesPaint(nsIWidget* aWidget);

void FlushDirtyRegionToWidget(nsView* aView);
/**
* Call WillPaint() on all view observers under this vm root.
Expand Down
124 changes: 47 additions & 77 deletions view/src/nsViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,104 +366,74 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
}
}

void
nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
bool aFlushDirtyRegion)
void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
bool aFlushDirtyRegion)
{
NS_ASSERTION(IsRootVM(), "Updates will be missed");
if (!aView) {

// Protect against a null-view.
nsViewManager* viewManager = aView ? aView->GetViewManager() : nullptr;
if (!aView || !viewManager) {
return;
}

nsCOMPtr<nsIPresShell> rootShell(mPresShell);
nsTArray<nsCOMPtr<nsIWidget> > widgets;
aView->GetViewManager()->ProcessPendingUpdatesRecurse(aView, widgets);
for (uint32_t i = 0; i < widgets.Length(); ++i) {
nsView* view = nsView::GetViewFor(widgets[i]);
if (view) {
view->ResetWidgetBounds(false, true);
}
}
if (rootShell->GetViewManager() != this) {
return; // 'this' might have been destroyed
}
if (aFlushDirtyRegion) {
nsAutoScriptBlocker scriptBlocker;
SetPainting(true);
for (uint32_t i = 0; i < widgets.Length(); ++i) {
nsIWidget* widget = widgets[i];
nsView* view = nsView::GetViewFor(widget);
if (view) {
view->GetViewManager()->ProcessPendingUpdatesPaint(widget);
}
}
SetPainting(false);
nsIPresShell* presShell = viewManager->mPresShell;
if (presShell && presShell->IsNeverPainting()) {
return;
}
}

void
nsViewManager::ProcessPendingUpdatesRecurse(nsView* aView,
nsTArray<nsCOMPtr<nsIWidget> >& aWidgets)
{
if (mPresShell && mPresShell->IsNeverPainting()) {
return;
if (aView->HasWidget()) {
aView->ResetWidgetBounds(false, true);
}

// process pending updates in child view.
for (nsView* childView = aView->GetFirstChild(); childView;
childView = childView->GetNextSibling()) {
childView->GetViewManager()->
ProcessPendingUpdatesRecurse(childView, aWidgets);
}

nsIWidget* widget = aView->GetWidget();
if (widget) {
aWidgets.AppendElement(widget);
} else {
FlushDirtyRegionToWidget(aView);
ProcessPendingUpdatesForView(childView, aFlushDirtyRegion);
}
}

void
nsViewManager::ProcessPendingUpdatesPaint(nsIWidget* aWidget)
{
if (aWidget->NeedsPaint()) {
// If an ancestor widget was hidden and then shown, we could
// have a delayed resize to handle.
for (nsViewManager *vm = this; vm;
vm = vm->mRootView->GetParent()
? vm->mRootView->GetParent()->GetViewManager()
: nullptr) {
if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
vm->mRootView->IsEffectivelyVisible() &&
vm->mPresShell && vm->mPresShell->IsVisible()) {
vm->FlushDelayedResize(true);
// Push out updates after we've processed the children; ensures that
// damage is applied based on the final widget geometry
if (aFlushDirtyRegion) {
nsIWidget *widget = aView->GetWidget();
if (widget && widget->NeedsPaint()) {
// If an ancestor widget was hidden and then shown, we could
// have a delayed resize to handle.
for (nsViewManager *vm = viewManager; vm;
vm = vm->mRootView->GetParent()
? vm->mRootView->GetParent()->GetViewManager()
: nullptr) {
if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
vm->mRootView->IsEffectivelyVisible() &&
vm->mPresShell && vm->mPresShell->IsVisible()) {
vm->FlushDelayedResize(true);
}
}
}
nsView* view = nsView::GetViewFor(aWidget);
if (!view) {
NS_ERROR("FlushDelayedResize destroyed the nsView?");
return;
}
NS_ASSERTION(aView->HasWidget(), "FlushDelayedResize removed our widget!");

if (mPresShell) {
if (presShell) {
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf_stderr("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n",
mPresShell, view, aWidget);
}
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf_stderr("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", presShell, aView, widget);
}
#endif

mPresShell->Paint(view, nsRegion(), nsIPresShell::PAINT_LAYERS);
view->SetForcedRepaint(false);

nsAutoScriptBlocker scriptBlocker;
SetPainting(true);
presShell->Paint(aView, nsRegion(), nsIPresShell::PAINT_LAYERS);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf_stderr("---- PAINT END ----\n");
}
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf_stderr("---- PAINT END ----\n");
}
#endif

aView->SetForcedRepaint(false);
SetPainting(false);
}
viewManager->FlushDirtyRegionToWidget(aView);
} else {
viewManager->FlushDirtyRegionToWidget(aView);
}
}
FlushDirtyRegionToWidget(nsView::GetViewFor(aWidget));
}

void nsViewManager::FlushDirtyRegionToWidget(nsView* aView)
Expand Down

0 comments on commit d65d6b0

Please sign in to comment.