if (hcontent == aContent || vcontent == aContent) { nscoord x = 0; nscoord y = 0;
x = value.ToInteger(&error); }
nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext,                                              nsIContent*     aContent,                                              PRInt32         aModType){  NS_ASSERTION(aContent, "aContent must not be null");  // Attribute changes on the scrollbars happen in one of three ways:  // 1) The scrollbar changed the attribute in response to some user event  // 2) We changed the attribute in response to a ScrollPositionDidChange  // callback from the scrolling view  // 3) We changed the attribute to adjust the scrollbars for the start  // of a smooth scroll operation  //  // In case 2), we don't need to scroll the view because the scrolling  // has already happened. In case 3) we don't need to scroll because  // we're just adjusting the scrollbars back to the correct setting  // for the view.  //   // We used to detect this case implicitly because we'd compare the  // scrollbar attributes with the view's current scroll position and  // bail out if they were equal. But that approach is fragile; it can  // fail when, for example, the view scrolls horizontally and  // vertically simultaneously; we'll get here when only the vertical  // attribute has been set, so the attributes and the view scroll  // position don't yet agree, and we'd tell the view to scroll to the  // new vertical position and the old horizontal position! Even worse  // things could happen when smooth scrolling got involved ... crashes  // and other terrors.  if (mViewInitiatedScroll || mFrameInitiatedScroll) return NS_OK;     nsIFrame* hframe = nsnull;     if (mHScrollbarBox)       mHScrollbarBox->GetFrame(&hframe);     nsIFrame* vframe = nsnull;     if (mVScrollbarBox)       mVScrollbarBox->GetFrame(&vframe);     nsIContent* vcontent = vframe ? vframe->GetContent() : nsnull;     nsIContent* hcontent = hframe ? hframe->GetContent() : nsnull;     if (hcontent == aContent || vcontent == aContent)     {        nscoord x = 0;        nscoord y = 0;        nsAutoString value;        if (hcontent && NS_CONTENT_ATTR_HAS_VALUE == hcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value))        {           PRInt32 error;           // convert it to an integer           x = value.ToInteger(&error);        }        if (vcontent && NS_CONTENT_ATTR_HAS_VALUE == vcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value))        {           PRInt32 error;           // convert it to an integer           y = value.ToInteger(&error);        }        // Make sure the scrollbars indeed moved before firing the event.        // I think it is OK to prevent the call to ScrollbarChanged()        // if we didn't actually move. The following check is the first        // thing ScrollbarChanged() does anyway, before deciding to move         // the scrollbars.         nscoord curPosX=0, curPosY=0;        nsIScrollableView* s = GetScrollableView(mOuter->mPresContext);        if (s) {          s->GetScrollPosition(curPosX, curPosY);          if ((x*mOnePixel) == curPosX && (y*mOnePixel) == curPosY)            return NS_OK;                    PRBool isSmooth = aContent->HasAttr(kNameSpaceID_None, nsXULAtoms::smooth);                  if (isSmooth) {            // Make sure an attribute-setting callback occurs even if the view didn't actually move yet            // We need to make sure other listeners see that the scroll position is not (yet)            // what they thought it was.            s->GetScrollPosition(curPosX, curPosY);            NS_ASSERTION(!mFrameInitiatedScroll, "Unexpected reentry");            // Make sure we don't do anything in when the view calls us back for this            // scroll operation.            mFrameInitiatedScroll = PR_TRUE;            InternalScrollPositionDidChange(curPosX, curPosY);            mFrameInitiatedScroll = PR_FALSE;          }          ScrollbarChanged(mOuter->mPresContext, x*mOnePixel, y*mOnePixel, isSmooth ? NS_VMREFRESH_SMOOTHSCROLL : 0);          // Fire the onScroll event now that we have scrolled          nsIPresShell *presShell = mOuter->mPresContext->GetPresShell();          if (presShell) {            nsScrollbarEvent event(NS_SCROLL_EVENT);            nsEventStatus status = nsEventStatus_eIgnore;            // note if hcontent is non-null then hframe must be non-null.            // likewise for vcontent and vframe. Thus targetFrame will always            // be non-null in here.            nsIFrame* targetFrame =              hcontent == aContent ? hframe : vframe;            presShell->HandleEventWithTarget(&event, targetFrame,                                             aContent,                                             NS_EVENT_FLAG_INIT, &status);          }        }     }   return NS_OK;}