nsSliderFrame::HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { nsIBox* scrollbarBox = GetScrollbar(); nsCOMPtr<nsIContent> scrollbar; scrollbar = GetContentOfBox(scrollbarBox); PRBool isHorizontal = IsHorizontal();  if (isDraggingThumb()) {   mRedrawImmediate = PR_TRUE;  switch (aEvent->message) { case NS_MOUSE_MOVE: { nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this); if (mChange) {    mDestinationPoint = eventPoint; nsRepeatService::GetInstance()->Stop(); nsRepeatService::GetInstance()->Start(mMediator); break; }  nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;  nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);  nsIFrame* thumbFrame = mFrames.FirstChild();   pos -= mDragStart; PRBool isMouseOutsideThumb = PR_FALSE; if (gSnapMultiplier) { nsSize thumbSize = thumbFrame->GetSize(); if (isHorizontal) {    if (eventPoint.y < -gSnapMultiplier * thumbSize.height || eventPoint.y > thumbSize.height + gSnapMultiplier * thumbSize.height) isMouseOutsideThumb = PR_TRUE; } else {  if (eventPoint.x < -gSnapMultiplier * thumbSize.width || eventPoint.x > thumbSize.width + gSnapMultiplier * thumbSize.width) isMouseOutsideThumb = PR_TRUE; } } if (isMouseOutsideThumb) {  SetCurrentPosition(scrollbar, thumbFrame, (int) (mThumbStart / onePixel / mRatio), PR_FALSE); return NS_OK; }    nscoord pospx = pos/onePixel;   pospx = nscoord(pospx/mRatio);   SetCurrentPosition(scrollbar, thumbFrame, pospx, PR_FALSE);  } break;  case NS_MOUSE_MIDDLE_BUTTON_UP: if(!gMiddlePref) break;  case NS_MOUSE_LEFT_BUTTON_UP:   AddListener(); DragThumb(PR_FALSE); if (mChange) { nsRepeatService::GetInstance()->Stop(); mChange = 0; } mRedrawImmediate = PR_FALSE; return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus); }    mRedrawImmediate = PR_FALSE;   return NS_OK; } else if ((aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN && ((nsMouseEvent *)aEvent)->isShift) || (gMiddlePref && aEvent->message == NS_MOUSE_MIDDLE_BUTTON_DOWN)) {  nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this); nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;  nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1); nscoord pospx = pos/onePixel;   nsIFrame* thumbFrame = mFrames.FirstChild(); nsSize thumbSize = thumbFrame->GetSize(); nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height; thumbLength /= onePixel; pospx -= (thumbLength/2);    pospx = nscoord(pospx/mRatio);   SetCurrentPosition(scrollbar, thumbFrame, pospx, PR_FALSE);  DragThumb(PR_TRUE);  if (isHorizontal) mThumbStart = thumbFrame->GetPosition().x; else mThumbStart = thumbFrame->GetPosition().y;  mDragStart = pos - mThumbStart; }      if (aEvent->message == NS_MOUSE_EXIT_SYNTH && mChange) HandleRelease(aPresContext, aEvent, aEventStatus);  return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus); }
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
nsSliderFrame::HandleEvent(nsPresContext* aPresContext,                                      nsGUIEvent* aEvent,                                      nsEventStatus* aEventStatus){  nsIBox* scrollbarBox = GetScrollbar();  nsCOMPtr<nsIContent> scrollbar;  scrollbar = GetContentOfBox(scrollbarBox);  PRBool isHorizontal = IsHorizontal();  if (isDraggingThumb())  {      // we want to draw immediately if the user doing it directly with the      // mouse that makes redrawing much faster.      mRedrawImmediate = PR_TRUE;    switch (aEvent->message) {    case NS_MOUSE_MOVE: {      nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,                                                                         this);      if (mChange) {        // We're in the process of moving the thumb to the mouse,        // but the mouse just moved.  Make sure to update our        // destination point.        mDestinationPoint = eventPoint;        nsRepeatService::GetInstance()->Stop();        nsRepeatService::GetInstance()->Start(mMediator);        break;      }       nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;       nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);       nsIFrame* thumbFrame = mFrames.FirstChild();       // take our current position and substract the start location       pos -= mDragStart;       PRBool isMouseOutsideThumb = PR_FALSE;       if (gSnapMultiplier) {         nsSize thumbSize = thumbFrame->GetSize();         if (isHorizontal) {           // horizontal scrollbar - check if mouse is above or below thumb           // XXXbz what about looking at the .y of the thumb's rect?  Is that           // always zero here?           if (eventPoint.y < -gSnapMultiplier * thumbSize.height ||               eventPoint.y > thumbSize.height +                                gSnapMultiplier * thumbSize.height)             isMouseOutsideThumb = PR_TRUE;         }         else {           // vertical scrollbar - check if mouse is left or right of thumb           if (eventPoint.x < -gSnapMultiplier * thumbSize.width ||               eventPoint.x > thumbSize.width +                                gSnapMultiplier * thumbSize.width)             isMouseOutsideThumb = PR_TRUE;         }       }       if (isMouseOutsideThumb)       {         // XXX see bug 81586         SetCurrentPosition(scrollbar, thumbFrame, (int) (mThumbStart / onePixel / mRatio), PR_FALSE);         return NS_OK;       }       // convert to pixels       nscoord pospx = pos/onePixel;       // convert to our internal coordinate system       pospx = nscoord(pospx/mRatio);       // set it       SetCurrentPosition(scrollbar, thumbFrame, pospx, PR_FALSE);    }    break;    case NS_MOUSE_MIDDLE_BUTTON_UP:    if(!gMiddlePref)        break;    case NS_MOUSE_LEFT_BUTTON_UP:       // stop capturing      //printf("stop capturing\n");      AddListener();      DragThumb(PR_FALSE);      if (mChange) {        nsRepeatService::GetInstance()->Stop();        mChange = 0;      }      mRedrawImmediate = PR_FALSE;//we MUST call nsFrame HandleEvent for mouse ups to maintain the selection state and capture state.      return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);    }    // we want to draw immediately if the user doing it directly with the    // mouse that makes redrawing much faster. Switch it back now.    mRedrawImmediate = PR_FALSE;    //return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);    return NS_OK;  }  else if ((aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN && ((nsMouseEvent *)aEvent)->isShift)      || (gMiddlePref && aEvent->message == NS_MOUSE_MIDDLE_BUTTON_DOWN)) {    // convert coord from twips to pixels    nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,                                                                      this);    nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;    nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);    nscoord pospx = pos/onePixel;   // adjust so that the middle of the thumb is placed under the click    nsIFrame* thumbFrame = mFrames.FirstChild();    nsSize thumbSize = thumbFrame->GetSize();    nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;    thumbLength /= onePixel;    pospx -= (thumbLength/2);    // convert to our internal coordinate system    pospx = nscoord(pospx/mRatio);    // set it    SetCurrentPosition(scrollbar, thumbFrame, pospx, PR_FALSE);    DragThumb(PR_TRUE);    if (isHorizontal)      mThumbStart = thumbFrame->GetPosition().x;    else      mThumbStart = thumbFrame->GetPosition().y;    mDragStart = pos - mThumbStart;  }  // XXX hack until handle release is actually called in nsframe.//  if (aEvent->message == NS_MOUSE_EXIT_SYNTH || aEvent->message == NS_MOUSE_RIGHT_BUTTON_UP || aEvent->message == NS_MOUSE_LEFT_BUTTON_UP)  //   HandleRelease(aPresContext, aEvent, aEventStatus);  if (aEvent->message == NS_MOUSE_EXIT_SYNTH && mChange)     HandleRelease(aPresContext, aEvent, aEventStatus);  return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);}