diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 9846b98fb2e3..422359d4ce90 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1888,14 +1888,19 @@ DocumentViewerImpl::SetBounds(const nsIntRect& aBounds) // window frame. // Don't have the widget repaint. Layout will generate repaint requests // during reflow. - if (mAttachedToParent) - mWindow->ResizeClient(aBounds.x, aBounds.y, - aBounds.width, aBounds.height, - false); - else + if (mAttachedToParent) { + if (aBounds.x != 0 || aBounds.y != 0) { + mWindow->ResizeClient(aBounds.x, aBounds.y, + aBounds.width, aBounds.height, + false); + } else { + mWindow->ResizeClient(aBounds.width, aBounds.height, false); + } + } else { mWindow->Resize(aBounds.x, aBounds.y, aBounds.width, aBounds.height, false); + } } else if (mPresContext && mViewManager) { PRInt32 p2a = mPresContext->AppUnitsPerDevPixel(); mViewManager->SetWindowDimensions(NSIntPixelsToAppUnits(mBounds.width, p2a), diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index a41e809388ab..c43411b87a55 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -118,8 +118,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event); #endif #define NS_IWIDGET_IID \ - { 0x34460b01, 0x3dc2, 0x4b58, \ - { 0x8e, 0xd3, 0x7e, 0x7c, 0x33, 0xb5, 0x78, 0x8b } } + { 0x41fc0f2c, 0x65c2, 0x418e, \ + { 0x89, 0x91, 0x5f, 0x0c, 0xa7, 0x01, 0x05, 0x34 } } /* * Window shadow styles * Also used for the -moz-window-shadow CSS property @@ -672,6 +672,21 @@ class nsIWidget : public nsISupports { **/ NS_IMETHOD Move(PRInt32 aX, PRInt32 aY) = 0; + /** + * Reposition this widget so that the client area has the given offset. + * + * @param aX the new x offset of the client area expressed as an + * offset from the origin of the client area of the parent + * widget (for root widgets and popup widgets it is in + * screen coordinates) + * @param aY the new y offset of the client area expressed as an + * offset from the origin of the client area of the parent + * widget (for root widgets and popup widgets it is in + * screen coordinates) + * + **/ + NS_IMETHOD MoveClient(PRInt32 aX, PRInt32 aY) = 0; + /** * Resize this widget. * @@ -701,10 +716,29 @@ class nsIWidget : public nsISupports { bool aRepaint) = 0; /** - * Resize and reposition the inner client area of the widget. + * Resize the widget so that the inner client area has the given size. * - * @param aX the new x offset expressed in the parent's coordinate system - * @param aY the new y offset expressed in the parent's coordinate system + * @param aWidth the new width of the client area. + * @param aHeight the new height of the client area. + * @param aRepaint whether the widget should be repainted + * + */ + NS_IMETHOD ResizeClient(PRInt32 aWidth, + PRInt32 aHeight, + bool aRepaint) = 0; + + /** + * Resize and reposition the widget so tht inner client area has the given + * offset and size. + * + * @param aX the new x offset of the client area expressed as an + * offset from the origin of the client area of the parent + * widget (for root widgets and popup widgets it is in + * screen coordinates) + * @param aY the new y offset of the client area expressed as an + * offset from the origin of the client area of the parent + * widget (for root widgets and popup widgets it is in + * screen coordinates) * @param aWidth the new width of the client area. * @param aHeight the new height of the client area. * @param aRepaint whether the widget should be repainted diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 6f2cca68b444..70843729915a 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -1523,30 +1523,6 @@ NS_METHOD nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeig return NS_OK; } -// Resize the client area and position the widget within it's parent -NS_METHOD nsWindow::ResizeClient(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, bool aRepaint) -{ - NS_ASSERTION((aWidth >=0) , "Negative width passed to ResizeClient"); - NS_ASSERTION((aHeight >=0), "Negative height passed to ResizeClient"); - - // Adjust our existing window bounds, based on the new client dims. - RECT client; - GetClientRect(mWnd, &client); - nsIntPoint dims(client.right - client.left, client.bottom - client.top); - aWidth = mBounds.width + (aWidth - dims.x); - aHeight = mBounds.height + (aHeight - dims.y); - - if (aX || aY) { - // offsets - nsIntRect bounds; - GetScreenBounds(bounds); - aX += bounds.x; - aY += bounds.y; - return Resize(aX, aY, aWidth, aHeight, aRepaint); - } - return Resize(aWidth, aHeight, aRepaint); -} - NS_IMETHODIMP nsWindow::BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical) { diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index d01a9574d738..5eaedd559919 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -125,7 +125,6 @@ public: NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, bool aRepaint); NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, bool aRepaint); - NS_IMETHOD ResizeClient(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, bool aRepaint); NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical); NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate); NS_IMETHOD SetSizeMode(PRInt32 aMode); diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 55d00db9dc27..de614b1e5d5f 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -300,15 +300,6 @@ NS_IMETHODIMP nsBaseWidget::SetAttachedViewPtr(ViewWrapper* aViewWrapper) return NS_OK; } -NS_METHOD nsBaseWidget::ResizeClient(PRInt32 aX, - PRInt32 aY, - PRInt32 aWidth, - PRInt32 aHeight, - bool aRepaint) -{ - return Resize(aX, aY, aWidth, aHeight, aRepaint); -} - //------------------------------------------------------------------------- // // Close this nsBaseWidget @@ -919,6 +910,50 @@ NS_METHOD nsBaseWidget::SetWindowClass(const nsAString& xulWinType) return NS_ERROR_NOT_IMPLEMENTED; } +NS_METHOD nsBaseWidget::MoveClient(PRInt32 aX, PRInt32 aY) +{ + nsIntPoint clientOffset(GetClientOffset()); + aX -= clientOffset.x; + aY -= clientOffset.y; + return Move(aX, aY); +} + +NS_METHOD nsBaseWidget::ResizeClient(PRInt32 aWidth, + PRInt32 aHeight, + bool aRepaint) +{ + NS_ASSERTION((aWidth >=0) , "Negative width passed to ResizeClient"); + NS_ASSERTION((aHeight >=0), "Negative height passed to ResizeClient"); + + nsIntRect clientBounds; + GetClientBounds(clientBounds); + aWidth = mBounds.width + (aWidth - clientBounds.width); + aHeight = mBounds.height + (aHeight - clientBounds.height); + + return Resize(aWidth, aHeight, aRepaint); +} + +NS_METHOD nsBaseWidget::ResizeClient(PRInt32 aX, + PRInt32 aY, + PRInt32 aWidth, + PRInt32 aHeight, + bool aRepaint) +{ + NS_ASSERTION((aWidth >=0) , "Negative width passed to ResizeClient"); + NS_ASSERTION((aHeight >=0), "Negative height passed to ResizeClient"); + + nsIntRect clientBounds; + GetClientBounds(clientBounds); + aWidth = mBounds.width + (aWidth - clientBounds.width); + aHeight = mBounds.height + (aHeight - clientBounds.height); + + nsIntPoint clientOffset(GetClientOffset()); + aX -= clientOffset.x; + aY -= clientOffset.y; + + return Resize(aX, aY, aWidth, aHeight, aRepaint); +} + //------------------------------------------------------------------------- // // Bounds diff --git a/widget/src/xpwidgets/nsBaseWidget.h b/widget/src/xpwidgets/nsBaseWidget.h index bc5f41ad3d26..d663885ee161 100644 --- a/widget/src/xpwidgets/nsBaseWidget.h +++ b/widget/src/xpwidgets/nsBaseWidget.h @@ -122,10 +122,15 @@ public: virtual gfxASurface* GetThebesSurface(); NS_IMETHOD SetModal(bool aModal); NS_IMETHOD SetWindowClass(const nsAString& xulWinType); + NS_IMETHOD MoveClient(PRInt32 aX, PRInt32 aY); + NS_IMETHOD ResizeClient(PRInt32 aWidth, PRInt32 aHeight, bool aRepaint); + NS_IMETHOD ResizeClient(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, bool aRepaint); NS_IMETHOD SetBounds(const nsIntRect &aRect); NS_IMETHOD GetBounds(nsIntRect &aRect); NS_IMETHOD GetClientBounds(nsIntRect &aRect); NS_IMETHOD GetScreenBounds(nsIntRect &aRect); + NS_IMETHOD GetNonClientMargins(nsIntMargin &margins); + NS_IMETHOD SetNonClientMargins(nsIntMargin &margins); virtual nsIntPoint GetClientOffset(); NS_IMETHOD EnableDragDrop(bool aEnable); NS_IMETHOD GetAttention(PRInt32 aCycleCount); @@ -163,9 +168,6 @@ public: NS_IMETHOD AttachViewToTopLevel(EVENT_CALLBACK aViewEventFunction, nsDeviceContext *aContext); virtual ViewWrapper* GetAttachedViewPtr(); NS_IMETHOD SetAttachedViewPtr(ViewWrapper* aViewWrapper); - NS_IMETHOD ResizeClient(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, bool aRepaint); - NS_IMETHOD GetNonClientMargins(nsIntMargin &margins); - NS_IMETHOD SetNonClientMargins(nsIntMargin &margins); NS_IMETHOD RegisterTouchWindow(); NS_IMETHOD UnregisterTouchWindow();