diff --git a/mozilla/widget/src/gtk/nsButton.cpp b/mozilla/widget/src/gtk/nsButton.cpp index ee3f9524e19..a7872f2f23e 100644 --- a/mozilla/widget/src/gtk/nsButton.cpp +++ b/mozilla/widget/src/gtk/nsButton.cpp @@ -27,8 +27,8 @@ #include "nsString.h" #include "nsStringUtil.h" -NS_IMPL_ADDREF(nsButton) -NS_IMPL_RELEASE(nsButton) +NS_IMPL_ADDREF_INHERITED(nsButton, nsButtonSuper) +NS_IMPL_RELEASE_INHERITED(nsButton, nsButtonSuper) //------------------------------------------------------------------------- // @@ -63,16 +63,17 @@ nsButton::~nsButton() void nsButton::InitCallbacks(char * aName) { nsWidget::InitCallbacks(); + /* FIXME: we need to unconnect the signals connected from * nsWidget::InitCallbacks that we provide here */ gtk_signal_connect(GTK_OBJECT(mWidget), - "button_press_event", - GTK_SIGNAL_FUNC(handle_button_press_event), - this); + "button_press_event", + GTK_SIGNAL_FUNC(handle_button_press_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), - "button_release_event", - GTK_SIGNAL_FUNC(handle_button_release_event), - this); + "button_release_event", + GTK_SIGNAL_FUNC(handle_button_release_event), + this); } /** diff --git a/mozilla/widget/src/gtk/nsButton.h b/mozilla/widget/src/gtk/nsButton.h index fd3147b4fea..43e801ae311 100644 --- a/mozilla/widget/src/gtk/nsButton.h +++ b/mozilla/widget/src/gtk/nsButton.h @@ -25,7 +25,8 @@ /** * Native GTK+ button wrapper */ -class nsButton : public nsWidget, +#define nsButtonSuper nsWidget +class nsButton : public nsButtonSuper, public nsIButton { diff --git a/mozilla/widget/src/gtk/nsCheckButton.cpp b/mozilla/widget/src/gtk/nsCheckButton.cpp index 5fd17b48aa2..51beab2d539 100644 --- a/mozilla/widget/src/gtk/nsCheckButton.cpp +++ b/mozilla/widget/src/gtk/nsCheckButton.cpp @@ -22,8 +22,8 @@ #include "nsString.h" #include "nsStringUtil.h" -NS_IMPL_ADDREF(nsCheckButton) -NS_IMPL_RELEASE(nsCheckButton) +NS_IMPL_ADDREF_INHERITED(nsCheckButton, nsCheckButtonSuper) +NS_IMPL_RELEASE_INHERITED(nsCheckButton, nsCheckButtonSuper) //------------------------------------------------------------------------- // diff --git a/mozilla/widget/src/gtk/nsCheckButton.h b/mozilla/widget/src/gtk/nsCheckButton.h index da242be8529..e573c35810d 100644 --- a/mozilla/widget/src/gtk/nsCheckButton.h +++ b/mozilla/widget/src/gtk/nsCheckButton.h @@ -26,7 +26,9 @@ * Native GTK+ Checkbox wrapper */ -class nsCheckButton : public nsWidget, +#define nsCheckButtonSuper nsWidget + +class nsCheckButton : public nsCheckButtonSuper, public nsICheckButton { diff --git a/mozilla/widget/src/gtk/nsComboBox.cpp b/mozilla/widget/src/gtk/nsComboBox.cpp index f5951341d77..699fd6d4532 100644 --- a/mozilla/widget/src/gtk/nsComboBox.cpp +++ b/mozilla/widget/src/gtk/nsComboBox.cpp @@ -30,8 +30,8 @@ #define INITIAL_MAX_ITEMS 128 #define ITEMS_GROWSIZE 128 -NS_IMPL_ADDREF(nsComboBox) -NS_IMPL_RELEASE(nsComboBox) +NS_IMPL_ADDREF_INHERITED(nsComboBox, nsComboBoxSuper) +NS_IMPL_RELEASE_INHERITED(nsComboBox, nsComboBoxSuper) //------------------------------------------------------------------------- // @@ -60,7 +60,9 @@ nsComboBox::~nsComboBox() g_free(items->data); } g_list_free(mItems); +#if 0 gtk_widget_destroy(mCombo); +#endif } //------------------------------------------------------------------------- diff --git a/mozilla/widget/src/gtk/nsComboBox.h b/mozilla/widget/src/gtk/nsComboBox.h index d1cf343a1fa..46b001c342d 100644 --- a/mozilla/widget/src/gtk/nsComboBox.h +++ b/mozilla/widget/src/gtk/nsComboBox.h @@ -26,7 +26,8 @@ * Native GTK+ Listbox wrapper */ -class nsComboBox : public nsWidget, +#define nsComboBoxSuper nsWidget +class nsComboBox : public nsComboBoxSuper, public nsIListWidget, public nsIComboBox { diff --git a/mozilla/widget/src/gtk/nsDialog.cpp b/mozilla/widget/src/gtk/nsDialog.cpp index c758881d7b7..7c32dcb455e 100644 --- a/mozilla/widget/src/gtk/nsDialog.cpp +++ b/mozilla/widget/src/gtk/nsDialog.cpp @@ -26,9 +26,6 @@ #include -NS_IMPL_ADDREF(nsDialog) -NS_IMPL_RELEASE(nsDialog) - //------------------------------------------------------------------------- // // nsDialog constructor @@ -48,6 +45,23 @@ nsDialog::~nsDialog() { } +//------------------------------------------------------------------------- +// +// nsDialog addref, release +// +//------------------------------------------------------------------------- +nsrefcnt +nsDialog::AddRef() +{ + return nsWindow::AddRef(); +} + +nsrefcnt +nsDialog::Release() +{ + return nsWindow::Release(); +} + //------------------------------------------------------------------------- // // Create the native GtkDialog widget diff --git a/mozilla/widget/src/gtk/nsGtkEventHandler.cpp b/mozilla/widget/src/gtk/nsGtkEventHandler.cpp index 136f434a195..4ee6294712b 100644 --- a/mozilla/widget/src/gtk/nsGtkEventHandler.cpp +++ b/mozilla/widget/src/gtk/nsGtkEventHandler.cpp @@ -137,7 +137,6 @@ void InitAllocationEvent(GtkAllocation *aAlloc, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_SIZE_EVENT; @@ -161,7 +160,6 @@ void InitConfigureEvent(GdkEventConfigure *aConf, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_SIZE_EVENT; @@ -187,7 +185,6 @@ void InitMouseEvent(GdkEventButton *aGEB, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_MOUSE_EVENT; @@ -234,7 +231,6 @@ void InitDrawEvent(GdkRectangle *area, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_PAINT_EVENT; @@ -265,7 +261,6 @@ void InitExposeEvent(GdkEventExpose *aGEE, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_PAINT_EVENT; @@ -296,7 +291,6 @@ void InitMotionEvent(GdkEventMotion *aGEM, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_MOUSE_EVENT; @@ -323,7 +317,6 @@ void InitCrossingEvent(GdkEventCrossing *aGEC, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_MOUSE_EVENT; @@ -350,7 +343,6 @@ void InitKeyEvent(GdkEventKey *aGEK, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_KEY_EVENT; @@ -389,7 +381,6 @@ void InitFocusEvent(GdkEventFocus *aGEF, { anEvent.message = aEventType; anEvent.widget = (nsWidget *) p; - NS_ADDREF(anEvent.widget); anEvent.eventStructType = NS_GUI_EVENT; @@ -487,8 +478,9 @@ gint handle_configure_event(GtkWidget *w, GdkEventConfigure *conf, gpointer p) InitConfigureEvent(conf, p, sevent, NS_SIZE); nsWindow *win = (nsWindow *)p; - + win->AddRef(); win->OnResize(sevent); + win->Release(); return PR_FALSE; } @@ -500,8 +492,9 @@ gint handle_draw_event(GtkWidget *w, GdkRectangle *area, gpointer p) InitDrawEvent(area, p, pevent, NS_PAINT); nsWindow *win = (nsWindow *)p; - + win->AddRef(); win->OnPaint(pevent); + win->Release(); UninitDrawEvent(area, p, pevent, NS_PAINT); @@ -517,8 +510,9 @@ gint handle_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer p) InitExposeEvent(event, p, pevent, NS_PAINT); nsWindow *win = (nsWindow *)p; - + win->AddRef(); win->OnPaint(pevent); + win->Release(); UninitExposeEvent(event, p, pevent, NS_PAINT); @@ -581,7 +575,9 @@ gint handle_button_press_event(GtkWidget *w, GdkEventButton * event, gpointer p) InitMouseEvent(event, p, mevent, b); nsWindow *win = (nsWindow *)p; + win->AddRef(); win->DispatchMouseEvent(mevent); + win->Release(); UninitMouseEvent(event, p, mevent, b); @@ -612,7 +608,9 @@ gint handle_button_release_event(GtkWidget *w, GdkEventButton * event, gpointer InitMouseEvent(event, p, mevent, b); nsWindow *win = (nsWindow *)p; + win->AddRef(); win->DispatchMouseEvent(mevent); + win->Release(); UninitMouseEvent(event, p, mevent, b); @@ -626,7 +624,9 @@ gint handle_motion_notify_event(GtkWidget *w, GdkEventMotion * event, gpointer p InitMotionEvent(event, p, mevent, NS_MOUSE_MOVE); nsWindow *win = (nsWindow *)p; + win->AddRef(); win->DispatchMouseEvent(mevent); + win->Release(); UninitMotionEvent(event, p, mevent, NS_MOUSE_MOVE); @@ -640,7 +640,9 @@ gint handle_enter_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer InitCrossingEvent(event, p, mevent, NS_MOUSE_ENTER); nsWindow *win = (nsWindow *)p; + win->AddRef(); win->DispatchMouseEvent(mevent); + win->Release(); UninitCrossingEvent(event, p, mevent, NS_MOUSE_ENTER); @@ -654,7 +656,9 @@ gint handle_leave_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer InitCrossingEvent(event, p, mevent, NS_MOUSE_EXIT); nsWindow *win = (nsWindow *)p; + win->AddRef(); win->DispatchMouseEvent(mevent); + win->Release(); return PR_TRUE; } @@ -662,28 +666,34 @@ gint handle_leave_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer //============================================================== gint handle_focus_in_event(GtkWidget *w, GdkEventFocus * event, gpointer p) { - nsGUIEvent gevent; - InitFocusEvent(event, p, gevent, NS_GOTFOCUS); - nsWindow *win = (nsWindow *)p; - win->DispatchFocus(gevent); + if (!win->IsDestroying()) { + nsGUIEvent gevent; + InitFocusEvent(event, p, gevent, NS_GOTFOCUS); - UninitFocusEvent(event, p, gevent, NS_GOTFOCUS); + win->AddRef(); + win->DispatchFocus(gevent); + win->Release(); + UninitFocusEvent(event, p, gevent, NS_GOTFOCUS); + } return PR_TRUE; } //============================================================== gint handle_focus_out_event(GtkWidget *w, GdkEventFocus * event, gpointer p) { - nsGUIEvent gevent; - InitFocusEvent(event, p, gevent, NS_LOSTFOCUS); - nsWindow *win = (nsWindow *)p; - win->DispatchFocus(gevent); + if (!win->IsDestroying()) { + nsGUIEvent gevent; + InitFocusEvent(event, p, gevent, NS_LOSTFOCUS); - UninitFocusEvent(event, p, gevent, NS_LOSTFOCUS); + win->AddRef(); + win->DispatchFocus(gevent); + win->Release(); + UninitFocusEvent(event, p, gevent, NS_LOSTFOCUS); + } return PR_TRUE; } @@ -694,8 +704,6 @@ void menu_item_activate_handler(GtkWidget *w, gpointer p) nsIMenuListener *menuListener = nsnull; nsIMenuItem *menuItem = (nsIMenuItem *)p; - NS_ADDREF(menuItem); - if (menuItem != NULL) { nsMenuEvent mevent; mevent.message = NS_MENU_SELECTED; @@ -721,85 +729,6 @@ void menu_item_activate_handler(GtkWidget *w, gpointer p) } } -#if 0 -//============================================================== -gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p) -{ - nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w)); - nsWindow * widgetWindow = (nsWindow *) p ; - - XmAnyCallbackStruct * cbs = (XmAnyCallbackStruct*)call_data; - nsGUIEvent event; - nsGtkWidget_InitNSEvent(cbs->event, p, event, - cbs->reason == XmCR_FOCUS?NS_GOTFOCUS:NS_LOSTFOCUS); - widgetWindow->DispatchFocus(event); - - return PR_FALSE; -} -#endif - -#if 0 -//============================================================== -gint nsGtkWidget_Toggle_Callback(GtkWidget *w, gpointer p) -{ - nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w)); - nsWindow * widgetWindow = (nsWindow *) p ; - if (DBG) fprintf(stderr, "***************** nsGtkWidget_Scrollbar_Callback\n"); - - nsScrollbarEvent sevent; - XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data; - - return PR_FALSE; -} -#endif - -#if 0 -//============================================================== -gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p) -{ - nsCheckButton *checkBtn = (nsCheckButton*)gtk_object_get_user_data(GTK_OBJECT(w)); - if (GTK_TOGGLE_BUTTON(w)->active) - checkBtn->Armed(); - else - checkBtn->DisArmed(); - - return PR_FALSE; -} -#endif - -#if 0 -//============================================================== -gint nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p) -{ - nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w)); - nsRadioButton * radioBtn = (nsRadioButton *) p ; - XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data; - radioBtn->Armed(); - nsMouseEvent mevent; - nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN); - radioBtn->DispatchMouseEvent(mevent); - - return PR_FALSE; -} -#endif - -#if 0 -//============================================================== -gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p) -{ - nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w)); - nsRadioButton * radioBtn = (nsRadioButton *) p ; - nsScrollbarEvent sevent; - XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data; - radioBtn->DisArmed(); - nsMouseEvent mevent; - nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP); - radioBtn->DispatchMouseEvent(mevent); - - return PR_FALSE; -} -#endif - //============================================================== void handle_scrollbar_value_changed(GtkAdjustment *adj, gpointer p) @@ -818,7 +747,9 @@ void handle_scrollbar_value_changed(GtkAdjustment *adj, gpointer p) widget->ReleaseNativeData(NS_NATIVE_WINDOW); #endif + widget->AddRef(); widget->OnScroll(sevent, adj->value); + widget->Release(); /* FIXME we need to set point.* from the event stuff. */ #if 0 @@ -882,7 +813,9 @@ gint handle_key_release_event(GtkWidget *w, GdkEventKey* event, gpointer p) InitKeyEvent(event, p, kevent, NS_KEY_UP); nsWindow * win = (nsWindow *) p; + win->AddRef(); win->OnKey(kevent); + win->Release(); return PR_TRUE; } @@ -903,7 +836,9 @@ gint handle_key_press_event(GtkWidget *w, GdkEventKey* event, gpointer p) InitKeyEvent(event, p, kevent, NS_KEY_DOWN); nsWindow * win = (nsWindow *) p; + win->AddRef(); win->OnKey(kevent); + win->Release(); return PR_TRUE; } diff --git a/mozilla/widget/src/gtk/nsLabel.cpp b/mozilla/widget/src/gtk/nsLabel.cpp index 3afc928f4d6..8db458a429a 100644 --- a/mozilla/widget/src/gtk/nsLabel.cpp +++ b/mozilla/widget/src/gtk/nsLabel.cpp @@ -27,8 +27,8 @@ #include "nsGtkEventHandler.h" -NS_IMPL_ADDREF(nsLabel) -NS_IMPL_RELEASE(nsLabel) +NS_IMPL_ADDREF_INHERITED(nsLabel, nsLabelSuper) +NS_IMPL_RELEASE_INHERITED(nsLabel, nsLabelSuper) //------------------------------------------------------------------------- // diff --git a/mozilla/widget/src/gtk/nsLabel.h b/mozilla/widget/src/gtk/nsLabel.h index fa3e05adb6c..40852510e0b 100644 --- a/mozilla/widget/src/gtk/nsLabel.h +++ b/mozilla/widget/src/gtk/nsLabel.h @@ -26,7 +26,8 @@ /** * Native GTK+ Label wrapper */ -class nsLabel : public nsWidget, +#define nsLabelSuper nsWidget +class nsLabel : public nsLabelSuper, public nsILabel { diff --git a/mozilla/widget/src/gtk/nsListBox.cpp b/mozilla/widget/src/gtk/nsListBox.cpp index c0f9d969686..3b20a3e4156 100644 --- a/mozilla/widget/src/gtk/nsListBox.cpp +++ b/mozilla/widget/src/gtk/nsListBox.cpp @@ -24,8 +24,8 @@ #include "nsString.h" #include "nsStringUtil.h" -NS_IMPL_ADDREF(nsListBox) -NS_IMPL_RELEASE(nsListBox) +NS_IMPL_ADDREF_INHERITED(nsListBox, nsListBoxSuper) +NS_IMPL_RELEASE_INHERITED(nsListBox, nsListBoxSuper) //------------------------------------------------------------------------- // @@ -36,6 +36,7 @@ nsListBox::nsListBox() : nsWidget(), nsIListWidget(), nsIListBox() { NS_INIT_REFCNT(); mMultiSelect = PR_FALSE; + mCList = nsnull; // mBackground = NS_RGB(124, 124, 124); } @@ -46,11 +47,13 @@ nsListBox::nsListBox() : nsWidget(), nsIListWidget(), nsIListBox() //------------------------------------------------------------------------- nsListBox::~nsListBox() { +#if 0 if (mCList) { ::gtk_widget_destroy(mCList); mCList = nsnull; } +#endif } //------------------------------------------------------------------------- diff --git a/mozilla/widget/src/gtk/nsListBox.h b/mozilla/widget/src/gtk/nsListBox.h index 40abba0f1d9..aeb97697b0b 100644 --- a/mozilla/widget/src/gtk/nsListBox.h +++ b/mozilla/widget/src/gtk/nsListBox.h @@ -25,8 +25,8 @@ /** * Native GTK+ Listbox wrapper */ - -class nsListBox : public nsWidget, +#define nsListBoxSuper nsWidget +class nsListBox : public nsListBoxSuper, public nsIListWidget, public nsIListBox { diff --git a/mozilla/widget/src/gtk/nsRadioButton.cpp b/mozilla/widget/src/gtk/nsRadioButton.cpp index 21e709c25cb..913d7129372 100644 --- a/mozilla/widget/src/gtk/nsRadioButton.cpp +++ b/mozilla/widget/src/gtk/nsRadioButton.cpp @@ -26,8 +26,8 @@ #include "nsGtkEventHandler.h" -NS_IMPL_ADDREF(nsRadioButton) -NS_IMPL_RELEASE(nsRadioButton) +NS_IMPL_ADDREF_INHERITED(nsRadioButton, nsRadioButtonSuper) +NS_IMPL_RELEASE_INHERITED(nsRadioButton, nsRadioButtonSuper) //------------------------------------------------------------------------- // @@ -48,8 +48,10 @@ nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton() //------------------------------------------------------------------------- nsRadioButton::~nsRadioButton() { +#if 0 if (mLabel) gtk_widget_destroy(mLabel); +#endif } diff --git a/mozilla/widget/src/gtk/nsRadioButton.h b/mozilla/widget/src/gtk/nsRadioButton.h index 4e8b62eca46..a700f7d8fc6 100644 --- a/mozilla/widget/src/gtk/nsRadioButton.h +++ b/mozilla/widget/src/gtk/nsRadioButton.h @@ -25,7 +25,8 @@ /** * Native GTK+ Radiobutton wrapper */ -class nsRadioButton : public nsWidget, +#define nsRadioButtonSuper nsWidget +class nsRadioButton : public nsRadioButtonSuper, public nsIRadioButton { diff --git a/mozilla/widget/src/gtk/nsScrollbar.cpp b/mozilla/widget/src/gtk/nsScrollbar.cpp index 7c60b9f62e8..7cc2460bd69 100644 --- a/mozilla/widget/src/gtk/nsScrollbar.cpp +++ b/mozilla/widget/src/gtk/nsScrollbar.cpp @@ -25,8 +25,8 @@ #include "nsGtkEventHandler.h" -NS_IMPL_ADDREF (nsScrollbar); -NS_IMPL_RELEASE (nsScrollbar); +NS_IMPL_ADDREF_INHERITED(nsScrollbar, nsScrollbarSuper); +NS_IMPL_RELEASE_INHERITED(nsScrollbar, nsScrollbarSuper); //------------------------------------------------------------------------- // diff --git a/mozilla/widget/src/gtk/nsScrollbar.h b/mozilla/widget/src/gtk/nsScrollbar.h index 780c2c12806..fabb034e3f1 100644 --- a/mozilla/widget/src/gtk/nsScrollbar.h +++ b/mozilla/widget/src/gtk/nsScrollbar.h @@ -25,8 +25,8 @@ /** * Native GTK+ scrollbar wrapper. */ - -class nsScrollbar : public nsWidget, +#define nsScrollbarSuper nsWidget +class nsScrollbar : public nsScrollbarSuper, public nsIScrollbar { diff --git a/mozilla/widget/src/gtk/nsTabWidget.cpp b/mozilla/widget/src/gtk/nsTabWidget.cpp index 5b904d5d219..c81daf3a7a7 100644 --- a/mozilla/widget/src/gtk/nsTabWidget.cpp +++ b/mozilla/widget/src/gtk/nsTabWidget.cpp @@ -24,8 +24,8 @@ #include "nsStringUtil.h" -NS_IMPL_ADDREF(nsTabWidget) -NS_IMPL_RELEASE(nsTabWidget) +NS_IMPL_ADDREF_INHERITED(nsTabWidget, nsTabWidgetSuper) +NS_IMPL_RELEASE_INHERITED(nsTabWidget, nsTabWidgetSuper) //------------------------------------------------------------------------- // diff --git a/mozilla/widget/src/gtk/nsTabWidget.h b/mozilla/widget/src/gtk/nsTabWidget.h index 169c463b578..3718b274c7c 100644 --- a/mozilla/widget/src/gtk/nsTabWidget.h +++ b/mozilla/widget/src/gtk/nsTabWidget.h @@ -26,8 +26,8 @@ /** * Native Win32 tab control wrapper */ - -class nsTabWidget : public nsWidget, +#define nsTabWidgetSuper nsWidget +class nsTabWidget : public nsTabWidgetSuper, public nsITabWidget { @@ -35,10 +35,10 @@ public: nsTabWidget(); virtual ~nsTabWidget(); - // nsISupports - NS_IMETHOD_(nsrefcnt) Release(void); - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); + // nsISupports + NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); // nsITabWidget part NS_IMETHOD SetTabs(PRUint32 aNumberOfTabs, const nsString aTabLabels[]); diff --git a/mozilla/widget/src/gtk/nsTextAreaWidget.cpp b/mozilla/widget/src/gtk/nsTextAreaWidget.cpp index 05aab745ad8..d4c0411e6cf 100644 --- a/mozilla/widget/src/gtk/nsTextAreaWidget.cpp +++ b/mozilla/widget/src/gtk/nsTextAreaWidget.cpp @@ -27,9 +27,6 @@ #define DBG 0 -NS_IMPL_ADDREF(nsTextAreaWidget) -NS_IMPL_RELEASE(nsTextAreaWidget) - //------------------------------------------------------------------------- // // nsTextAreaWidget constructor diff --git a/mozilla/widget/src/gtk/nsTextAreaWidget.h b/mozilla/widget/src/gtk/nsTextAreaWidget.h index 451aef24701..aa4dd8a01a6 100644 --- a/mozilla/widget/src/gtk/nsTextAreaWidget.h +++ b/mozilla/widget/src/gtk/nsTextAreaWidget.h @@ -34,9 +34,7 @@ public: nsTextAreaWidget(); virtual ~nsTextAreaWidget(); - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); + // nsISupports NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); virtual PRBool OnPaint(nsPaintEvent & aEvent); diff --git a/mozilla/widget/src/gtk/nsTextHelper.cpp b/mozilla/widget/src/gtk/nsTextHelper.cpp index 28a4ef9b4f5..12b1e440af6 100644 --- a/mozilla/widget/src/gtk/nsTextHelper.cpp +++ b/mozilla/widget/src/gtk/nsTextHelper.cpp @@ -28,6 +28,9 @@ #define DBG 0 +NS_IMPL_ADDREF_INHERITED(nsTextHelper, nsTextHelperSuper) +NS_IMPL_RELEASE_INHERITED(nsTextHelper, nsTextHelperSuper) + //------------------------------------------------------------------------- // // nsTextHelper constructor diff --git a/mozilla/widget/src/gtk/nsTextHelper.h b/mozilla/widget/src/gtk/nsTextHelper.h index 60b594ab7ed..1a0c273be93 100644 --- a/mozilla/widget/src/gtk/nsTextHelper.h +++ b/mozilla/widget/src/gtk/nsTextHelper.h @@ -25,8 +25,8 @@ /** * Base class for nsTextAreaWidget and nsTextWidget */ - -class nsTextHelper : public nsWidget, +#define nsTextHelperSuper nsWidget +class nsTextHelper : public nsTextHelperSuper, public nsITextAreaWidget, public nsITextWidget { @@ -34,6 +34,11 @@ class nsTextHelper : public nsWidget, public: nsTextHelper(); virtual ~nsTextHelper(); + + // nsISupports + NS_IMETHOD_(nsrefcnt) AddRef(); + NS_IMETHOD_(nsrefcnt) Release(); + NS_IMETHOD SelectAll(); NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData); NS_IMETHOD SetMaxTextLength(PRUint32 aChars); diff --git a/mozilla/widget/src/gtk/nsTextWidget.cpp b/mozilla/widget/src/gtk/nsTextWidget.cpp index 266eac30c3b..eb6a53b9343 100644 --- a/mozilla/widget/src/gtk/nsTextWidget.cpp +++ b/mozilla/widget/src/gtk/nsTextWidget.cpp @@ -29,9 +29,6 @@ extern int mIsPasswordCallBacksInstalled; -NS_IMPL_ADDREF(nsTextWidget) -NS_IMPL_RELEASE(nsTextWidget) - //------------------------------------------------------------------------- // // nsTextWidget constructor diff --git a/mozilla/widget/src/gtk/nsTextWidget.h b/mozilla/widget/src/gtk/nsTextWidget.h index 3d6d1866c3f..c9503fefc2e 100644 --- a/mozilla/widget/src/gtk/nsTextWidget.h +++ b/mozilla/widget/src/gtk/nsTextWidget.h @@ -37,8 +37,6 @@ public: // nsISupports NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); virtual PRBool OnPaint(nsPaintEvent & aEvent); virtual PRBool OnResize(nsSizeEvent &aEvent); diff --git a/mozilla/widget/src/gtk/nsWidget.cpp b/mozilla/widget/src/gtk/nsWidget.cpp index 92ef0ef6f39..643154e4f28 100644 --- a/mozilla/widget/src/gtk/nsWidget.cpp +++ b/mozilla/widget/src/gtk/nsWidget.cpp @@ -93,6 +93,10 @@ NS_METHOD nsWidget::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) NS_IMETHODIMP nsWidget::Destroy(void) { +#ifdef NOISY_WIDGET_DESTROY + printf("nsWidget::Destroy:%p: isDestroying=%s widget=%p parent=%p\n", + this, mIsDestroying ? "yes" : "no", mWidget, mParent); +#endif GtkAllocation *old_size = NULL; if (!mIsDestroying) { nsBaseWidget::Destroy(); @@ -122,12 +126,13 @@ void nsWidget::OnDestroy() nsBaseWidget::OnDestroy(); // dispatch the event if (!mIsDestroying) { - // dispatching of the event may cause the reference count to drop to 0 - // and result in this object being destroyed. To avoid that, add a reference - // and then release it after dispatching the event - AddRef(); + // dispatching of the event may cause the reference count to drop + // to 0 and result in this object being destroyed. To avoid that, + // add a reference and then release it after dispatching the event + nsrefcnt old = mRefCnt; + mRefCnt = 99; DispatchStandardEvent(NS_DESTROY); - Release(); + mRefCnt = old; } } @@ -269,13 +274,9 @@ PRBool nsWidget::OnResize(nsRect &aRect) event.point.y = mWidget->allocation.y; event.time = 0; PRBool result = DispatchWindowEvent(&event); - // XXX why does this always crash? maybe we need to add - // a ref in the dispatch code? check the windows - // code for a reference - //NS_RELEASE(event.widget); return result; } -return PR_FALSE; + return PR_FALSE; } //------ @@ -294,7 +295,6 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY) event.point.y = aY; event.eventStructType = NS_GUI_EVENT; PRBool result = DispatchWindowEvent(&event); - // NS_RELEASE(event.widget); return result; } @@ -677,6 +677,8 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent, BaseCreate(aParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData); + mParent = aParent; + NS_IF_ADDREF(mParent); if (aNativeParent) { parentWidget = GTK_WIDGET(aNativeParent); @@ -817,7 +819,6 @@ void nsWidget::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY) void nsWidget::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint) { event.widget = this; - NS_IF_ADDREF(event.widget); GdkEventConfigure *ge; ge = (GdkEventConfigure*)gtk_get_current_event(); @@ -880,9 +881,7 @@ PRBool nsWidget::DispatchStandardEvent(PRUint32 aMsg) nsGUIEvent event; event.eventStructType = NS_GUI_EVENT; InitEvent(event, aMsg); - PRBool result = DispatchWindowEvent(&event); - NS_IF_RELEASE(event.widget); return result; } @@ -913,6 +912,7 @@ NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *event, aStatus = mEventListener->ProcessEvent(*event); } NS_RELEASE(event->widget); + return NS_OK; } diff --git a/mozilla/widget/src/gtk/nsWidget.h b/mozilla/widget/src/gtk/nsWidget.h index 0894b3fd9e3..a6a22fdb0e3 100644 --- a/mozilla/widget/src/gtk/nsWidget.h +++ b/mozilla/widget/src/gtk/nsWidget.h @@ -137,7 +137,7 @@ class nsWidget : public nsBaseWidget PRBool DispatchWindowEvent(nsGUIEvent* event); GtkWidget *mWidget; - nsWidget *mParent; + nsIWidget *mParent; // This is the composite update area (union of all the calls to // Invalidate) diff --git a/mozilla/widget/src/gtk/nsWindow.cpp b/mozilla/widget/src/gtk/nsWindow.cpp index 26c290880ca..aa1dd03692f 100644 --- a/mozilla/widget/src/gtk/nsWindow.cpp +++ b/mozilla/widget/src/gtk/nsWindow.cpp @@ -39,10 +39,6 @@ //#define DBG 0 -// for nsISupports -NS_IMPL_ADDREF(nsWindow) -NS_IMPL_RELEASE(nsWindow) - /** * Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID * @modify gpk 8/4/98 @@ -98,14 +94,16 @@ nsWindow::nsWindow() nsWindow::~nsWindow() { mIsDestroying = PR_TRUE; - if (mShell) - { - if (GTK_IS_WIDGET(mShell)) - gtk_widget_destroy(mShell); - mShell = nsnull; + if (nsnull != mShell) { + Destroy(); } } +PRBool nsWindow::IsChild() const +{ + return PR_FALSE; +} + //------------------------------------------------------------------------- void nsWindow::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY) { @@ -146,13 +144,10 @@ NS_METHOD nsWindow::RemoveTooltips() NS_METHOD nsWindow::Destroy() { - // disconnect from the parent - + // Call base class first... + nsWidget::Destroy(); if (mIsDestroying == PR_TRUE) { - nsBaseWidget::Destroy(); - if (PR_FALSE == mOnDestroyCalled) - OnDestroy(); if (mShell) { if (GTK_IS_WIDGET(mShell)) gtk_widget_destroy(mShell); @@ -163,24 +158,6 @@ NS_METHOD nsWindow::Destroy() return NS_OK; } -void nsWindow::OnDestroy() -{ - mOnDestroyCalled = PR_TRUE; - - // release references to children, device context, toolkit, and app shell - nsBaseWidget::OnDestroy(); - - // dispatch the event - if (mIsDestroying == PR_TRUE) { - // dispatching of the event may cause the reference count to drop to 0 - // and result in this object being destroyed. To avoid that, add a reference - // and then release it after dispatching the event - AddRef(); - DispatchStandardEvent(NS_DESTROY); - Release(); - } -} - gint handle_delete_event(GtkWidget *w, GdkEventAny *e, nsWindow *win) { @@ -287,53 +264,53 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget) void nsWindow::InitCallbacks(char * aName) { gtk_signal_connect_after(GTK_OBJECT(mWidget), - "size_allocate", - GTK_SIGNAL_FUNC(handle_size_allocate), - this); + "size_allocate", + GTK_SIGNAL_FUNC(handle_size_allocate), + this); gtk_signal_connect_after(GTK_OBJECT(mWidget), - "button_press_event", - GTK_SIGNAL_FUNC(handle_button_press_event), - this); + "button_press_event", + GTK_SIGNAL_FUNC(handle_button_press_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "button_release_event", - GTK_SIGNAL_FUNC(handle_button_release_event), - this); + GTK_SIGNAL_FUNC(handle_button_release_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "motion_notify_event", - GTK_SIGNAL_FUNC(handle_motion_notify_event), - this); + GTK_SIGNAL_FUNC(handle_motion_notify_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "enter_notify_event", - GTK_SIGNAL_FUNC(handle_enter_notify_event), - this); + GTK_SIGNAL_FUNC(handle_enter_notify_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "leave_notify_event", - GTK_SIGNAL_FUNC(handle_leave_notify_event), - this); + GTK_SIGNAL_FUNC(handle_leave_notify_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "draw", - GTK_SIGNAL_FUNC(handle_draw_event), - this); + GTK_SIGNAL_FUNC(handle_draw_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "expose_event", - GTK_SIGNAL_FUNC(handle_expose_event), - this); + GTK_SIGNAL_FUNC(handle_expose_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "key_press_event", - GTK_SIGNAL_FUNC(handle_key_press_event), - this); + GTK_SIGNAL_FUNC(handle_key_press_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "key_release_event", - GTK_SIGNAL_FUNC(handle_key_release_event), - this); + GTK_SIGNAL_FUNC(handle_key_release_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "focus_in_event", - GTK_SIGNAL_FUNC(handle_focus_in_event), - this); + GTK_SIGNAL_FUNC(handle_focus_in_event), + this); gtk_signal_connect(GTK_OBJECT(mWidget), "focus_out_event", - GTK_SIGNAL_FUNC(handle_focus_out_event), - this); + GTK_SIGNAL_FUNC(handle_focus_out_event), + this); } //------------------------------------------------------------------------- @@ -508,3 +485,14 @@ NS_METHOD nsWindow::SetMenuBar(nsIMenuBar * aMenuBar) return NS_OK; } + +//---------------------------------------------------------------------- + +ChildWindow::ChildWindow() +{ +} + +PRBool ChildWindow::IsChild() const +{ + return PR_TRUE; +} diff --git a/mozilla/widget/src/gtk/nsWindow.h b/mozilla/widget/src/gtk/nsWindow.h index fb08eeb2458..8d6863f4b9d 100644 --- a/mozilla/widget/src/gtk/nsWindow.h +++ b/mozilla/widget/src/gtk/nsWindow.h @@ -45,8 +45,6 @@ public: virtual ~nsWindow(); // nsIsupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); @@ -71,8 +69,15 @@ public: NS_IMETHOD Destroy(void); - virtual PRBool IsChild() { return(PR_FALSE); }; - virtual void SetIsDestroying( PRBool val) { mIsDestroying = val; }; + virtual PRBool IsChild() const; + + void SetIsDestroying(PRBool val) { + mIsDestroying = val; + } + + PRBool IsDestroying() const { + return mIsDestroying; + } // Utility methods virtual PRBool OnPaint(nsPaintEvent &event); @@ -85,7 +90,6 @@ public: char gInstanceClassName[256]; protected: - virtual void OnDestroy(); virtual void InitCallbacks(char * aName = nsnull); NS_IMETHOD CreateNative(GtkWidget *parentWidget); @@ -113,9 +117,9 @@ protected: // A child window is a window with different style // class ChildWindow : public nsWindow { - public: - ChildWindow() {}; - virtual PRBool IsChild() { return(PR_TRUE); }; +public: + ChildWindow(); + virtual PRBool IsChild() const; }; #endif // Window_h__