зеркало из https://github.com/mozilla/pjs.git
defer showing/hiding widgets when view manager is batching updates to suppress invalidates bug=141901 a=asa r=roc+moz sr=kin
This commit is contained in:
Родитель
c228eb5ee9
Коммит
9282e7cd01
|
@ -539,7 +539,6 @@ NS_IMETHODIMP nsView::GetBounds(nsRect &aBounds) const
|
|||
|
||||
NS_IMETHODIMP nsView::SetVisibility(nsViewVisibility aVisibility)
|
||||
{
|
||||
|
||||
mVis = aVisibility;
|
||||
|
||||
if (aVisibility == nsViewVisibility_kHide)
|
||||
|
@ -547,7 +546,10 @@ NS_IMETHODIMP nsView::SetVisibility(nsViewVisibility aVisibility)
|
|||
DropMouseGrabbing();
|
||||
}
|
||||
|
||||
if (nsnull != mWindow)
|
||||
// Don't show or hide the widget if the view manager is batching
|
||||
// updates. Showing/Hiding the view's widget will cause widget's to
|
||||
// be invalidated. When batching all invalidates must be deferred.
|
||||
if ((nsnull != mWindow) && (! mViewManager->IsBatchingUpdates()))
|
||||
{
|
||||
#ifndef HIDE_ALL_WIDGETS
|
||||
if (mVis == nsViewVisibility_kShow)
|
||||
|
|
|
@ -1545,14 +1545,27 @@ void nsViewManager::ProcessPendingUpdates(nsView* aView)
|
|||
if (nsnull == aView) {
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool hasWidget;
|
||||
aView->HasWidget(&hasWidget);
|
||||
if (hasWidget) {
|
||||
// Check to see if the visibility matches between the view and widget.
|
||||
// If they dont match then showing/hiding the widget was deferred.
|
||||
nsViewVisibility viewVisibility = aView->GetVisibility();
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
aView->GetWidget(*getter_AddRefs(widget));
|
||||
if (widget) {
|
||||
PRBool widgetVisibility;
|
||||
widget->IsVisible(widgetVisibility);
|
||||
if (((viewVisibility == nsViewVisibility_kShow) != widgetVisibility)) {
|
||||
// Process the deferred show/hide of the view's widget
|
||||
widget->Show(viewVisibility == nsViewVisibility_kShow);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRegion> dirtyRegion;
|
||||
aView->GetDirtyRegion(*getter_AddRefs(dirtyRegion));
|
||||
if (dirtyRegion != nsnull && !dirtyRegion->IsEmpty()) {
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
aView->GetWidget(*getter_AddRefs(widget));
|
||||
if (widget) {
|
||||
widget->InvalidateRegion(dirtyRegion, PR_FALSE);
|
||||
}
|
||||
|
@ -1655,16 +1668,6 @@ PRBool nsViewManager::UpdateWidgetArea(nsView *aWidgetView, const nsRect &aDamag
|
|||
nsViewVisibility visible;
|
||||
aWidgetView->GetVisibility(visible);
|
||||
if (nsViewVisibility_kHide == visible) {
|
||||
#ifdef DEBUG
|
||||
// Assert if view is hidden but widget is visible
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
GetWidgetForView(aWidgetView, getter_AddRefs(widget));
|
||||
if (widget) {
|
||||
PRBool visible;
|
||||
widget->IsVisible(visible);
|
||||
NS_ASSERTION(!visible, "View is hidden but widget is visible!");
|
||||
}
|
||||
#endif
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -3315,6 +3318,12 @@ NS_IMETHODIMP nsViewManager::EnableRefresh(PRUint32 aUpdateFlags)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsViewManager::IsBatchingUpdates(void)
|
||||
{
|
||||
return mUpdateBatchCnt > 0;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsViewManager::BeginUpdateViewBatch(void)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
|
|
@ -235,6 +235,11 @@ public:
|
|||
PRUint16 aMinTwips,
|
||||
nsRectVisibility *aRectVisibility);
|
||||
|
||||
/* Determine if invalidates are being batched through the use
|
||||
* of BeginUpdateViewBatch
|
||||
* @returns PR_TRUE if current batching updates, PR_FALSE otherwise
|
||||
*/
|
||||
PRBool IsBatchingUpdates(void);
|
||||
protected:
|
||||
virtual ~nsViewManager();
|
||||
void ProcessPendingUpdates(nsView *aView);
|
||||
|
|
Загрузка…
Ссылка в новой задаче