White-space, bracing, and 80th column style fixes, r=self.

This commit is contained in:
brendan%mozilla.org 2003-03-25 01:38:53 +00:00
Родитель 7043a365ea
Коммит c92b2cbbb3
1 изменённых файлов: 463 добавлений и 458 удалений

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

@ -116,8 +116,7 @@ static PRLogModuleInfo *event_lm = NULL;
** EventQueueType -- Defines notification type for an event queue
**
*/
typedef enum
{
typedef enum {
EventQueueIsNative = 1,
EventQueueIsMonitored = 2
} EventQueueType;
@ -333,8 +332,7 @@ PL_PostEvent(PLEventQueue* self, PLEvent* event)
PR_APPEND_LINK(&event->link, &self->queue);
}
if ( self->type == EventQueueIsNative && !self->notified )
{
if (self->type == EventQueueIsNative && !self->notified) {
err = _pl_NativeNotify(self);
if (err != PR_SUCCESS)
@ -349,7 +347,6 @@ PL_PostEvent(PLEventQueue* self, PLEvent* event)
*/
err = PR_Notify(mon);
error:
PR_ExitMonitor(mon);
return err;
@ -378,7 +375,7 @@ PL_PostSynchronousEvent(PLEventQueue* self, PLEvent* event)
PL_PostEvent(self, event);
/* We need to temporarily give up our event queue monitor if
/* We need temporarily to give up our event queue monitor if
we're holding it, otherwise, the thread we're going to wait
for notification from won't be able to enter it to process
the event. */
@ -389,8 +386,10 @@ PL_PostSynchronousEvent(PLEventQueue* self, PLEvent* event)
event->handled = PR_FALSE;
while (!event->handled)
PR_WaitCondVar(event->condVar, PR_INTERVAL_NO_TIMEOUT); /* wait for event to be handled or destroyed */
while (!event->handled) {
/* wait for event to be handled or destroyed */
PR_WaitCondVar(event->condVar, PR_INTERVAL_NO_TIMEOUT);
}
if (entryCount) {
for (i = 0; i < entryCount; i++)
@ -421,8 +420,7 @@ PL_GetEvent(PLEventQueue* self)
PR_EnterMonitor(self->monitor);
if (!PR_CLIST_IS_EMPTY(&self->queue))
{
if (!PR_CLIST_IS_EMPTY(&self->queue)) {
if ( self->type == EventQueueIsNative &&
self->notified &&
!self->processingEvents &&
@ -431,7 +429,8 @@ PL_GetEvent(PLEventQueue* self)
err = _pl_AcknowledgeNativeNotify(self);
self->notified = PR_FALSE;
}
if (err) goto done;
if (err)
goto done;
/* then grab the event and return it: */
event = PR_EVENT_PTR(self->queue.next);
@ -596,17 +595,14 @@ PL_ProcessPendingEvents(PLEventQueue* self)
PR_EnterMonitor(self->monitor);
if (self->type == EventQueueIsNative)
{
if (self->type == EventQueueIsNative) {
count = _pl_GetEventCount(self);
if (count <= 0)
{
if (count <= 0) {
_pl_AcknowledgeNativeNotify(self);
self->notified = PR_FALSE;
}
else
{
else {
_pl_NativeNotify(self);
self->notified = PR_TRUE;
}
@ -660,7 +656,7 @@ PL_HandleEvent(PLEvent* self)
/* This event better not be on an event queue anymore. */
PR_ASSERT(PR_CLIST_IS_EMPTY(&self->link));
result = (*self->handler)(self);
result = self->handler(self);
if (NULL != self->synchronousResult) {
PR_Lock(self->lock);
self->synchronousResult = result;
@ -697,7 +693,7 @@ PL_DestroyEvent(PLEvent* self)
printf("$$$ running avg (%d) \n", PR_IntervalToMilliseconds(s_totalTime/s_eventCount));
#endif
(*self->destructor)(self);
self->destructor(self);
}
PR_IMPLEMENT(void)
@ -735,7 +731,8 @@ PL_DequeueEvent(PLEvent* self, PLEventQueue* queue)
}
PR_IMPLEMENT(void)
PL_FavorPerformanceHint(PRBool favorPerformanceOverEventStarvation, PRUint32 starvationDelay)
PL_FavorPerformanceHint(PRBool favorPerformanceOverEventStarvation,
PRUint32 starvationDelay)
{
#if defined(_WIN32)
@ -977,8 +974,8 @@ static void _md_DetermineOSType()
}
}
static PRUint32 _md_GetPaintStarvationLimit() {
static PRUint32 _md_GetPaintStarvationLimit()
{
if (! _md_IsOSSet) {
_md_DetermineOSType();
_md_IsOSSet = PR_TRUE;
@ -992,16 +989,18 @@ static PRUint32 _md_GetPaintStarvationLimit() {
}
/* Determine if an event is being starved (i.e the starvation limit has
/*
* Determine if an event is being starved (i.e the starvation limit has
* been exceeded.
* Note: this function uses the current setting and updates
* the contents of the wasPending and lastTime arguments
* Note: this function uses the current setting and updates the contents
* of the wasPending and lastTime arguments
*
* ispending: PR_TRUE if the event is currently pending
* starvationLimit: Threshold defined in milliseconds for determining when the event
* has been held in the queue too long
* wasPending: PR_TRUE if the last time _md_EventIsStarved was called the event was pending.
* This value is updated within this function.
* starvationLimit: Threshold defined in milliseconds for determining when
* the event has been held in the queue too long
* wasPending: PR_TRUE if the last time _md_EventIsStarved was called
* the event was pending. This value is updated within
* this function.
* lastTime: Holds the last time the event was in the queue.
* This value is updated within this function
* returns: PR_TRUE if the event is starved, PR_FALSE otherwise
@ -1011,12 +1010,12 @@ static PRBool _md_EventIsStarved(PRBool isPending, PRUint32 starvationLimit,
PRBool *wasPending, PRUint32 *lastTime,
PRUint32 currentTime)
{
if ((*wasPending) && (isPending)) {
/* It was pending previously and the event is still
if (*wasPending && isPending) {
/*
* It was pending previously and the event is still
* pending so check to see if the elapsed time is
* over the limit which indicates the event was starved
*/
if ((currentTime - *lastTime) > starvationLimit) {
return PR_TRUE; /* pending and over the limit */
}
@ -1025,7 +1024,8 @@ static PRBool _md_EventIsStarved(PRBool isPending, PRUint32 starvationLimit,
}
if (isPending) {
/* was_pending must be false so record the current time
/*
* was_pending must be false so record the current time
* so the elapsed time can be computed the next time this
* function is called
*/
@ -1043,8 +1043,8 @@ static PRBool _md_EventIsStarved(PRBool isPending, PRUint32 starvationLimit,
static PRBool _md_IsInputPending(WORD qstatus)
{
/* Return immediately there aren't any pending input or paints. */
if (qstatus == 0) {
/* return immediately there isn't any pending input or paints */
return PR_FALSE;
}
@ -1055,7 +1055,8 @@ static PRBool _md_IsInputPending(WORD qstatus)
return PR_TRUE;
}
/* Mouse moves need extra processing to determine if the mouse
/*
* Mouse moves need extra processing to determine if the mouse
* pointer actually changed location because Windows automatically
* generates WM_MOVEMOVE events when a new window is created which
* we need to filter out.
@ -1101,34 +1102,52 @@ _pl_NativeNotify(PLEventQueue* self)
qstatus = HIWORD(GetQueueStatus(QS_INPUT | QS_PAINT));
/* Check for starved input */
if (_md_EventIsStarved( _md_IsInputPending(qstatus), INPUT_STARVATION_LIMIT,
&_md_WasInputPending, &_md_InputTime, now )) {
/* Use timer for notification. Timers have the lowest priority. They are not processed
* until all other events have been processed. This allows the starved paints and input to
* be processed
if (_md_EventIsStarved( _md_IsInputPending(qstatus),
INPUT_STARVATION_LIMIT,
&_md_WasInputPending,
&_md_InputTime,
now )) {
/*
* Use a timer for notification. Timers have the lowest priority.
* They are not processed until all other events have been processed.
* This allows any starved paints and input to be processed.
*/
SetTimer(self->eventReceiverWindow, TIMER_ID, 0 ,_md_TimerProc);
self->timerSet = PR_TRUE;
/* Clear out any pending paint, _md_WasInputPending was cleared in _md_EventIsStarved */
/*
* Clear any pending paint. _md_WasInputPending was cleared in
* _md_EventIsStarved.
*/
_md_WasPaintPending = PR_FALSE;
return PR_SUCCESS;
}
if (_md_EventIsStarved( (qstatus & QS_PAINT), _md_GetPaintStarvationLimit(),
&_md_WasPaintPending, &_md_PaintTime, now) ) {
/* Use timer for notification. Timers have the lowest priority. They are not processed
* until all other events have been processed. This allows the starved paints and input to
* be processed
if (_md_EventIsStarved( (qstatus & QS_PAINT),
_md_GetPaintStarvationLimit(),
&_md_WasPaintPending,
&_md_PaintTime,
now) ) {
/*
* Use a timer for notification. Timers have the lowest priority.
* They are not processed until all other events have been processed.
* This allows any starved paints and input to be processed
*/
SetTimer(self->eventReceiverWindow, TIMER_ID, 0 ,_md_TimerProc);
self->timerSet = PR_TRUE;
/* Clear out any pending input, _md_WasPaintPending was cleared in _md_EventIsStarved */
/*
* Clear any pending input. _md_WasPaintPending was cleared in
* _md_EventIsStarved.
*/
_md_WasInputPending = PR_FALSE;
return PR_SUCCESS;
}
/* Nothing is being starved so post a message instead of using a timer
* Posted messages are processed before other messages so they have the highest priority.
/*
* Nothing is being starved so post a message instead of using a timer.
* Posted messages are processed before other messages so they have the
* highest priority.
*/
#endif
PostMessage( self->eventReceiverWindow, _pr_PostEventMsgId,
@ -1159,10 +1178,7 @@ _pl_NativeNotify(PLEventQueue* self)
("_pl_NativeNotify: self=%p efn=%d",
self, self->efn));
status = SYS$SETEF(self->efn);
if ($VMS_STATUS_SUCCESS(status))
return PR_SUCCESS;
else
return PR_FAILURE;
return ($VMS_STATUS_SUCCESS(status)) ? PR_SUCCESS : PR_FAILURE;
}/* --- end _pl_NativeNotify() --- */
#elif defined(XP_UNIX) && !defined(XP_MACOSX)
@ -1177,11 +1193,10 @@ _pl_NativeNotify(PLEventQueue* self)
("_pl_NativeNotify: self=%p",
self));
count = write(self->eventPipe[1], buf, 1);
if (count == 1) {
if (count == 1)
return PR_SUCCESS;
} else if ((count == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
if (count == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
return PR_SUCCESS;
} else
return PR_FAILURE;
}/* --- end _pl_NativeNotify() --- */
#endif /* defined(XP_UNIX) && !defined(XP_MACOSX) */
@ -1280,11 +1295,10 @@ _pl_AcknowledgeNativeNotify(PLEventQueue* self)
self));
/* consume the byte NativeNotify put in our pipe: */
count = read(self->eventPipe[0], &c, 1);
if ((count == 1) && (c == NOTIFY_TOKEN)) {
if ((count == 1) && (c == NOTIFY_TOKEN))
return PR_SUCCESS;
} else if ((count == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
if ((count == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
return PR_SUCCESS;
} else
return PR_FAILURE;
#else
@ -1316,11 +1330,8 @@ PR_IMPLEMENT(PRBool)
PL_IsQueueOnCurrentThread( PLEventQueue *queue )
{
PRThread *me = PR_GetCurrentThread();
if ( me == queue->handlerThread )
return PR_TRUE;
else
return PR_FALSE;
} /* end PL_IsQueueOnCurrentThread() */
return me == queue->handlerThread;
}
PR_EXTERN(PRBool)
PL_IsQueueNative(PLEventQueue *queue)
@ -1405,11 +1416,8 @@ static PRStatus InitEventLib( void )
PR_ASSERT( initLock == NULL );
initLock = PR_NewLock();
if ( NULL == initLock )
return PR_FAILURE;
else
return PR_SUCCESS;
} /* end InitWinEventLib() */
return initLock ? PR_SUCCESS : PR_FAILURE;
}
#endif /* Win32, OS2 */
@ -1656,29 +1664,26 @@ PL_ProcessEventsBeforeID(PLEventQueue *aSelf, unsigned long aID)
break;
PR_LOG(event_lm, PR_LOG_DEBUG, ("$$$ processing event %ld\n",
event->id));
if (event->id < aID) {
if (event->id >= aID) {
PR_LOG(event_lm, PR_LOG_DEBUG, ("$$$ skipping event and breaking"));
break;
}
event = PL_GetEvent(aSelf);
PL_HandleEvent(event);
PR_LOG(event_lm, PR_LOG_DEBUG, ("$$$ done processing event"));
count++;
}
else {
PR_LOG(event_lm, PR_LOG_DEBUG, ("$$$ skipping event and breaking"));
break;
}
}
PR_EnterMonitor(aSelf->monitor);
/* if full count still had items left then there's still items left
in the queue. Let the native notify token stay. */
if (aSelf->type == EventQueueIsNative)
{
if (aSelf->type == EventQueueIsNative) {
fullCount = _pl_GetEventCount(aSelf);
if (fullCount <= 0)
{
if (fullCount <= 0) {
_pl_AcknowledgeNativeNotify(aSelf);
aSelf->notified = PR_FALSE;
}