зеркало из https://github.com/mozilla/gecko-dev.git
Make nsIWidget::GetParent return a weak pointer. Bug 227489, r+sr=roc
This commit is contained in:
Родитель
c5f7025c57
Коммит
ed97753ea2
|
@ -170,17 +170,17 @@ nsPoint nsDOMUIEvent::GetClientPoint() {
|
|||
// anyway... actually what we want is for all users of this and refPoint to agree
|
||||
// gracefully on what coordinate system to use, but that's a more involved change.
|
||||
|
||||
nsCOMPtr<nsIWidget> eventParent = eventWidget;
|
||||
nsIWidget* eventParent = eventWidget;
|
||||
for (;;) {
|
||||
nsCOMPtr<nsIWidget> t = dont_AddRef(eventParent->GetParent());
|
||||
nsIWidget* t = eventParent->GetParent();
|
||||
if (!t)
|
||||
break;
|
||||
eventParent = t;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWidget> docParent = docWidget;
|
||||
nsIWidget* docParent = docWidget;
|
||||
for (;;) {
|
||||
nsCOMPtr<nsIWidget> t = dont_AddRef(docParent->GetParent());
|
||||
nsIWidget* t = docParent->GetParent();
|
||||
if (!t)
|
||||
break;
|
||||
docParent = t;
|
||||
|
@ -198,7 +198,7 @@ nsPoint nsDOMUIEvent::GetClientPoint() {
|
|||
nsRect bounds;
|
||||
eventWidget->GetBounds(bounds);
|
||||
pt += bounds.TopLeft();
|
||||
eventWidget = dont_AddRef(eventWidget->GetParent());
|
||||
eventWidget = eventWidget->GetParent();
|
||||
}
|
||||
|
||||
if (eventWidget != docWidget) {
|
||||
|
@ -219,7 +219,7 @@ nsPoint nsDOMUIEvent::GetClientPoint() {
|
|||
nsRect bounds;
|
||||
docWidget->GetBounds(bounds);
|
||||
pt -= bounds.TopLeft();
|
||||
docWidget = dont_AddRef(docWidget->GetParent());
|
||||
docWidget = docWidget->GetParent();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -479,7 +479,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
// "on top" window.
|
||||
{
|
||||
nsMouseEvent* mouseEvent = NS_STATIC_CAST(nsMouseEvent*, aEvent);
|
||||
nsCOMPtr<nsIWidget> parentWidget = getter_AddRefs(mouseEvent->widget->GetParent());
|
||||
nsIWidget* parentWidget = mouseEvent->widget->GetParent();
|
||||
nsPoint eventPoint;
|
||||
eventPoint = nsLayoutUtils::TranslateWidgetToView(aPresContext,
|
||||
mouseEvent->widget,
|
||||
|
|
|
@ -172,10 +172,10 @@ nsGTKRemoteService::RegisterWindow(nsIDOMWindow* aWindow)
|
|||
// walk up the widget tree and find the toplevel window in the
|
||||
// hierarchy
|
||||
|
||||
nsCOMPtr<nsIWidget> tempWidget (dont_AddRef(mainWidget->GetParent()));
|
||||
nsIWidget* tempWidget = mainWidget->GetParent();
|
||||
|
||||
while (tempWidget) {
|
||||
tempWidget = dont_AddRef(tempWidget->GetParent());
|
||||
tempWidget = tempWidget->GetParent();
|
||||
if (tempWidget)
|
||||
mainWidget = tempWidget;
|
||||
}
|
||||
|
|
|
@ -1767,8 +1767,8 @@ void nsViewManager::ReparentChildWidgets(nsIView* aView, nsIWidget *aNewWidget)
|
|||
// the widget, otherwise there is nothing more
|
||||
// to do for the view and its descendants
|
||||
nsIWidget* widget = aView->GetWidget();
|
||||
nsCOMPtr<nsIWidget> parentWidget = getter_AddRefs(widget->GetParent());
|
||||
if (parentWidget.get() != aNewWidget) {
|
||||
nsIWidget* parentWidget = widget->GetParent();
|
||||
if (parentWidget != aNewWidget) {
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
|
|
|
@ -73,7 +73,7 @@ class nsIMenu : public nsISupports {
|
|||
nsIChangeManager* aManager, nsIDocShell* aShell, nsIContent* aNode ) = 0;
|
||||
|
||||
/**
|
||||
* Get the Menu's Parent
|
||||
* Get the Menu's Parent. This addrefs.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParent(nsISupports *&aParent) = 0;
|
||||
|
|
|
@ -64,7 +64,7 @@ class nsIMenuBar : public nsISupports {
|
|||
NS_IMETHOD Create(nsIWidget * aParent) = 0;
|
||||
|
||||
/**
|
||||
* Get the MenuBar's Parent
|
||||
* Get the MenuBar's Parent. This addrefs.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetParent(nsIWidget *&aParent) = 0;
|
||||
|
|
|
@ -96,10 +96,10 @@ typedef nsEventStatus (*PR_CALLBACK EVENT_CALLBACK)(nsGUIEvent *event);
|
|||
#define NS_NATIVE_SCREEN 9
|
||||
#define NS_NATIVE_SHELLWIDGET 10 // Get the shell GtkWidget
|
||||
|
||||
// e7f09105-d21b-406a-89d5-e6b731b8f665
|
||||
// 6259bce0-f407-4c31-a09b-5d3c7b1c4260
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0xe7f09105, 0xd21b, 0x406a, \
|
||||
{ 0x89, 0xd5, 0xe6, 0xb7, 0x31, 0xb8, 0xf6, 0x65 } }
|
||||
{ 0x6259bce0, 0xf407, 0x4c31, \
|
||||
{ 0xa0, 0x9b, 0x5d, 0x3c, 0x7b, 0x1c, 0x42, 0x60 } }
|
||||
|
||||
|
||||
// Hide the native window systems real window type so as to avoid
|
||||
|
|
|
@ -798,7 +798,6 @@ nsIWidget* nsWindow::GetParent(void)
|
|||
if (mIsDestroying || mOnDestroyCalled)
|
||||
return nsnull;
|
||||
widget = (nsIWidget *)mParent;
|
||||
NS_IF_ADDREF(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
|
|
@ -700,7 +700,6 @@ NS_IMETHODIMP nsChildView::Show(PRBool bState)
|
|||
nsIWidget*
|
||||
nsChildView::GetParent(void)
|
||||
{
|
||||
NS_IF_ADDREF(mParentWidget);
|
||||
return mParentWidget;
|
||||
}
|
||||
|
||||
|
|
|
@ -424,10 +424,7 @@ nsWidget::OnDestroySignal(GtkWidget* aGtkWidget)
|
|||
|
||||
nsIWidget* nsWidget::GetParent(void)
|
||||
{
|
||||
nsIWidget *ret;
|
||||
ret = mParent;
|
||||
NS_IF_ADDREF(ret);
|
||||
return ret;
|
||||
return mParent;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -63,10 +63,7 @@ nsCommonWidget::~nsCommonWidget()
|
|||
nsIWidget *
|
||||
nsCommonWidget::GetParent(void)
|
||||
{
|
||||
nsIWidget *retval;
|
||||
retval = mParent;
|
||||
NS_IF_ADDREF(retval);
|
||||
return retval;
|
||||
return mParent;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -257,7 +257,7 @@ void nsMacEventDispatchHandler::SetDeactivated(nsWindow *aDeactivatedWidget)
|
|||
if (mActiveWidget) {
|
||||
nsCOMPtr<nsIWidget> curWin = do_QueryInterface(NS_STATIC_CAST(nsIWidget*, mActiveWidget));
|
||||
for (;;) {
|
||||
nsCOMPtr<nsIWidget> parent = dont_AddRef(curWin->GetParent());
|
||||
nsIWidget* parent = curWin->GetParent();
|
||||
if (!parent)
|
||||
break;
|
||||
curWin = parent;
|
||||
|
@ -502,8 +502,8 @@ PRBool nsMacEventHandler::HandleMenuCommand(
|
|||
// the event is supposed to not have been handled)
|
||||
if (focusedWidget == gEventDispatchHandler.GetActive())
|
||||
{
|
||||
nsCOMPtr<nsIWidget> grandParent;
|
||||
nsCOMPtr<nsIWidget> parent ( dont_AddRef(focusedWidget->GetParent()) );
|
||||
// Hold a ref across event dispatch
|
||||
nsCOMPtr<nsIWidget> parent = focusedWidget->GetParent();
|
||||
while (parent)
|
||||
{
|
||||
menuEvent.widget = parent;
|
||||
|
@ -514,8 +514,7 @@ PRBool nsMacEventHandler::HandleMenuCommand(
|
|||
}
|
||||
else
|
||||
{
|
||||
grandParent = dont_AddRef(parent->GetParent());
|
||||
parent = grandParent;
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part)
|
|||
if (mOnDestroyCalled)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIWidget> parent ( dont_AddRef(GetParent()) );
|
||||
nsCOMPtr<nsIWidget> parent ( GetParent() );
|
||||
if (!parent)
|
||||
{
|
||||
// parent disappeared while scrolling was in progress. Handling Destroy
|
||||
|
|
|
@ -432,7 +432,6 @@ NS_IMETHODIMP nsWindow::Destroy()
|
|||
nsIWidget* nsWindow::GetParent(void)
|
||||
{
|
||||
if (mIsTopWidgetWindow) return nsnull;
|
||||
NS_IF_ADDREF(mParent);
|
||||
return mParent;
|
||||
}
|
||||
|
||||
|
@ -2055,7 +2054,7 @@ nsWindow::CalcOffset(PRInt32 &aX, PRInt32 &aY)
|
|||
{
|
||||
aX = aY = 0;
|
||||
|
||||
nsCOMPtr<nsIWidget> theParent = dont_AddRef(GetParent());
|
||||
nsIWidget* theParent = GetParent();
|
||||
while (theParent)
|
||||
{
|
||||
nsRect theRect;
|
||||
|
@ -2063,8 +2062,7 @@ nsWindow::CalcOffset(PRInt32 &aX, PRInt32 &aY)
|
|||
aX += theRect.x;
|
||||
aY += theRect.y;
|
||||
|
||||
nsIWidget* grandparent = theParent->GetParent();
|
||||
theParent = dont_AddRef(grandparent);
|
||||
theParent = theParent->GetParent();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2072,7 +2070,7 @@ nsWindow::CalcOffset(PRInt32 &aX, PRInt32 &aY)
|
|||
PRBool
|
||||
nsWindow::ContainerHierarchyIsVisible()
|
||||
{
|
||||
nsCOMPtr<nsIWidget> theParent = dont_AddRef(GetParent());
|
||||
nsIWidget* theParent = GetParent();
|
||||
|
||||
while (theParent)
|
||||
{
|
||||
|
@ -2081,8 +2079,7 @@ nsWindow::ContainerHierarchyIsVisible()
|
|||
if (!visible)
|
||||
return PR_FALSE;
|
||||
|
||||
nsIWidget* grandparent = theParent->GetParent();
|
||||
theParent = dont_AddRef(grandparent);
|
||||
theParent = theParent->GetParent();
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
|
@ -2159,7 +2156,6 @@ NS_IMETHODIMP nsWindow::WidgetToScreen(const nsRect& aLocalRect, nsRect& aGlobal
|
|||
//
|
||||
// Convert the local rect to global, except for this level.
|
||||
theParent->WidgetToScreen(aLocalRect, aGlobalRect);
|
||||
NS_RELEASE(theParent);
|
||||
|
||||
// the offset from our parent is in the x/y of our bounding rect
|
||||
nsRect myBounds;
|
||||
|
@ -2200,7 +2196,6 @@ NS_IMETHODIMP nsWindow::ScreenToWidget(const nsRect& aGlobalRect, nsRect& aLocal
|
|||
//
|
||||
// Convert the local rect to global, except for this level.
|
||||
theParent->WidgetToScreen(aGlobalRect, aLocalRect);
|
||||
NS_RELEASE(theParent);
|
||||
|
||||
// the offset from our parent is in the x/y of our bounding rect
|
||||
nsRect myBounds;
|
||||
|
@ -2341,7 +2336,7 @@ NS_IMETHODIMP nsWindow::GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigi
|
|||
widgetClipRect.y = 0;
|
||||
|
||||
// Gather up the absolute position of the widget, clip window, and visibilty
|
||||
nsCOMPtr<nsIWidget> widget = getter_AddRefs(GetParent());
|
||||
nsIWidget* widget = GetParent();
|
||||
while (widget)
|
||||
{
|
||||
if (isVisible)
|
||||
|
@ -2358,7 +2353,7 @@ NS_IMETHODIMP nsWindow::GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigi
|
|||
widgetClipRect.IntersectRect(widgetClipRect, widgetRect);
|
||||
absX += wx;
|
||||
absY += wy;
|
||||
widget = getter_AddRefs(widget->GetParent());
|
||||
widget = widget->GetParent();
|
||||
if (!widget)
|
||||
{
|
||||
// Don't include the top-level windows offset
|
||||
|
@ -2421,7 +2416,7 @@ NS_IMETHODIMP nsWindow::ResetInputState()
|
|||
{
|
||||
// currently, the nsMacEventHandler is owned by nsMacWindow, which is the top level window
|
||||
// we delegate this call to its parent
|
||||
nsCOMPtr<nsIWidget> parent = getter_AddRefs(GetParent());
|
||||
nsIWidget* parent = GetParent();
|
||||
NS_WARN_IF_FALSE(parent, "cannot get parent");
|
||||
if (parent)
|
||||
{
|
||||
|
|
|
@ -1166,7 +1166,6 @@ nsIWidget* nsWindow::GetParent(void)
|
|||
nsWindow *widget = nsnull;
|
||||
if ((nsnull != mParent) && (!mParent->mIsDestroying))
|
||||
{
|
||||
NS_ADDREF(mParent);
|
||||
widget = mParent;
|
||||
}
|
||||
|
||||
|
|
|
@ -1740,6 +1740,7 @@ nsIWidget* nsWindow::GetParent(void)
|
|||
return GetParent(PR_TRUE);
|
||||
}
|
||||
|
||||
// XXX does anyone pass false for aStopOnFirstTopLevel?
|
||||
nsWindow* nsWindow::GetParent(PRBool aStopOnFirstTopLevel)
|
||||
{
|
||||
if (mIsTopWidgetWindow && aStopOnFirstTopLevel) {
|
||||
|
@ -1764,8 +1765,6 @@ nsWindow* nsWindow::GetParent(PRBool aStopOnFirstTopLevel)
|
|||
// do NOT return it
|
||||
if (widget->mIsDestroying) {
|
||||
widget = nsnull;
|
||||
} else {
|
||||
NS_ADDREF(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2085,8 +2084,6 @@ NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
|
|||
VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, 0, 0,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE));
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(par);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2132,8 +2129,6 @@ NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
|||
else {
|
||||
VERIFY(::SetWindowPos(mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight), flags));
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(par);
|
||||
}
|
||||
|
||||
if (aRepaint)
|
||||
|
@ -2185,8 +2180,6 @@ NS_METHOD nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeig
|
|||
else {
|
||||
VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight), flags));
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(par);
|
||||
}
|
||||
|
||||
if (aRepaint)
|
||||
|
@ -7521,9 +7514,7 @@ nsWindow::ResolveIMECaretPos(nsWindow* aClient,
|
|||
nsRect& aResult)
|
||||
{
|
||||
// RootView coordinates -> Screen coordinates
|
||||
nsWindow* topWindow = GetTopLevelWindow();
|
||||
topWindow->WidgetToScreen(aEventResult, aResult);
|
||||
NS_RELEASE(topWindow);
|
||||
GetTopLevelWindow()->WidgetToScreen(aEventResult, aResult);
|
||||
// if aClient is nsnull, returns screen coordinates
|
||||
if (!aClient)
|
||||
return;
|
||||
|
@ -8325,17 +8316,14 @@ STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, L
|
|||
nsWindow* nsWindow::GetTopLevelWindow()
|
||||
{
|
||||
nsWindow* curWindow = this;
|
||||
NS_ADDREF(curWindow);
|
||||
|
||||
while (PR_TRUE)
|
||||
{
|
||||
nsWindow* parentWindow = curWindow->GetParent(PR_TRUE);
|
||||
|
||||
if (parentWindow)
|
||||
{
|
||||
NS_RELEASE(curWindow);
|
||||
curWindow = parentWindow;
|
||||
} else
|
||||
else
|
||||
return curWindow;
|
||||
}
|
||||
}
|
||||
|
@ -8448,27 +8436,21 @@ void nsWindow::ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PR
|
|||
|
||||
NS_IMETHODIMP nsWindow::GetWindowTranslucency(PRBool& aTranslucent)
|
||||
{
|
||||
nsWindow* topWindow = GetTopLevelWindow();
|
||||
aTranslucent = topWindow->GetWindowTranslucencyInner();
|
||||
NS_RELEASE(topWindow);
|
||||
aTranslucent = GetTopLevelWindow()->GetWindowTranslucencyInner();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::SetWindowTranslucency(PRBool aTranslucent)
|
||||
{
|
||||
nsWindow* topWindow = GetTopLevelWindow();
|
||||
nsresult rv = topWindow->SetWindowTranslucencyInner(aTranslucent);
|
||||
NS_RELEASE(topWindow);
|
||||
nsresult rv = GetTopLevelWindow()->SetWindowTranslucencyInner(aTranslucent);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas)
|
||||
{
|
||||
nsWindow* topWindow = GetTopLevelWindow();
|
||||
topWindow->UpdateTranslucentWindowAlphaInner(aRect, aAlphas);
|
||||
NS_RELEASE(topWindow);
|
||||
GetTopLevelWindow()->UpdateTranslucentWindowAlphaInner(aRect, aAlphas);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -756,9 +756,6 @@ NS_IMETHODIMP nsWidget::PreCreateWidget(nsWidgetInitData *aInitData)
|
|||
|
||||
nsIWidget *nsWidget::GetParent(void)
|
||||
{
|
||||
if (nsnull != mParentWidget) {
|
||||
NS_ADDREF(mParentWidget);
|
||||
}
|
||||
return mParentWidget;
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,6 @@ NS_METHOD nsBaseWidget::Destroy()
|
|||
nsIWidget *parent = GetParent();
|
||||
if (parent) {
|
||||
parent->RemoveChild(this);
|
||||
NS_RELEASE(parent);
|
||||
}
|
||||
// disconnect listeners.
|
||||
NS_IF_RELEASE(mMouseListener);
|
||||
|
@ -306,9 +305,7 @@ void nsBaseWidget::AddChild(nsIWidget* aChild)
|
|||
//-------------------------------------------------------------------------
|
||||
void nsBaseWidget::RemoveChild(nsIWidget* aChild)
|
||||
{
|
||||
NS_ASSERTION(nsCOMPtr<nsIWidget>(dont_AddRef(aChild->GetParent())) ==
|
||||
NS_STATIC_CAST(nsIWidget*, this),
|
||||
"Not one of our kids!");
|
||||
NS_ASSERTION(aChild->GetParent() == this, "Not one of our kids!");
|
||||
|
||||
if (mLastChild == aChild) {
|
||||
mLastChild = mLastChild->GetPrevSibling();
|
||||
|
@ -340,6 +337,10 @@ void nsBaseWidget::RemoveChild(nsIWidget* aChild)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseWidget::SetZIndex(PRInt32 aZIndex)
|
||||
{
|
||||
// Hold a ref to ourselves just in case, since we're going to remove
|
||||
// from our parent.
|
||||
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
|
||||
|
||||
mZIndex = aZIndex;
|
||||
|
||||
// reorder this child in its parent's list.
|
||||
|
@ -374,8 +375,6 @@ NS_IMETHODIMP nsBaseWidget::SetZIndex(PRInt32 aZIndex)
|
|||
if (!sib) {
|
||||
parent->AddChild(this);
|
||||
}
|
||||
|
||||
NS_RELEASE(parent);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -707,7 +707,7 @@ NS_IMETHODIMP nsXULWindow::GetParentWidget(nsIWidget** aParentWidget)
|
|||
NS_ENSURE_ARG_POINTER(aParentWidget);
|
||||
NS_ENSURE_STATE(mWindow);
|
||||
|
||||
*aParentWidget = mWindow->GetParent();
|
||||
NS_IF_ADDREF(*aParentWidget = mWindow->GetParent());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче