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