mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 598482 part 10 - Small refactoring in nsViewManager. r=roc
This commit is contained in:
parent
610ff178d3
commit
c5f5e5536a
@ -417,34 +417,51 @@ void nsViewManager::ProcessPendingUpdates(nsView* aView, bool aDoInvalidate)
|
||||
ProcessPendingUpdates(childView, aDoInvalidate);
|
||||
}
|
||||
|
||||
if (aDoInvalidate && aView->HasNonEmptyDirtyRegion()) {
|
||||
if (aDoInvalidate) {
|
||||
// Push out updates after we've processed the children; ensures that
|
||||
// damage is applied based on the final widget geometry
|
||||
NS_ASSERTION(IsRefreshEnabled(), "Cannot process pending updates with refresh disabled");
|
||||
nsRegion* dirtyRegion = aView->GetDirtyRegion();
|
||||
if (dirtyRegion) {
|
||||
nsView* nearestViewWithWidget = aView;
|
||||
while (!nearestViewWithWidget->HasWidget() &&
|
||||
nearestViewWithWidget->GetParent()) {
|
||||
nearestViewWithWidget = nearestViewWithWidget->GetParent();
|
||||
}
|
||||
nsRegion r =
|
||||
ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget);
|
||||
nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager();
|
||||
widgetVM->
|
||||
UpdateWidgetArea(nearestViewWithWidget,
|
||||
nearestViewWithWidget->GetWidget(), r);
|
||||
dirtyRegion->SetEmpty();
|
||||
}
|
||||
FlushDirtyRegionToWidget(aView);
|
||||
}
|
||||
}
|
||||
|
||||
void nsViewManager::FlushDirtyRegionToWidget(nsView* aView)
|
||||
{
|
||||
if (!aView->HasNonEmptyDirtyRegion())
|
||||
return;
|
||||
|
||||
nsRegion* dirtyRegion = aView->GetDirtyRegion();
|
||||
nsView* nearestViewWithWidget = aView;
|
||||
while (!nearestViewWithWidget->HasWidget() &&
|
||||
nearestViewWithWidget->GetParent()) {
|
||||
nearestViewWithWidget = nearestViewWithWidget->GetParent();
|
||||
}
|
||||
nsRegion r =
|
||||
ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget);
|
||||
nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager();
|
||||
widgetVM->
|
||||
UpdateWidgetArea(nearestViewWithWidget,
|
||||
nearestViewWithWidget->GetWidget(), r);
|
||||
dirtyRegion->SetEmpty();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView)
|
||||
{
|
||||
// Mark the entire view as damaged
|
||||
return UpdateView(aView, aView->GetDimensions());
|
||||
}
|
||||
|
||||
static void
|
||||
AddDirtyRegion(nsView *aView, const nsRegion &aDamagedRegion)
|
||||
{
|
||||
nsRegion* dirtyRegion = aView->GetDirtyRegion();
|
||||
if (!dirtyRegion)
|
||||
return;
|
||||
|
||||
dirtyRegion->Or(*dirtyRegion, aDamagedRegion);
|
||||
dirtyRegion->SimplifyOutward(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aWidget the widget for aWidgetView; in some cases the widget
|
||||
* is being managed directly by the frame system, so aWidgetView->GetWidget()
|
||||
@ -469,18 +486,10 @@ nsViewManager::UpdateWidgetArea(nsView *aWidgetView, nsIWidget* aWidget,
|
||||
if (!IsRefreshEnabled()) {
|
||||
// accumulate this rectangle in the view's dirty region, so we can
|
||||
// process it later.
|
||||
nsRegion* dirtyRegion = aWidgetView->GetDirtyRegion();
|
||||
if (!dirtyRegion) return;
|
||||
|
||||
dirtyRegion->Or(*dirtyRegion, aDamagedRegion);
|
||||
// Don't let dirtyRegion grow beyond 8 rects
|
||||
dirtyRegion->SimplifyOutward(8);
|
||||
AddDirtyRegion(aWidgetView, aDamagedRegion);
|
||||
nsViewManager* rootVM = RootViewManager();
|
||||
rootVM->mHasPendingUpdates = true;
|
||||
return;
|
||||
// this should only happen at the top level, and this result
|
||||
// should not be consumed by top-level callers, so it doesn't
|
||||
// really matter what we return
|
||||
}
|
||||
|
||||
// If the bounds don't overlap at all, there's nothing to do
|
||||
|
@ -151,6 +151,7 @@ private:
|
||||
|
||||
void FlushPendingInvalidates();
|
||||
void ProcessPendingUpdates(nsView *aView, bool aDoInvalidate);
|
||||
void FlushDirtyRegionToWidget(nsView* aView);
|
||||
/**
|
||||
* Call WillPaint() on all view observers under this vm root.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user