Bug 668437. Part 3. Make the client bounds of a widget be relative to its parent in all cases. r=jimm
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 01 Dec 2011 13:56:42 -0600
changeset 81907 70bc06b28e600ccb5bfdddecaadd4539d79999fa
parent 81906 42ded0d67419334075c4033233329e0fca6fbc8e
child 81908 a5e487e8270228abb31b838ca099736afa54bf3e
push idunknown
push userunknown
push dateunknown
reviewersjimm
bugs668437
milestone11.0a1
Bug 668437. Part 3. Make the client bounds of a widget be relative to its parent in all cases. r=jimm
dom/base/nsDOMWindowUtils.cpp
widget/public/nsIWidget.h
widget/src/os2/nsWindow.cpp
widget/src/windows/nsTextStore.cpp
widget/src/windows/nsWindow.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1322,16 +1322,17 @@ nsDOMWindowUtils::SendQueryContentEvent(
     nsQueryContentEvent dummyEvent(true, NS_QUERY_CONTENT_STATE, widget);
     InitEvent(dummyEvent, &pt);
     nsIFrame* popupFrame =
       nsLayoutUtils::GetPopupFrameForEventCoordinates(presContext->GetRootPresContext(), &dummyEvent);
 
     nsIntRect widgetBounds;
     nsresult rv = widget->GetClientBounds(widgetBounds);
     NS_ENSURE_SUCCESS(rv, rv);
+    widgetBounds.MoveTo(0, 0);
 
     // There is no popup frame at the point and the point isn't in our widget,
     // we cannot process this request.
     NS_ENSURE_TRUE(popupFrame || widgetBounds.Contains(pt),
                    NS_ERROR_FAILURE);
 
     // Fire the event on the widget at the point
     if (popupFrame) {
--- a/widget/public/nsIWidget.h
+++ b/widget/public/nsIWidget.h
@@ -794,19 +794,20 @@ class nsIWidget : public nsISupports {
      * includes any title bar on the window.
      *
      * @param aRect   On return it holds the  x, y, width and height of
      *                this widget.
      */
     NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0;
 
     /**
-     * Get this widget's client area dimensions, if the window has a 3D
-     * border appearance this returns the area inside the border. Origin
-     * is always zero.
+     * Get this widget's client area bounds, if the window has a 3D border
+     * appearance this returns the area inside the border. The position is the
+     * position of the client area relative to the client area of the parent
+     * widget (for root widgets and popup widgets it is in screen coordinates).
      *
      * @param aRect   On return it holds the  x. y, width and height of
      *                the client area of this widget.
      */
     NS_IMETHOD GetClientBounds(nsIntRect &aRect) = 0;
 
     /**
      * Get the non-client area dimensions of the window.
--- a/widget/src/os2/nsWindow.cpp
+++ b/widget/src/os2/nsWindow.cpp
@@ -764,20 +764,17 @@ NS_METHOD nsWindow::GetBounds(nsIntRect&
 }
 
 //-----------------------------------------------------------------------------
 // Since mBounds contains the dimensions of the client, os2FrameWindow
 // doesn't have to provide any special handling for this method.
 
 NS_METHOD nsWindow::GetClientBounds(nsIntRect& aRect)
 {
-  aRect.x = 0;
-  aRect.y = 0;
-  aRect.width = mBounds.width;
-  aRect.height = mBounds.height;
+  aRect = mBounds;
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 
 nsIntPoint nsWindow::WidgetToScreenOffset()
 {
   POINTL point = { 0, 0 };
--- a/widget/src/windows/nsTextStore.cpp
+++ b/widget/src/windows/nsTextStore.cpp
@@ -1180,16 +1180,18 @@ nsTextStore::GetScreenExt(TsViewCookie v
   // Result rect is in top level widget coordinates
   refWindow = refWindow->GetTopLevelWindow(false);
   NS_ENSURE_TRUE(refWindow, E_FAIL);
 
   nsIntRect boundRect;
   nsresult rv = refWindow->GetClientBounds(boundRect);
   NS_ENSURE_SUCCESS(rv, E_FAIL);
 
+  boundRect.MoveTo(0, 0);
+
   // Clip frame rect to window rect
   boundRect.IntersectRect(event.mReply.mRect, boundRect);
   if (!boundRect.IsEmpty()) {
     boundRect.MoveBy(refWindow->WidgetToScreenOffset());
     ::SetRect(prc, boundRect.x, boundRect.y,
               boundRect.XMost(), boundRect.YMost());
   } else {
     ::SetRectEmpty(prc);
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -1925,19 +1925,19 @@ NS_METHOD nsWindow::GetBounds(nsIntRect 
 
 // Get this component dimension
 NS_METHOD nsWindow::GetClientBounds(nsIntRect &aRect)
 {
   if (mWnd) {
     RECT r;
     VERIFY(::GetClientRect(mWnd, &r));
 
-    // assign size
-    aRect.x = 0;
-    aRect.y = 0;
+    nsIntRect bounds;
+    GetBounds(bounds);
+    aRect.MoveTo(bounds.TopLeft() + GetClientOffset());
     aRect.width  = r.right - r.left;
     aRect.height = r.bottom - r.top;
 
   } else {
     aRect.SetRect(0,0,0,0);
   }
   return NS_OK;
 }