Bug 454959. When a document is in a floating view, floating-ness doesn't propagate across view manager boundaries. So use the display-root view as the place to invalidate from. r+sr=bzbarsky
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 26 Nov 2008 11:09:37 +1300
changeset 21941 48481020e51760ed772555471019bb1e72973279
parent 21940 59950d816bf5b11d2d3152e5233cd3794e8ab101
child 21942 feb0232b677168a8aad6cc73f360b765f5d0da45
push idunknown
push userunknown
push dateunknown
bugs454959
milestone1.9.1b3pre
Bug 454959. When a document is in a floating view, floating-ness doesn't propagate across view manager boundaries. So use the display-root view as the place to invalidate from. r+sr=bzbarsky
view/src/nsViewManager.cpp
view/src/nsViewManager.h
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -889,38 +889,22 @@ NS_IMETHODIMP nsViewManager::UpdateView(
    // can be expensive.
    // This also checks for silly request like damagedRect.width = 0 or damagedRect.height = 0
   nsRectVisibility rectVisibility;
   GetRectVisibility(view, damagedRect, 0, &rectVisibility);
   if (rectVisibility != nsRectVisibility_kVisible) {
     return NS_OK;
   }
 
-  // if this is a floating view, it isn't covered by any widgets other than
-  // its children. In that case we walk up to its parent widget and use
-  // that as the root to update from. This also means we update areas that
-  // may be outside the parent view(s), which is necessary for floats.
-  if (view->GetFloating()) {
-    nsView* widgetParent = view;
-
-    while (!widgetParent->HasWidget()) {
-      widgetParent->ConvertToParentCoords(&damagedRect.x, &damagedRect.y);
-      widgetParent = widgetParent->GetParent();
-    }
-
-    UpdateWidgetArea(widgetParent, nsRegion(damagedRect), nsnull);
-  } else {
-    // Propagate the update to the root widget of the root view manager, since
-    // iframes, for example, can overlap each other and be translucent.  So we
-    // have to possibly invalidate our rect in each of the widgets we have
-    // lying about.
-    damagedRect.MoveBy(ComputeViewOffset(view));
-
-    UpdateWidgetArea(RootViewManager()->GetRootView(), nsRegion(damagedRect), nsnull);
-  }
+  nsView* displayRoot = GetDisplayRootFor(view);
+  // Propagate the update to the displayRoot, since iframes, for example,
+  // can overlap each other and be translucent.  So we have to possibly
+  // invalidate our rect in each of the widgets we have lying about.
+  damagedRect.MoveBy(view->GetOffsetTo(displayRoot));
+  UpdateWidgetArea(displayRoot, nsRegion(damagedRect), nsnull);
 
   RootViewManager()->IncrementUpdateCount();
 
   if (!IsRefreshEnabled()) {
     return NS_OK;
   }
 
   // See if we should do an immediate refresh or wait
@@ -2024,39 +2008,16 @@ NS_IMETHODIMP nsViewManager::ForceUpdate
   // Walk the view tree looking for widgets, and call Update() on each one
   if (mRootView) {
     UpdateWidgetsForView(mRootView);
   }
   
   return NS_OK;
 }
 
-nsPoint nsViewManager::ComputeViewOffset(const nsView *aView)
-{
-  NS_PRECONDITION(aView, "Null view in ComputeViewOffset?");
-  
-  nsPoint origin(0, 0);
-#ifdef DEBUG
-  const nsView* rootView;
-  const nsView* origView = aView;
-#endif
-
-  while (aView) {
-#ifdef DEBUG
-    rootView = aView;
-#endif
-    origin += aView->GetPosition();
-    aView = aView->GetParent();
-  }
-  NS_ASSERTION(rootView ==
-               origView->GetViewManager()->RootViewManager()->GetRootView(),
-               "Unexpected root view");
-  return origin;
-}
-
 void nsViewManager::ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const
 {
   while (aView != aWidgetView) {
     aView->ConvertToParentCoords(&aRect.x, &aRect.y);
     aView = aView->GetParent();
   }
   
   // intersect aRect with bounds of aWidgetView, to prevent generating any illegal rectangles.
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -411,21 +411,16 @@ public: // NOT in nsIViewManager, so pri
    * Asks whether we can scroll a view using bitblt. If we say 'yes', we
    * return in aUpdateRegion an area that must be updated (relative to aView
    * after it has been scrolled).
    */
   PRBool CanScrollWithBitBlt(nsView* aView, nsPoint aDelta, nsRegion* aUpdateRegion);
 
   nsresult CreateRegion(nsIRegion* *result);
 
-  // return the sum of all view offsets from aView right up to the
-  // root of this view hierarchy (the view with no parent, which might
-  // not be in this view manager).
-  static nsPoint ComputeViewOffset(const nsView *aView);
-
   PRBool IsRefreshEnabled() { return RootViewManager()->mRefreshEnabled; }
 
   nsIViewObserver* GetViewObserver() { return mObserver; }
 
   // Call this when you need to let the viewmanager know that it now has
   // pending updates.
   void PostPendingUpdate() { RootViewManager()->mHasPendingUpdates = PR_TRUE; }
 private: