diff = rect.x + rect.width;
diff = rect.x + rect.width/2;
NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(PRInt32 dindexes){    nsIScrollableView* scrollableView = GetScrollableView();    if (!scrollableView)       return NS_ERROR_FAILURE;    // get our box    nsIFrame* frame = GetFrame();    nsIBox* box;    CallQueryInterface(frame, &box);    nsRect rect;    nsIBox* scrolledBox;    nsIBox* child;    // get the scrolled box    box->GetChildBox(&scrolledBox);    // now get the scrolled boxes first child.    scrolledBox->GetChildBox(&child);    PRBool horiz = PR_FALSE;    scrolledBox->GetOrientation(horiz);    nsPoint cp;    scrollableView->GetScrollPosition(cp.x,cp.y);    nscoord diff = 0;    PRInt32 curIndex = 0;    // first find out what index we are currently at    while(child) {      child->GetBounds(rect);      if (horiz) {        diff = rect.x + rect.width;        if (diff > cp.x) {          break;        }      } else {        diff = rect.y + rect.height;        if (diff > cp.y) {          break;        }      }      child->GetNextBox(&child);      curIndex++;    }    PRInt32 count = 0;    if (dindexes == 0)       return NS_OK;    if (dindexes > 0) {      while(child) {        child->GetNextBox(&child);        if (child)          child->GetBounds(rect);        count++;        if (count >= dindexes)          break;      }   } else if (dindexes < 0) {      scrolledBox->GetChildBox(&child);      while(child) {        child->GetBounds(rect);        if (count >= curIndex + dindexes)          break;        count++;        child->GetNextBox(&child);      }   }   if (horiz)       return scrollableView->ScrollTo(rect.x, cp.y, NS_SCROLL_PROPERTY_ALWAYS_BLIT);   else       return scrollableView->ScrollTo(cp.x, rect.y, NS_SCROLL_PROPERTY_ALWAYS_BLIT);}