This commit is contained in:
ramiro%netscape.com 1999-09-09 02:32:54 +00:00
Родитель 855d60c608
Коммит 0dd37aec4a
12 изменённых файлов: 393 добавлений и 240 удалений

Просмотреть файл

@ -2865,13 +2865,15 @@ nsBrowserWindow::ToggleFrameBorders()
}
void
nsBrowserWindow::ToggleFlashPaintArea()
nsBrowserWindow::ToggleBoolPrefAndRefresh(const char * aPrefName)
{
if (nsnull != mPrefs)
NS_ASSERTION(nsnull != aPrefName,"null pref name");
if (nsnull != mPrefs && nsnull != aPrefName)
{
PRBool flashing;
mPrefs->GetBoolPref("nglayout.widget.flash_invalidate_areas",&flashing);
mPrefs->SetBoolPref("nglayout.widget.flash_invalidate_areas",!flashing);
PRBool value;
mPrefs->GetBoolPref(aPrefName,&value);
mPrefs->SetBoolPref(aPrefName,!value);
mPrefs->SavePrefFile();
ForceRefresh();
@ -2935,8 +2937,33 @@ nsBrowserWindow::DispatchDebugMenu(PRInt32 aID)
result = nsEventStatus_eConsumeNoDefault;
break;
case VIEWER_FLASH_PAINT_AREA:
ToggleFlashPaintArea();
case VIEWER_TOGGLE_PAINT_FLASHING:
ToggleBoolPrefAndRefresh("nglayout.debug.paint_flashing");
result = nsEventStatus_eConsumeNoDefault;
break;
case VIEWER_TOGGLE_PAINT_DUMPING:
ToggleBoolPrefAndRefresh("nglayout.debug.paint_dumping");
result = nsEventStatus_eConsumeNoDefault;
break;
case VIEWER_TOGGLE_INVALIDATE_DUMPING:
ToggleBoolPrefAndRefresh("nglayout.debug.invalidate_dumping");
result = nsEventStatus_eConsumeNoDefault;
break;
case VIEWER_TOGGLE_EVENT_DUMPING:
ToggleBoolPrefAndRefresh("nglayout.debug.event_dumping");
result = nsEventStatus_eConsumeNoDefault;
break;
case VIEWER_TOGGLE_MOTION_EVENT_DUMPING:
ToggleBoolPrefAndRefresh("nglayout.debug.motion_event_dumping");
result = nsEventStatus_eConsumeNoDefault;
break;
case VIEWER_TOGGLE_CROSSING_EVENT_DUMPING:
ToggleBoolPrefAndRefresh("nglayout.debug.crossing_event_dumping");
result = nsEventStatus_eConsumeNoDefault;
break;

Просмотреть файл

@ -200,7 +200,7 @@ public:
void DumpStyleSheets(FILE *out = stdout);
void DumpStyleContexts(FILE *out = stdout);
void ToggleFrameBorders();
void ToggleFlashPaintArea();
void ToggleBoolPrefAndRefresh(const char * aPrefName);
void ShowContentSize();
void ShowFrameSize(FILE* out = stdout);
void ShowStyleSize();

Просмотреть файл

@ -69,7 +69,13 @@
#define VIEWER_GFX_WIDGET_MODE 40048
#define VIEWER_DISPLAYTEXT 40049
#define VIEWER_DISPLAYHTML 40050
#define VIEWER_FLASH_PAINT_AREA 40051
#define VIEWER_TOGGLE_PAINT_FLASHING 40200
#define VIEWER_TOGGLE_PAINT_DUMPING 40210
#define VIEWER_TOGGLE_INVALIDATE_DUMPING 40220
#define VIEWER_TOGGLE_EVENT_DUMPING 40230
#define VIEWER_TOGGLE_MOTION_EVENT_DUMPING 40240
#define VIEWER_TOGGLE_CROSSING_EVENT_DUMPING 40250
#define VIEWER_SELECT_STYLE_LIST 40500
#define VIEWER_SELECT_STYLE_DEFAULT 40501

Просмотреть файл

@ -81,7 +81,14 @@ GtkItemFactoryEntry menu_items[] =
//#ifdef DEBUG // turning off for now
{ "/_Debug", nsnull, nsnull, 0, "<Branch>" },
{ "/Debug/_Visual Debugging", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_VISUAL_DEBUGGING,nsnull },
{ "/Debug/_Flash Paint Area", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_FLASH_PAINT_AREA,nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Event Debugging/Toggle Paint Flashing", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_PAINT_FLASHING,nsnull },
{ "/Debug/Event Debugging/Toggle Paint Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_PAINT_DUMPING,nsnull },
{ "/Debug/Event Debugging/Toggle Invalidate Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_INVALIDATE_DUMPING,nsnull },
{ "/Debug/Event Debugging/Toggle Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_EVENT_DUMPING,nsnull },
{ "/Debug/Event Debugging/Toggle Motion Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_MOTION_EVENT_DUMPING,nsnull },
{ "/Debug/Event Debugging/Toggle Crossing Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_CROSSING_EVENT_DUMPING,nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/_Reflow Test", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_REFLOW_TEST, nsnull },
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
{ "/Debug/Dump _Content", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_CONTENT, nsnull },

Просмотреть файл

@ -412,7 +412,8 @@ NS_IMETHODIMP nsWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
{
#if 0
printf("nsWidget::Resize %s (%p) to %d %d\n",
mWidget ? gtk_widget_get_name(mWidget) : "(no-widget)", this,
(const char *) debug_GetName(mWidget),
this,
aWidth, aHeight);
#endif
mBounds.width = aWidth;
@ -474,7 +475,7 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY)
nsGUIEvent event;
#if 0
printf("nsWidget::OnMove %s (%p)\n",
mWidget ? gtk_widget_get_name(mWidget) : "(no-widget)",
(const char *) debug_GetName(mWidget),
this);
#endif
InitEvent(event, NS_MOVE);
@ -659,12 +660,6 @@ NS_IMETHODIMP nsWidget::SetCursor(nsCursor aCursor)
return NS_OK;
}
#undef TRACE_INVALIDATE
#ifdef TRACE_INVALIDATE
static PRInt32 sInvalidatePrintCount = 0;
#endif
NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
{
if (!mWidget)
@ -676,17 +671,14 @@ NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
if (!GTK_WIDGET_REALIZED(mWidget) || !GTK_WIDGET_VISIBLE(mWidget))
return NS_ERROR_FAILURE;
#ifdef TRACE_INVALIDATE
GdkWindow * renderWindow = GetRenderWindow();
Window xid = renderWindow ? GDK_WINDOW_XWINDOW(renderWindow) : 0;
printf("%4d nsWidget::Invalidate(this=%p,name=%s,xid=%p,sync=%s)\n",
sInvalidatePrintCount++,
(void *) this,
gtk_widget_get_name(mWidget),
(void *) xid,
aIsSynchronous ? "yes" : "no");
#endif
#ifdef NS_DEBUG
debug_DumpInvalidate(stdout,
this,
nsnull,
aIsSynchronous,
debug_GetName(mWidget),
debug_GetRenderXID(mWidget));
#endif // NS_DEBUG
if (aIsSynchronous) {
::gtk_widget_draw(mWidget, (GdkRectangle *) NULL);
@ -710,21 +702,14 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
if (!GTK_WIDGET_REALIZED(mWidget) || !GTK_WIDGET_VISIBLE(mWidget))
return NS_ERROR_FAILURE;
#ifdef TRACE_INVALIDATE
GdkWindow * renderWindow = GetRenderWindow();
Window xid = renderWindow ? GDK_WINDOW_XWINDOW(renderWindow) : 0;
printf("%4d nsWidget::Invalidate(this=%p,name=%s,xid=%p,sync=%s,rect=%d,%d,%d,%d)\n",
sInvalidatePrintCount++,
(void *) this,
gtk_widget_get_name(mWidget),
(void *) xid,
aIsSynchronous ? "yes" : "no",
aRect.x,
aRect.y,
aRect.width,
aRect.height);
#endif
#ifdef NS_DEBUG
debug_DumpInvalidate(stdout,
this,
&aRect,
aIsSynchronous,
debug_GetName(mWidget),
debug_GetRenderXID(mWidget));
#endif // NS_DEBUG
if (aIsSynchronous)
{
@ -1081,83 +1066,27 @@ PRBool nsWidget::DispatchFocus(nsGUIEvent &aEvent)
//
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//
// Turning TRACE_EVENTS on will cause printfs for all
// mouse events that are dispatched.
//
// These are extra noisy, and thus have their own switch:
//
// NS_MOUSE_MOVE
// NS_PAINT
// NS_MOUSE_ENTER, NS_MOUSE_EXIT
//
//////////////////////////////////////////////////////////////////
#undef TRACE_EVENTS
#undef TRACE_EVENTS_MOTION
#undef TRACE_EVENTS_PAINT
#undef TRACE_EVENTS_CROSSING
#ifdef DEBUG_pavlov
#define EVENT_SPAM
#endif
#if defined(EVENT_SPAM)
#define TRACE_EVENTS 1
#define TRACE_EVENTS_MOTION 1
#define TRACE_EVENTS_PAINT 1
#define TRACE_EVENTS_CROSSING 1
#endif
#ifdef DEBUG
void
nsWidget::DebugPrintEvent(nsGUIEvent & aEvent,
GtkWidget * aGtkWidget)
#ifdef NS_DEBUG
PRInt32
nsWidget::debug_GetRenderXID(GtkWidget * aGtkWidget)
{
#ifndef TRACE_EVENTS_MOTION
if (aEvent.message == NS_MOUSE_MOVE)
{
return;
}
#endif
#ifndef TRACE_EVENTS_PAINT
if (aEvent.message == NS_PAINT)
{
return;
}
#endif
#ifndef TRACE_EVENTS_CROSSING
if (aEvent.message == NS_MOUSE_ENTER || aEvent.message == NS_MOUSE_EXIT)
{
return;
}
#endif
static int sPrintCount=0;
printf("%4d %-26s(this=%-8p , name=%-12s",
sPrintCount++,
(const char *) nsAutoCString(GuiEventToString(aEvent)),
this,
aGtkWidget ? gtk_widget_get_name(aGtkWidget) : "null");
Window win = 0;
GdkWindow * renderWindow = GetRenderWindow(aGtkWidget);
if (aGtkWidget && GTK_WIDGET_REALIZED(aGtkWidget))
{
win = GDK_WINDOW_XWINDOW(aGtkWidget->window);
}
Window xid = renderWindow ? GDK_WINDOW_XWINDOW(renderWindow) : 0x0;
printf(" , xid=%-8p",(void *) win);
printf(" , x=%-3d, y=%d)",aEvent.point.x,aEvent.point.y);
printf("\n");
return (PRInt32) xid;
}
#endif // DEBUG
nsCAutoString
nsWidget::debug_GetName(GtkWidget * aGtkWidget)
{
if (nsnull != aGtkWidget)
return nsCAutoString(gtk_widget_get_name(aGtkWidget));
return nsCAutoString("null");
}
#endif // NS_DEBUG
//////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------
@ -1166,30 +1095,36 @@ nsWidget::DebugPrintEvent(nsGUIEvent & aEvent,
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *event,
NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *aEvent,
nsEventStatus &aStatus)
{
NS_ADDREF(event->widget);
NS_ADDREF(aEvent->widget);
#ifdef TRACE_EVENTS
DebugPrintEvent(*event,mWidget);
#endif
#ifdef NS_DEBUG
GtkWidget * gw = (GtkWidget *) aEvent->widget->GetNativeData(NS_NATIVE_WIDGET);
debug_DumpEvent(stdout,
aEvent->widget,
aEvent,
debug_GetName(gw),
(PRInt32) debug_GetRenderXID(gw));
#endif // NS_DEBUG
if (nsnull != mMenuListener) {
if (NS_MENU_EVENT == event->eventStructType)
aStatus = mMenuListener->MenuSelected(NS_STATIC_CAST(nsMenuEvent&, *event));
if (NS_MENU_EVENT == aEvent->eventStructType)
aStatus = mMenuListener->MenuSelected(NS_STATIC_CAST(nsMenuEvent&, *aEvent));
}
aStatus = nsEventStatus_eIgnore;
if (nsnull != mEventCallback) {
aStatus = (*mEventCallback)(event);
aStatus = (*mEventCallback)(aEvent);
}
// Dispatch to event listener if event was not consumed
if ((aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener)) {
aStatus = mEventListener->ProcessEvent(*event);
aStatus = mEventListener->ProcessEvent(*aEvent);
}
NS_RELEASE(event->widget);
NS_RELEASE(aEvent->widget);
return NS_OK;
}
@ -2333,19 +2268,19 @@ nsWidget::GetWindowForSetBackground()
}
/* virtual */ GdkWindow *
nsWidget::GetRenderWindow()
nsWidget::GetRenderWindow(GtkWidget * aGtkWidget)
{
GdkWindow * renderWindow = nsnull;
if (mWidget)
if (aGtkWidget)
{
if (GTK_IS_LAYOUT(mWidget))
if (GTK_IS_LAYOUT(aGtkWidget))
{
renderWindow = GTK_LAYOUT(mWidget)->bin_window;
renderWindow = GTK_LAYOUT(aGtkWidget)->bin_window;
}
else
{
renderWindow = mWidget->window;
renderWindow = aGtkWidget->window;
}
}

Просмотреть файл

@ -150,7 +150,7 @@ public:
#endif
// Return the Gdk window used for rendering
virtual GdkWindow * GetRenderWindow();
virtual GdkWindow * GetRenderWindow(GtkWidget * aGtkWidget);
protected:
@ -345,8 +345,8 @@ protected:
PRUint32 aEventType);
#ifdef DEBUG
void DebugPrintEvent(nsGUIEvent & aEvent,
GtkWidget * aGtkWidget);
nsCAutoString debug_GetName(GtkWidget * aGtkWidget);
PRInt32 debug_GetRenderXID(GtkWidget * aGtkWidget);
#endif
guint32 mGrabTime;

Просмотреть файл

@ -38,9 +38,6 @@
#include "nsGtkUtils.h" // for nsGtkUtils::gdk_window_flash()
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "stdio.h"
//-------------------------------------------------------------------------
@ -408,9 +405,6 @@ nsresult nsWindow::SetIcon(GdkPixmap *pixmap,
return NS_OK;
}
// Uncommenting this will cause OnPaint() to printf what it is doing
#undef TRACE_PAINT
/**
* Processes an Expose Event
*
@ -418,76 +412,27 @@ nsresult nsWindow::SetIcon(GdkPixmap *pixmap,
PRBool nsWindow::OnPaint(nsPaintEvent &event)
{
nsresult result ;
// call the event callback
if (mEventCallback) {
if (mEventCallback)
{
event.renderingContext = nsnull;
#ifdef TRACE_PAINT
static PRInt32 sPrintCount = 0;
GdkWindow * renderWindow = GetRenderWindow();
Window xid = renderWindow ? GDK_WINDOW_XWINDOW(renderWindow) : 0;
if (event.rect)
{
printf("%4d nsWindow::OnPaint (this=%p,name=%s,xid=%p,rect=%d,%d,%d,%d)\n",
sPrintCount++,
(void *) this,
gtk_widget_get_name(mWidget),
(void *) xid,
event.rect->x,
event.rect->y,
event.rect->width,
event.rect->height);
}
else
{
printf("%4d nsWindow::OnPaint (this=%p,name=%s,xid=%p,rect=none)\n",
sPrintCount++,
(void *) this,
gtk_widget_get_name(mWidget),
(void *) xid);
}
#endif
#ifdef NS_DEBUG
debug_DumpPaintEvent(stdout,
this,
&event,
debug_GetName(mWidget),
(PRInt32) debug_GetRenderXID(mWidget));
#endif // NS_DEBUG
event.renderingContext = GetRenderingContext();
result = DispatchWindowEvent(&event);
#ifdef NS_DEBUG
// The idea here is to create this widget debugging thing
// only once, otherwise we will slow down painting significantly.
//
// However, it will cause wd to leak. It should probably be
// cleaned up in the dll unloading magic
//
// But, its debug only code...
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static nsIPref * sPrefs = nsnull;
PRBool flashing = PR_FALSE;
if (!sPrefs)
if (debug_WantPaintFlashing())
{
nsresult rv = nsServiceManager::GetService(kPrefCID,
NS_GET_IID(nsIPref),
(nsISupports**) &sPrefs);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
}
if (sPrefs)
{
sPrefs->GetBoolPref("nglayout.widget.flash_invalidate_areas",&flashing);
}
//nsServiceManager::ReleaseService(kPrefCID, sPrefs);
if (flashing)
{
GdkWindow * gw = GetRenderWindow();
GdkWindow * gw = GetRenderWindow(mWidget);
if (gw)
{
@ -508,7 +453,7 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event)
nsGtkUtils::gdk_window_flash(gw,1,100000,area);
}
}
#endif
#endif // NS_DEBUG
}
return result;
}
@ -563,7 +508,8 @@ NS_IMETHODIMP nsWindow::Show(PRBool bState)
{
#if 0
printf("nsWidget::Show %s (%p) bState = %i, mWindowType = %i\n",
mWidget ? gtk_widget_get_name(mWidget) : "(no-widget)", this,
(const char *) debug_GetName(mWidget),
this,
bState, mWindowType);
#endif
@ -648,7 +594,8 @@ NS_IMETHODIMP nsWindow::Move(PRInt32 aX, PRInt32 aY)
{
#if 0
printf("nsWindow::Move %s (%p) to %d %d\n",
mWidget ? gtk_widget_get_name(mWidget) : "(no-widget)", this,
(const char *) debug_GetName(mWidget),
this,
aX, aY);
#endif
// not implimented for toplevel windows
@ -692,7 +639,8 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
{
#if 0
printf("nsWindow::Resize %s (%p) to %d %d\n",
mWidget ? gtk_widget_get_name(mWidget) : "(no-widget)", this,
(const char *) debug_GetName(mWidget),
this,
aWidth, aHeight);
#endif

Просмотреть файл

@ -1220,7 +1220,7 @@ nsWindow::DebugPrintEvent(nsGUIEvent & aEvent,
printf("%4d %-26s(this=%-8p , widget=%-8p",
sPrintCount++,
(const char *) nsAutoCString(GuiEventToString(aEvent)),
(const char *) nsAutoCString(debug_GuiEventToString(&aEvent)),
this,
(void *) aWidget);

Просмотреть файл

@ -315,7 +315,7 @@ nsWindow::DebugPrintEvent(nsGUIEvent & aEvent,
printf("%4d %-26s(this=%-8p , HWND=%-8p",
sPrintCount++,
(const char *) nsAutoCString(GuiEventToString(aEvent)),
(const char *) nsAutoCString(debug_GuiEventToString(aEvent)),
this,
aWnd);

Просмотреть файл

@ -951,7 +951,7 @@ nsWidget::DebugPrintEvent(nsGUIEvent & aEvent,
printf("%4d %-26s(this=%-8p , window=%-8p",
sPrintCount++,
(const char *) nsAutoCString(GuiEventToString(aEvent)),
(const char *) nsAutoCString(debug_GuiEventToString(&aEvent)),
this,
(void *) aWindow);

Просмотреть файл

@ -25,6 +25,11 @@
#include "nsGfxCIID.h"
#include "nsWidgetsCID.h"
#ifdef NS_DEBUG
#include "nsIServiceManager.h"
#include "nsIPref.h"
#endif
// nsBaseWidget
NS_IMPL_ISUPPORTS1(nsBaseWidget, nsIWidget)
@ -728,7 +733,8 @@ NS_METHOD nsBaseWidget::SetModal(void)
return NS_ERROR_FAILURE;
}
#ifdef DEBUG
#ifdef NS_DEBUG
//////////////////////////////////////////////////////////////
//
// Convert a GUI event message code to a string.
// Makes it a lot easier to debug events.
@ -737,25 +743,28 @@ NS_METHOD nsBaseWidget::SetModal(void)
// for a DebugPrintEvent() function that uses
// this.
//
nsAutoString
nsBaseWidget::GuiEventToString(nsGUIEvent & aEvent)
//////////////////////////////////////////////////////////////
/* static */ nsAutoString
nsBaseWidget::debug_GuiEventToString(nsGUIEvent * aGuiEvent)
{
nsString eventName = "UNKNOWN";
NS_ASSERTION(nsnull != aGuiEvent,"cmon, null gui event.");
nsAutoString eventName = "UNKNOWN";
#define _ASSIGN_eventName(_value,_name)\
case _value: eventName = _name ; break
switch(aEvent.message)
switch(aGuiEvent->message)
{
_ASSIGN_eventName(NS_BLUR_CONTENT,"NS_BLUR_CONTENT");
_ASSIGN_eventName(NS_CONTROL_CHANGE,"NS_CONTROL_CHANGE");
_ASSIGN_eventName(NS_CREATE,"NS_CREATE");
_ASSIGN_eventName(NS_DESTROY,"NS_DESTROY");
_ASSIGN_eventName(NS_DRAGDROP_GESTURE,"NS_DRAGDROP_GESTURE");
_ASSIGN_eventName(NS_DRAGDROP_DROP,"NS_DRAGDROP_DROP");
_ASSIGN_eventName(NS_DRAGDROP_ENTER,"NS_DRAGDROP_ENTER");
_ASSIGN_eventName(NS_DRAGDROP_EXIT,"NS_DRAGDROP_EXIT");
_ASSIGN_eventName(NS_DRAGDROP_OVER,"NS_DRAGDROP_OVER");
_ASSIGN_eventName(NS_DRAGDROP_GESTURE,"NS_DND_GESTURE");
_ASSIGN_eventName(NS_DRAGDROP_DROP,"NS_DND_DROP");
_ASSIGN_eventName(NS_DRAGDROP_ENTER,"NS_DND_ENTER");
_ASSIGN_eventName(NS_DRAGDROP_EXIT,"NS_DND_EXIT");
_ASSIGN_eventName(NS_DRAGDROP_OVER,"NS_DND_OVER");
_ASSIGN_eventName(NS_FOCUS_CONTENT,"NS_FOCUS_CONTENT");
_ASSIGN_eventName(NS_FORM_SELECTED,"NS_FORM_SELECTED");
_ASSIGN_eventName(NS_FORM_CHANGE,"NS_FORM_CHANGE");
@ -772,19 +781,19 @@ case _value: eventName = _name ; break
_ASSIGN_eventName(NS_MENU_SELECTED,"NS_MENU_SELECTED");
_ASSIGN_eventName(NS_MOUSE_ENTER,"NS_MOUSE_ENTER");
_ASSIGN_eventName(NS_MOUSE_EXIT,"NS_MOUSE_EXIT");
_ASSIGN_eventName(NS_MOUSE_LEFT_BUTTON_DOWN,"NS_MOUSE_LEFT_BUTTON_DOWN");
_ASSIGN_eventName(NS_MOUSE_LEFT_BUTTON_UP,"NS_MOUSE_LEFT_BUTTON_UP");
_ASSIGN_eventName(NS_MOUSE_LEFT_BUTTON_DOWN,"NS_MOUSE_LEFT_BTN_DOWN");
_ASSIGN_eventName(NS_MOUSE_LEFT_BUTTON_UP,"NS_MOUSE_LEFT_BTN_UP");
_ASSIGN_eventName(NS_MOUSE_LEFT_CLICK,"NS_MOUSE_LEFT_CLICK");
_ASSIGN_eventName(NS_MOUSE_LEFT_DOUBLECLICK,"NS_MOUSE_LEFT_DOUBLECLICK");
_ASSIGN_eventName(NS_MOUSE_MIDDLE_BUTTON_DOWN,"NS_MOUSE_MIDDLE_BUTTON_DOWN");
_ASSIGN_eventName(NS_MOUSE_MIDDLE_BUTTON_UP,"NS_MOUSE_MIDDLE_BUTTON_UP");
_ASSIGN_eventName(NS_MOUSE_LEFT_DOUBLECLICK,"NS_MOUSE_LEFT_DBLCLICK");
_ASSIGN_eventName(NS_MOUSE_MIDDLE_BUTTON_DOWN,"NS_MOUSE_MIDDLE_BTN_DOWN");
_ASSIGN_eventName(NS_MOUSE_MIDDLE_BUTTON_UP,"NS_MOUSE_MIDDLE_BTN_UP");
_ASSIGN_eventName(NS_MOUSE_MIDDLE_CLICK,"NS_MOUSE_MIDDLE_CLICK");
_ASSIGN_eventName(NS_MOUSE_MIDDLE_DOUBLECLICK,"NS_MOUSE_MIDDLE_DOUBLECLICK");
_ASSIGN_eventName(NS_MOUSE_MIDDLE_DOUBLECLICK,"NS_MOUSE_MIDDLE_DBLCLICK");
_ASSIGN_eventName(NS_MOUSE_MOVE,"NS_MOUSE_MOVE");
_ASSIGN_eventName(NS_MOUSE_RIGHT_BUTTON_DOWN,"NS_MOUSE_RIGHT_BUTTON_DOWN");
_ASSIGN_eventName(NS_MOUSE_RIGHT_BUTTON_UP,"NS_MOUSE_RIGHT_BUTTON_UP");
_ASSIGN_eventName(NS_MOUSE_RIGHT_BUTTON_DOWN,"NS_MOUSE_RIGHT_BTN_DOWN");
_ASSIGN_eventName(NS_MOUSE_RIGHT_BUTTON_UP,"NS_MOUSE_RIGHT_BTN_UP");
_ASSIGN_eventName(NS_MOUSE_RIGHT_CLICK,"NS_MOUSE_RIGHT_CLICK");
_ASSIGN_eventName(NS_MOUSE_RIGHT_DOUBLECLICK,"NS_MOUSE_RIGHT_DOUBLECLICK");
_ASSIGN_eventName(NS_MOUSE_RIGHT_DOUBLECLICK,"NS_MOUSE_RIGHT_DBLCLICK");
_ASSIGN_eventName(NS_MOVE,"NS_MOVE");
_ASSIGN_eventName(NS_PAGE_LOAD,"NS_PAGE_LOAD");
_ASSIGN_eventName(NS_PAGE_UNLOAD,"NS_PAGE_UNLOAD");
@ -792,11 +801,11 @@ case _value: eventName = _name ; break
_ASSIGN_eventName(NS_MENU_CREATE,"NS_MENU_CREATE");
_ASSIGN_eventName(NS_MENU_DESTROY,"NS_MENU_DESTROY");
_ASSIGN_eventName(NS_MENU_ACTION, "NS_MENU_ACTION");
_ASSIGN_eventName(NS_SCROLLBAR_LINE_NEXT,"NS_SCROLLBAR_LINE_NEXT");
_ASSIGN_eventName(NS_SCROLLBAR_LINE_PREV,"NS_SCROLLBAR_LINE_PREV");
_ASSIGN_eventName(NS_SCROLLBAR_PAGE_NEXT,"NS_SCROLLBAR_PAGE_NEXT");
_ASSIGN_eventName(NS_SCROLLBAR_PAGE_PREV,"NS_SCROLLBAR_PAGE_PREV");
_ASSIGN_eventName(NS_SCROLLBAR_POS,"NS_SCROLLBAR_POS");
_ASSIGN_eventName(NS_SCROLLBAR_LINE_NEXT,"NS_SB_LINE_NEXT");
_ASSIGN_eventName(NS_SCROLLBAR_LINE_PREV,"NS_SB_LINE_PREV");
_ASSIGN_eventName(NS_SCROLLBAR_PAGE_NEXT,"NS_SB_PAGE_NEXT");
_ASSIGN_eventName(NS_SCROLLBAR_PAGE_PREV,"NS_SB_PAGE_PREV");
_ASSIGN_eventName(NS_SCROLLBAR_POS,"NS_SB_POS");
_ASSIGN_eventName(NS_SIZE,"NS_SIZE");
#undef _ASSIGN_eventName
@ -805,13 +814,209 @@ case _value: eventName = _name ; break
{
char buf[32];
sprintf(buf,"UNKNOWN: %d",aEvent.message);
sprintf(buf,"UNKNOWN: %d",aGuiEvent->message);
eventName = buf;
}
break;
}
return nsAutoString(eventName);
}
#endif
//////////////////////////////////////////////////////////////
//
// The idea here is to get the prefs service once and cache it.
// The reason being that this code gets called from OnPaint()
// which we dont want to slow down.
//
// So, gPrefs will leak when the beast shutdowns.
//
// debug_CleanupCrapSoThatBruceAndPurifyAreHappy() can be called from
// the widget dll unloading hook to cleanup...
//
// But then again, its only debug code, so...
//
//////////////////////////////////////////////////////////////
static nsIPref * gPrefs = nsnull;
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static nsIPref *
_GetPrefService()
{
if (!gPrefs)
{
nsresult rv = nsServiceManager::GetService(kPrefCID,
NS_GET_IID(nsIPref),
(nsISupports**) &gPrefs);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
NS_ASSERTION(nsnull != gPrefs,"Prefs services is null.");
}
return gPrefs;
}
//////////////////////////////////////////////////////////////
static PRBool
_GetBoolPref(const char * aPrefName)
{
NS_ASSERTION(nsnull != aPrefName,"cmon, pref name is null.");
PRBool value = PR_FALSE;
nsIPref * prefs = _GetPrefService();
if (prefs)
prefs->GetBoolPref(aPrefName,&value);
return value;
}
//////////////////////////////////////////////////////////////
static PRInt32
_GetPrintCount()
{
static PRInt32 sCount = 0;
return ++sCount;
}
//////////////////////////////////////////////////////////////
/* static */ PRBool
nsBaseWidget::debug_WantPaintFlashing()
{
return _GetBoolPref("nglayout.debug.paint_flashing");
}
//////////////////////////////////////////////////////////////
/* static */ void
nsBaseWidget::debug_DumpEvent(FILE * aFileOut,
nsIWidget * aWidget,
nsGUIEvent * aGuiEvent,
const nsCAutoString & aWidgetName,
PRInt32 aWindowID)
{
// NS_PAINT is handled by debug_DumpPaintEvent()
if (aGuiEvent->message == NS_PAINT)
return;
if (aGuiEvent->message == NS_MOUSE_MOVE)
{
if (!_GetBoolPref("nglayout.debug.motion_event_dumping"))
return;
}
if (aGuiEvent->message == NS_MOUSE_ENTER ||
aGuiEvent->message == NS_MOUSE_EXIT)
{
if (!_GetBoolPref("nglayout.debug.crossing_event_dumping"))
return;
}
if (!_GetBoolPref("nglayout.debug.event_dumping"))
return;
fprintf(aFileOut,
"%4d %-26s widget=%-8p name=%-12s id=%-8p pos=%d,%d\n",
_GetPrintCount(),
(const char *) nsCAutoString(debug_GuiEventToString(aGuiEvent)),
(void *) aWidget,
(const char *) aWidgetName,
(void *) (aWindowID ? aWindowID : 0x0),
aGuiEvent->point.x,
aGuiEvent->point.y);
}
//////////////////////////////////////////////////////////////
/* static */ void
nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut,
nsIWidget * aWidget,
nsPaintEvent * aPaintEvent,
const nsCAutoString & aWidgetName,
PRInt32 aWindowID)
{
NS_ASSERTION(nsnull != aFileOut,"cmon, null output FILE");
NS_ASSERTION(nsnull != aWidget,"cmon, the widget is null");
NS_ASSERTION(nsnull != aPaintEvent,"cmon, the paint event is null");
if (!_GetBoolPref("nglayout.debug.paint_dumping"))
return;
fprintf(aFileOut,
"%4d PAINT widget=%p name=%-12s id=%-8p rect=",
_GetPrintCount(),
(void *) aWidget,
(const char *) aWidgetName,
(void *) aWindowID);
if (aPaintEvent->rect)
{
fprintf(aFileOut,
"%3d,%-3d %3d,%-3d",
aPaintEvent->rect->x,
aPaintEvent->rect->y,
aPaintEvent->rect->width,
aPaintEvent->rect->height);
}
else
{
fprintf(aFileOut,"none");
}
fprintf(aFileOut,"\n");
}
//////////////////////////////////////////////////////////////
/* static */ void
nsBaseWidget::debug_DumpInvalidate(FILE * aFileOut,
nsIWidget * aWidget,
const nsRect * aRect,
PRBool aIsSynchronous,
const nsCAutoString & aWidgetName,
PRInt32 aWindowID)
{
if (!_GetBoolPref("nglayout.debug.invalidate_dumping"))
return;
NS_ASSERTION(nsnull != aFileOut,"cmon, null output FILE");
NS_ASSERTION(nsnull != aWidget,"cmon, the widget is null");
fprintf(aFileOut,
"%4d Invalidate widget=%p name=%-12s id=%-8p",
_GetPrintCount(),
(void *) aWidget,
(const char *) aWidgetName,
(void *) aWindowID);
if (aRect)
{
fprintf(aFileOut,
" rect=%3d,%-3d %3d,%-3d",
aRect->x,
aRect->y,
aRect->width,
aRect->height);
}
else
{
fprintf(aFileOut,
" rect=%-15s",
"none");
}
fprintf(aFileOut,
" sync=%s",
(const char *) (aIsSynchronous ? "yes" : "no "));
fprintf(aFileOut,"\n");
}
//////////////////////////////////////////////////////////////
/* static */ void
nsBaseWidget::debug_CleanupCrapSoThatBruceAndPurifyAreHappy()
{
if (gPrefs)
{
nsServiceManager::ReleaseService(kPrefCID, gPrefs);
gPrefs = nsnull;
}
}
//////////////////////////////////////////////////////////////
#endif // NS_DEBUG

Просмотреть файл

@ -89,6 +89,7 @@ public:
NS_IMETHOD EnableDragDrop(PRBool aEnable);
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
virtual void FreeNativeData(void * data, PRUint32 aDataType) {}//~~~
protected:
virtual void DrawScaledRect(nsIRenderingContext& aRenderingContext,
@ -162,8 +163,32 @@ protected:
CREATE_HACK
};
#ifdef DEBUG
static nsAutoString GuiEventToString(nsGUIEvent & aEvent);
#ifdef NS_DEBUG
protected:
static nsAutoString debug_GuiEventToString(nsGUIEvent * aGuiEvent);
static PRBool debug_WantPaintFlashing();
static void debug_DumpInvalidate(FILE * aFileOut,
nsIWidget * aWidget,
const nsRect * aRect,
PRBool aIsSynchronous,
const nsCAutoString & aWidgetName,
PRInt32 aWindowID);
static void debug_DumpEvent(FILE * aFileOut,
nsIWidget * aWidget,
nsGUIEvent * aGuiEvent,
const nsCAutoString & aWidgetName,
PRInt32 aWindowID);
static void debug_DumpPaintEvent(FILE * aFileOut,
nsIWidget * aWidget,
nsPaintEvent * aPaintEvent,
const nsCAutoString & aWidgetName,
PRInt32 aWindowID);
public:
static void debug_CleanupCrapSoThatBruceAndPurifyAreHappy();
#endif
};