Bug 748048 - Part 1: Remove SetInvalidationDimensions and GetInvalidationDimensions. r=roc
authorAli Juma <ajuma@mozilla.com>
Thu, 03 May 2012 12:33:51 -0400
changeset 92899 3e391f4c1bcbc8691a3a9f68ff15d90d1091bb59
parent 92898 82fad02b755a613ce6733d408b97187afd00a3ab
child 92900 5be71aa88a163df3f3de490d737dec12562a3b34
push id22600
push userajuma@mozilla.com
push dateThu, 03 May 2012 16:34:30 +0000
treeherdermozilla-central@5be71aa88a16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs748048
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 748048 - Part 1: Remove SetInvalidationDimensions and GetInvalidationDimensions. r=roc
dom/base/nsDOMWindowUtils.cpp
layout/generic/nsFrame.cpp
view/public/nsIView.h
view/src/nsView.cpp
view/src/nsView.h
view/src/nsViewManager.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -326,29 +326,16 @@ nsDOMWindowUtils::SetDisplayPortForEleme
                        DestroyNsRect);
 
   nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
   if (rootScrollFrame) {
     if (content == rootScrollFrame->GetContent()) {
       // We are setting a root displayport for a document.
       // The pres shell needs a special flag set.
       presShell->SetIgnoreViewportScrolling(true);
-
-      // The root document currently has a widget, but we might end up
-      // painting content inside the displayport but outside the widget
-      // bounds. This ensures the document's view honors invalidations
-      // within the displayport.
-      nsPresContext* presContext = GetPresContext();
-      if (presContext && presContext->IsRoot()) {
-        nsIFrame* rootFrame = presShell->GetRootFrame();
-        nsIView* view = rootFrame->GetView();
-        if (view) {
-          view->SetInvalidationDimensions(&displayport);
-        }
-      }
     }
   }
 
   if (presShell) {
     nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
     if (rootFrame) {
       nsIContent* rootContent =
         rootScrollFrame ? rootScrollFrame->GetContent() : nsnull;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -4548,16 +4548,20 @@ nsIFrame::InvalidateWithFlags(const nsRe
  * @param aY The y offset from the origin of this frame to the rectangle.
  * @param aImmediate Whether to redraw immediately.
  * @return None, though this funnels the request up to the parent frame.
  */
 void
 nsIFrame::InvalidateInternalAfterResize(const nsRect& aDamageRect, nscoord aX,
                                         nscoord aY, PRUint32 aFlags)
 {
+  if (aDamageRect.IsEmpty()) {
+    return;
+  }
+
   /* If we're a transformed frame, then we need to apply our transform to the
    * damage rectangle so that the redraw correctly redraws the transformed
    * region.  We're moved over aX and aY from our origin, but since this aX
    * and aY is contained within our border, we need to scoot back by -aX and
    * -aY to get back to the origin of the transform.
    *
    * There's one more problem, though, and that's that we don't know what
    * coordinate space this rectangle is in.  Sometimes it's in the local
--- a/view/public/nsIView.h
+++ b/view/public/nsIView.h
@@ -58,18 +58,18 @@ class nsIWidget;
 // show - the layer is shown irrespective of the visibility of 
 //        the layer's parent.
 enum nsViewVisibility {
   nsViewVisibility_kHide = 0,
   nsViewVisibility_kShow = 1
 };
 
 #define NS_IVIEW_IID    \
-  { 0xda62efbf, 0x0711, 0x4b79, \
-    { 0x87, 0x85, 0x9e, 0xec, 0xed, 0xf5, 0xb0, 0x32 } }
+  { 0x697948d2, 0x3f10, 0x407d, \
+    { 0xb8, 0x94, 0x9f, 0x36, 0xd2, 0x11, 0xdb, 0xf1 } }
 
 // Public view flags
 
 // Indicates that the view is using auto z-indexing
 #define NS_VIEW_FLAG_AUTO_ZINDEX          0x0004
 
 // Indicates that the view is a floating view.
 #define NS_VIEW_FLAG_FLOATING             0x0008
@@ -163,27 +163,16 @@ public:
    * The bounds of this view relative to this view. So this is the same as
    * GetBounds except this is relative to this view instead of the parent view.
    */
   nsRect GetDimensions() const {
     nsRect r = mDimBounds; r.MoveBy(-mPosX, -mPosY); return r;
   }
 
   /**
-   * Set the dimensions at which invalidations are clipped, which can
-   * be different than |GetDimensions()|.  |aRect| is relative to
-   * |this|.  It can be null, in which case invalidations return to
-   * being clipped to the view dimensions.
-   *
-   * The caller is responsible for invalidating the area that may lie
-   * outside the view dimensions but inside |aRect| after this call.
-   */
-  void SetInvalidationDimensions(const nsRect* aRect);
-
-  /**
    * Get the offset between the coordinate systems of |this| and aOther.
    * Adding the return value to a point in the coordinate system of |this|
    * will transform the point to the coordinate system of aOther.
    *
    * The offset is expressed in appunits of |this|. So if you are getting the
    * offset between views in different documents that might have different
    * appunits per devpixel ratios you need to be careful how you use the
    * result.
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -201,17 +201,16 @@ nsView::nsView(nsViewManager* aViewManag
   // Views should be transparent by default. Not being transparent is
   // a promise that the view will paint all its pixels opaquely. Views
   // should make this promise explicitly by calling
   // SetViewContentTransparency.
   mVFlags = 0;
   mViewManager = aViewManager;
   mDirtyRegion = nsnull;
   mDeletionObserver = nsnull;
-  mHaveInvalidationDimensions = false;
   mWidgetIsTopLevel = false;
 }
 
 void nsView::DropMouseGrabbing()
 {
   nsIPresShell* presShell = mViewManager->GetPresShell();
   if (presShell)
     presShell->ClearMouseCaptureOnView(this);
@@ -350,21 +349,16 @@ void nsView::SetPosition(nscoord aX, nsc
   mPosY = aY;
 
   NS_ASSERTION(GetParent() || (aX == 0 && aY == 0),
                "Don't try to move the root widget to something non-zero");
 
   ResetWidgetBounds(true, false);
 }
 
-void nsIView::SetInvalidationDimensions(const nsRect* aRect)
-{
-  return Impl()->SetInvalidationDimensions(aRect);
-}
-
 void nsView::ResetWidgetBounds(bool aRecurse, bool aForceSync)
 {
   if (mWindow) {
     if (!aForceSync) {
       // Don't change widget geometry synchronously, since that can
       // cause synchronous painting.
       mViewManager->PostPendingUpdate();
     } else {
@@ -493,23 +487,16 @@ void nsView::SetDimensions(const nsRect&
 
   mDimBounds = dims;
 
   if (aResizeWidget) {
     ResetWidgetBounds(false, false);
   }
 }
 
-void nsView::SetInvalidationDimensions(const nsRect* aRect)
-{
-  if ((mHaveInvalidationDimensions = !!aRect)) {
-    mInvalidationDimensions = *aRect;
-  }
-}
-
 void nsView::NotifyEffectiveVisibilityChanged(bool aEffectivelyVisible)
 {
   if (!aEffectivelyVisible)
   {
     DropMouseGrabbing();
   }
 
   if (nsnull != mWindow)
--- a/view/src/nsView.h
+++ b/view/src/nsView.h
@@ -71,17 +71,16 @@ public:
   /**
    * Called to indicate that the dimensions of the view have been changed.
    * The x and y coordinates may be < 0, indicating that the view extends above
    * or to the left of its origin position. The term 'dimensions' indicates it
    * is relative to this view.
    */
   virtual void SetDimensions(const nsRect &aRect, bool aPaint = true,
                              bool aResizeWidget = true);
-  void SetInvalidationDimensions(const nsRect* aRect);
 
   /**
    * Called to indicate that the visibility of a view has been
    * changed.
    * @param visibility new visibility state
    */
   NS_IMETHOD  SetVisibility(nsViewVisibility visibility);
 
@@ -144,20 +143,16 @@ public:
   nsView* GetParent() const { return mParent; }
   nsViewManager* GetViewManager() const { return mViewManager; }
   // These are superseded by a better interface in nsIView
   PRInt32 GetZIndex() const { return mZIndex; }
   bool GetZIndexIsAuto() const { return (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0; }
   // Same as GetBounds but converts to parent appunits if they are different.
   nsRect GetBoundsInParentUnits() const;
 
-  nsRect GetInvalidationDimensions() const {
-    return mHaveInvalidationDimensions ? mInvalidationDimensions : GetDimensions();
-  }
-
   // These are defined exactly the same in nsIView, but for now they have to be redeclared
   // here because of stupid C++ method hiding rules
 
   bool HasNonEmptyDirtyRegion() {
     return mDirtyRegion && !mDirtyRegion->IsEmpty();
   }
   nsRegion* GetDirtyRegion() {
     if (!mDirtyRegion) {
@@ -200,21 +195,14 @@ public:
   nsIWidget* GetNearestWidget(nsPoint* aOffset, const PRInt32 aAPD) const;
 
 protected:
   // Do the actual work of ResetWidgetBounds, unconditionally.  Don't
   // call this method if we have no widget.
   void DoResetWidgetBounds(bool aMoveOnly, bool aInvalidateChangedSize);
 
   nsRegion*    mDirtyRegion;
-  // invalidations are clipped to mInvalidationDimensions, not
-  // GetDimensions(), when mHaveInvalidationDimensions is true.  This
-  // is used to support persistent "displayport" rendering; see
-  // nsPresShell.cpp.  The coordinates of mInvalidationDimensions are
-  // relative to |this|.
-  nsRect       mInvalidationDimensions;
-  bool mHaveInvalidationDimensions;
 
 private:
   void InitializeWindow(bool aEnableDragDrop, bool aResetVisibility);
 };
 
 #endif
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -474,23 +474,16 @@ nsViewManager::InvalidateWidgetArea(nsVi
 
 #if 0
   nsRect dbgBounds = aDamagedRegion.GetBounds();
   printf("InvalidateWidgetArea view:%X (%d) widget:%X region: %d, %d, %d, %d\n",
     aWidgetView, aWidgetView->IsAttachedToTopLevel(),
     widget, dbgBounds.x, dbgBounds.y, dbgBounds.width, dbgBounds.height);
 #endif
 
-  // If the bounds don't overlap at all, there's nothing to do
-  nsRegion intersection;
-  intersection.And(aWidgetView->GetInvalidationDimensions(), aDamagedRegion);
-  if (intersection.IsEmpty()) {
-    return;
-  }
-
   // If the widget is hidden, it don't cover nothing
   if (widget) {
     bool visible;
     widget->IsVisible(visible);
     if (!visible)
       return;
   }
 
@@ -537,17 +530,17 @@ nsViewManager::InvalidateWidgetArea(nsVi
           children.SimplifyInward(20);
         }
 #endif
       }
     }
   }
 
   nsRegion leftOver;
-  leftOver.Sub(intersection, children);
+  leftOver.Sub(aDamagedRegion, children);
 
   if (!leftOver.IsEmpty()) {
     const nsRect* r;
     for (nsRegionRectIterator iter(leftOver); (r = iter.Next());) {
       nsIntRect bounds = ViewToWidget(aWidgetView, *r);
       widget->Invalidate(bounds);
     }
   }
@@ -1315,23 +1308,18 @@ NS_IMETHODIMP nsViewManager::GetRootWidg
   *aWidget = nsnull;
   return NS_OK;
 }
 
 nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const
 {
   NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
 
-  // intersect aRect with bounds of aView, to prevent generating any illegal rectangles.
-  nsRect bounds = aView->GetInvalidationDimensions();
-  nsRect rect;
-  rect.IntersectRect(aRect, bounds);
-
   // account for the view's origin not lining up with the widget's
-  rect += aView->ViewToWidgetOffset();
+  nsRect rect = aRect + aView->ViewToWidgetOffset();
 
   // finally, convert to device coordinates.
   return rect.ToOutsidePixels(AppUnitsPerDevPixel());
 }
 
 NS_IMETHODIMP
 nsViewManager::IsPainting(bool& aIsPainting)
 {