From 9b26154c74990e2ed055ad2d16483ac3a2d2cb1b Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Thu, 1 Dec 2011 15:43:07 -0500 Subject: [PATCH] Backed out changeset 5d920a44a901 (bug 698002) --- accessible/src/base/nsRootAccessible.cpp | 25 ++++---- dom/base/nsDOMWindowUtils.cpp | 1 - dom/base/nsGlobalWindow.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 15 ++--- layout/xul/base/src/nsMenuPopupFrame.cpp | 42 ++++++++----- layout/xul/base/src/nsMenuPopupFrame.h | 9 +-- layout/xul/base/src/nsResizerFrame.cpp | 3 +- layout/xul/base/src/nsTitleBarFrame.cpp | 3 +- layout/xul/base/src/nsXULPopupManager.cpp | 13 ++-- view/src/nsView.cpp | 12 ++-- widget/public/nsIWidget.h | 51 +++------------- widget/src/gtk2/nsWindow.cpp | 74 +++++------------------ widget/src/gtk2/nsWindow.h | 2 - widget/src/os2/nsWindow.cpp | 5 +- widget/src/windows/nsTextStore.cpp | 2 - widget/src/windows/nsWindow.cpp | 30 ++++++++- widget/src/windows/nsWindow.h | 1 + widget/src/xpwidgets/nsBaseWidget.cpp | 53 +++------------- widget/src/xpwidgets/nsBaseWidget.h | 8 +-- 19 files changed, 128 insertions(+), 223 deletions(-) diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index 4a235a5c3d3a..d43216600260 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -396,21 +396,20 @@ nsRootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent) targetNode->AsElement()->NodeInfo()->Equals(nsGkAtoms::tree, kNameSpaceID_XUL)) { treeAcc = do_QueryObject(accessible); - if (treeAcc) { - if (eventType.EqualsLiteral("TreeViewChanged")) { - treeAcc->TreeViewChanged(); - return; - } - if (eventType.EqualsLiteral("TreeRowCountChanged")) { - HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc); - return; - } + if (eventType.EqualsLiteral("TreeViewChanged")) { + treeAcc->TreeViewChanged(); + return; + } - if (eventType.EqualsLiteral("TreeInvalidated")) { - HandleTreeInvalidatedEvent(aDOMEvent, treeAcc); - return; - } + if (eventType.EqualsLiteral("TreeRowCountChanged")) { + HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc); + return; + } + + if (eventType.EqualsLiteral("TreeInvalidated")) { + HandleTreeInvalidatedEvent(aDOMEvent, treeAcc); + return; } } #endif diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 5ae971245d3c..3d4a38f9d865 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1327,7 +1327,6 @@ nsDOMWindowUtils::SendQueryContentEvent(PRUint32 aType, 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. diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 52211ee25406..5771ec2ac87c 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -10324,7 +10324,7 @@ nsGlobalChromeWindow::BeginWindowMove(nsIDOMEvent *aMouseDownEvent, nsIDOMElemen nsIFrame* frame = panel->GetPrimaryFrame(); NS_ENSURE_TRUE(frame && frame->GetType() == nsGkAtoms::menuPopupFrame, NS_OK); - widget = (static_cast(frame))->GetWidget(); + (static_cast(frame))->GetWidget(getter_AddRefs(widget)); } else { #endif diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 422359d4ce90..9846b98fb2e3 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1888,19 +1888,14 @@ DocumentViewerImpl::SetBounds(const nsIntRect& aBounds) // window frame. // Don't have the widget repaint. Layout will generate repaint requests // during reflow. - 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 { + if (mAttachedToParent) + mWindow->ResizeClient(aBounds.x, aBounds.y, + 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/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 5a8c76e8bc5a..0bb7b73e93f0 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -115,7 +115,6 @@ nsMenuPopupFrame::nsMenuPopupFrame(nsIPresShell* aShell, nsStyleContext* aContex :nsBoxFrame(aShell, aContext), mCurrentMenu(nsnull), mPrefSize(-1, -1), - mLastClientOffset(0, 0), mPopupType(ePopupTypePanel), mPopupState(ePopupClosed), mPopupAlignment(POPUPALIGNMENT_NONE), @@ -487,6 +486,21 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, b nsRect rect = GetRect(); rect.x = rect.y = 0; + // Increase the popup's view size to account for any titlebar or borders. + // XXXndeakin this should really be accounted for earlier in + // SetPopupPosition so that this extra size is accounted for when flipping + // or resizing the popup due to it being too large, but that can be a + // followup bug. + if (mPopupType == ePopupTypePanel && view) { + nsIWidget* widget = view->GetWidget(); + if (widget) { + nsIntSize popupSize = nsIntSize(pc->AppUnitsToDevPixels(rect.width), + pc->AppUnitsToDevPixels(rect.height)); + popupSize = widget->ClientToWindowSize(popupSize); + rect.width = pc->DevPixelsToAppUnits(popupSize.width); + rect.height = pc->DevPixelsToAppUnits(popupSize.height); + } + } viewManager->ResizeView(view, rect); viewManager->SetViewVisibility(view, nsViewVisibility_kShow); @@ -1304,6 +1318,8 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove) nsIView* view = GetView(); NS_ASSERTION(view, "popup with no view"); + presContext->GetPresShell()->GetViewManager()-> + MoveViewTo(view, viewPoint.x, viewPoint.y); // Offset the position by the width and height of the borders and titlebar. // Even though GetClientOffset should return (0, 0) when there is no @@ -1311,14 +1327,11 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove) // to save time since they will never have a titlebar. nsIWidget* widget = view->GetWidget(); if (mPopupType == ePopupTypePanel && widget) { - mLastClientOffset = widget->GetClientOffset(); - viewPoint.x += presContext->DevPixelsToAppUnits(mLastClientOffset.x); - viewPoint.y += presContext->DevPixelsToAppUnits(mLastClientOffset.y); + nsIntPoint offset = widget->GetClientOffset(); + viewPoint.x += presContext->DevPixelsToAppUnits(offset.x); + viewPoint.y += presContext->DevPixelsToAppUnits(offset.y); } - presContext->GetPresShell()->GetViewManager()-> - MoveViewTo(view, viewPoint.x, viewPoint.y); - // Now that we've positioned the view, sync up the frame's origin. nsBoxFrame::SetPosition(viewPoint - GetParent()->GetOffsetTo(rootFrame)); @@ -1750,14 +1763,16 @@ nsMenuPopupFrame::LockMenuUntilClosed(bool aLock) } } -nsIWidget* -nsMenuPopupFrame::GetWidget() +NS_IMETHODIMP +nsMenuPopupFrame::GetWidget(nsIWidget **aWidget) { nsIView * view = GetRootViewForPopup(this); if (!view) - return nsnull; + return NS_OK; - return view->GetWidget(); + *aWidget = view->GetWidget(); + NS_IF_ADDREF(*aWidget); + return NS_OK; } void @@ -1856,11 +1871,8 @@ nsMenuPopupFrame::DestroyFrom(nsIFrame* aDestructRoot) void nsMenuPopupFrame::MoveTo(PRInt32 aLeft, PRInt32 aTop, bool aUpdateAttrs) { - nsIWidget* widget = GetWidget(); - if ((mScreenXPos == aLeft && mScreenYPos == aTop) && - (!widget || widget->GetClientOffset() == mLastClientOffset)) { + if (mScreenXPos == aLeft && mScreenYPos == aTop) return; - } // reposition the popup at the specified coordinates. Don't clear the anchor // and position, because the popup can be reset to its anchor position by diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index d788b7eb9688..ea8b35ef4b88 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -176,7 +176,7 @@ public: virtual void LockMenuUntilClosed(bool aLock); virtual bool IsMenuLocked() { return mIsMenuLocked; } - nsIWidget* GetWidget(); + NS_IMETHOD GetWidget(nsIWidget **aWidget); // The dismissal listener gets created and attached to the window. void AttachedDismissalListener(); @@ -352,9 +352,6 @@ public: NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists); - - nsIntPoint GetLastClientOffset() const { return mLastClientOffset; } - protected: // returns the popup's level. @@ -438,10 +435,6 @@ protected: PRInt32 mYPos; PRInt32 mScreenXPos; PRInt32 mScreenYPos; - // The value of the client offset of our widget the last time we positioned - // ourselves. We store this so that we can detect when it changes but the - // position of our widget didn't change. - nsIntPoint mLastClientOffset; nsPopupType mPopupType; // type of popup nsPopupState mPopupState; // open state of the popup diff --git a/layout/xul/base/src/nsResizerFrame.cpp b/layout/xul/base/src/nsResizerFrame.cpp index 9b84c3d07a43..06bc5ca94bac 100644 --- a/layout/xul/base/src/nsResizerFrame.cpp +++ b/layout/xul/base/src/nsResizerFrame.cpp @@ -259,7 +259,8 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext, nsIntRect oldRect; nsWeakFrame weakFrame(menuPopupFrame); if (menuPopupFrame) { - nsCOMPtr widget = menuPopupFrame->GetWidget(); + nsCOMPtr widget; + menuPopupFrame->GetWidget(getter_AddRefs(widget)); if (widget) widget->GetScreenBounds(oldRect); diff --git a/layout/xul/base/src/nsTitleBarFrame.cpp b/layout/xul/base/src/nsTitleBarFrame.cpp index badaa8f48cfb..259bee02e48d 100644 --- a/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/layout/xul/base/src/nsTitleBarFrame.cpp @@ -161,7 +161,8 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext, // move the widget associated with the window if (parent) { nsMenuPopupFrame* menuPopupFrame = static_cast(parent); - nsCOMPtr widget = menuPopupFrame->GetWidget(); + nsCOMPtr widget; + menuPopupFrame->GetWidget(getter_AddRefs(widget)); nsIntRect bounds; widget->GetScreenBounds(bounds); menuPopupFrame->MoveTo(bounds.x + nsMoveBy.x, bounds.y + nsMoveBy.y, false); diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index c25a7d928955..12cdc3122cf6 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -283,7 +283,8 @@ nsXULPopupManager::GetSubmenuWidgetChain(nsTArray *aWidgetChain) NS_ASSERTION(aWidgetChain, "null parameter"); nsMenuChainItem* item = GetTopVisibleMenu(); while (item) { - nsCOMPtr widget = item->Frame()->GetWidget(); + nsCOMPtr widget; + item->Frame()->GetWidget(getter_AddRefs(widget)); NS_ASSERTION(widget, "open popup has no widget"); aWidgetChain->AppendElement(widget.get()); // In the case when a menulist inside a panel is open, clicking in the @@ -358,9 +359,7 @@ nsXULPopupManager::PopupMoved(nsIFrame* aFrame, nsIntPoint aPnt) // Don't do anything if the popup is already at the specified location. This // prevents recursive calls when a popup is positioned. nsIntPoint currentPnt = menuPopupFrame->ScreenPosition(); - nsIWidget* widget = menuPopupFrame->GetWidget(); - if ((aPnt.x != currentPnt.x || aPnt.y != currentPnt.y) || (widget && - widget->GetClientOffset() != menuPopupFrame->GetLastClientOffset())) { + if (aPnt.x != currentPnt.x || aPnt.y != currentPnt.y) { // Update the popup's position using SetPopupPosition if the popup is // anchored and at the parent level as these maintain their position // relative to the parent window. Otherwise, just update the popup to @@ -1465,7 +1464,8 @@ nsXULPopupManager::MayShowPopup(nsMenuPopupFrame* aPopup) } // if the popup was just rolled up, don't reopen it - nsCOMPtr widget = aPopup->GetWidget(); + nsCOMPtr widget; + aPopup->GetWidget(getter_AddRefs(widget)); if (widget && widget->GetLastRollup() == aPopup->GetContent()) return false; @@ -1618,7 +1618,8 @@ nsXULPopupManager::SetCaptureState(nsIContent* aOldPopup) if (item) { nsMenuPopupFrame* popup = item->Frame(); - nsCOMPtr widget = popup->GetWidget(); + nsCOMPtr widget; + popup->GetWidget(getter_AddRefs(widget)); if (widget) { widget->CaptureRollupEvents(this, true, popup->ConsumeOutsideClicks()); mWidget = widget; diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 5f4c3cc772c4..e4121351ebaa 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -438,7 +438,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly, } nsIntRect curBounds; - mWindow->GetClientBounds(curBounds); + mWindow->GetBounds(curBounds); nsWindowType type; mWindow->GetWindowType(type); @@ -462,16 +462,14 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly, // Child views are never attached to top level widgets, this is safe. if (changedPos) { if (changedSize && !aMoveOnly) { - mWindow->ResizeClient(newBounds.x, newBounds.y, - newBounds.width, newBounds.height, - aInvalidateChangedSize); + mWindow->Resize(newBounds.x, newBounds.y, newBounds.width, newBounds.height, + aInvalidateChangedSize); } else { - mWindow->MoveClient(newBounds.x, newBounds.y); + mWindow->Move(newBounds.x, newBounds.y); } } else { if (changedSize && !aMoveOnly) { - mWindow->ResizeClient(newBounds.width, newBounds.height, - aInvalidateChangedSize); + mWindow->Resize(newBounds.width, newBounds.height, aInvalidateChangedSize); } // else do nothing! } } diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index c43411b87a55..eb85af4c7851 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 \ - { 0x41fc0f2c, 0x65c2, 0x418e, \ - { 0x89, 0x91, 0x5f, 0x0c, 0xa7, 0x01, 0x05, 0x34 } } + { 0x34460b01, 0x3dc2, 0x4b58, \ + { 0x8e, 0xd3, 0x7e, 0x7c, 0x33, 0xb5, 0x78, 0x8b } } /* * Window shadow styles * Also used for the -moz-window-shadow CSS property @@ -672,21 +672,6 @@ 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. * @@ -716,29 +701,10 @@ class nsIWidget : public nsISupports { bool aRepaint) = 0; /** - * Resize the widget so that the inner client area has the given size. + * Resize and reposition the inner client area of the widget. * - * @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 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 @@ -833,10 +799,9 @@ class nsIWidget : public nsISupports { NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0; /** - * 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). + * 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. * * @param aRect On return it holds the x. y, width and height of * the client area of this widget. diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index f0f322068605..d51de863e24e 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -1579,57 +1579,6 @@ nsWindow::GetScreenBounds(nsIntRect &aRect) return NS_OK; } -NS_IMETHODIMP -nsWindow::GetClientBounds(nsIntRect &aRect) -{ - // GetBounds returns a rect whose top left represents the top left of the - // outer bounds, but whose width/height represent the size of the inner - // bounds (which is messed up). - GetBounds(aRect); - aRect.MoveBy(GetClientOffset()); - - return NS_OK; -} - -nsIntPoint -nsWindow::GetClientOffset() -{ - if (!mIsTopLevel) { - return nsIntPoint(0, 0); - } - - GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL); - - GdkAtom type_returned; - int format_returned; - int length_returned; - long *frame_extents; - - if (!mShell || !mShell->window || - !gdk_property_get(mShell->window, - gdk_atom_intern ("_NET_FRAME_EXTENTS", FALSE), - cardinal_atom, - 0, // offset - 4*4, // length - FALSE, // delete - &type_returned, - &format_returned, - &length_returned, - (guchar **) &frame_extents) || - length_returned/sizeof(glong) != 4) { - - return nsIntPoint(0, 0); - } - - // data returned is in the order left, right, top, bottom - PRInt32 left = PRInt32(frame_extents[0]); - PRInt32 top = PRInt32(frame_extents[2]); - - g_free(frame_extents); - - return nsIntPoint(left, top); -} - NS_IMETHODIMP nsWindow::SetForegroundColor(const nscolor &aColor) { @@ -2390,16 +2339,17 @@ nsWindow::OnConfigureEvent(GtkWidget *aWidget, GdkEventConfigure *aEvent) LOG(("configure event [%p] %d %d %d %d\n", (void *)this, aEvent->x, aEvent->y, aEvent->width, aEvent->height)); - nsIntRect screenBounds; - GetScreenBounds(screenBounds); + // mBounds.x/y are set to the window manager frame top-left when Move() or + // Resize()d from within Gecko, so comparing with the client window + // top-left is weird. However, mBounds.x/y are set to client window + // position below, so this check avoids unwanted rollup on spurious + // configure events from Cygwin/X (bug 672103). + if (mBounds.x == aEvent->x && + mBounds.y == aEvent->y) + return FALSE; if (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog) { - // This check avoids unwanted rollup on spurious configure events from - // Cygwin/X (bug 672103). - if (mBounds.x != screenBounds.x || - mBounds.y != screenBounds.y) { - check_for_rollup(aEvent->window, 0, 0, false, true); - } + check_for_rollup(aEvent->window, 0, 0, false, true); } // This event indicates that the window position may have changed. @@ -2427,7 +2377,11 @@ nsWindow::OnConfigureEvent(GtkWidget *aWidget, GdkEventConfigure *aEvent) return FALSE; } - mBounds.MoveTo(screenBounds.TopLeft()); + // This is wrong, but noautohide titlebar panels currently depend on it + // (bug 601545#c13). mBounds.TopLeft() should refer to the + // window-manager frame top-left, but WidgetToScreenOffset() gives the + // client window origin. + mBounds.MoveTo(WidgetToScreenOffset()); nsGUIEvent event(true, NS_MOVE, this); diff --git a/widget/src/gtk2/nsWindow.h b/widget/src/gtk2/nsWindow.h index 02e92aea3fe0..11d75f213abf 100644 --- a/widget/src/gtk2/nsWindow.h +++ b/widget/src/gtk2/nsWindow.h @@ -170,8 +170,6 @@ public: NS_IMETHOD Enable(bool aState); NS_IMETHOD SetFocus(bool aRaise = false); NS_IMETHOD GetScreenBounds(nsIntRect &aRect); - NS_IMETHOD GetClientBounds(nsIntRect &aRect); - virtual nsIntPoint GetClientOffset(); NS_IMETHOD SetForegroundColor(const nscolor &aColor); NS_IMETHOD SetBackgroundColor(const nscolor &aColor); NS_IMETHOD SetCursor(nsCursor aCursor); diff --git a/widget/src/os2/nsWindow.cpp b/widget/src/os2/nsWindow.cpp index 42b0a33dfc49..67a8a9f44bd6 100644 --- a/widget/src/os2/nsWindow.cpp +++ b/widget/src/os2/nsWindow.cpp @@ -769,7 +769,10 @@ NS_METHOD nsWindow::GetBounds(nsIntRect& aRect) NS_METHOD nsWindow::GetClientBounds(nsIntRect& aRect) { - aRect = mBounds; + aRect.x = 0; + aRect.y = 0; + aRect.width = mBounds.width; + aRect.height = mBounds.height; return NS_OK; } diff --git a/widget/src/windows/nsTextStore.cpp b/widget/src/windows/nsTextStore.cpp index ebd64f936dd5..af5bf21240b8 100644 --- a/widget/src/windows/nsTextStore.cpp +++ b/widget/src/windows/nsTextStore.cpp @@ -1185,8 +1185,6 @@ nsTextStore::GetScreenExt(TsViewCookie vcView, 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()) { diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 70843729915a..feee2d9cfb97 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -1523,6 +1523,30 @@ 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) { @@ -1906,9 +1930,9 @@ NS_METHOD nsWindow::GetClientBounds(nsIntRect &aRect) RECT r; VERIFY(::GetClientRect(mWnd, &r)); - nsIntRect bounds; - GetBounds(bounds); - aRect.MoveTo(bounds.TopLeft() + GetClientOffset()); + // assign size + aRect.x = 0; + aRect.y = 0; aRect.width = r.right - r.left; aRect.height = r.bottom - r.top; diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index 5eaedd559919..d01a9574d738 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -125,6 +125,7 @@ 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 de614b1e5d5f..55d00db9dc27 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -300,6 +300,15 @@ 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 @@ -910,50 +919,6 @@ 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 d663885ee161..bc5f41ad3d26 100644 --- a/widget/src/xpwidgets/nsBaseWidget.h +++ b/widget/src/xpwidgets/nsBaseWidget.h @@ -122,15 +122,10 @@ 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); @@ -168,6 +163,9 @@ 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();