if (IsScrollingEnabled()) return ScrollFrameIntoView(aFrame, NS_PRESSHELL_SCROLL_ANYWHERE, NS_PRESSHELL_SCROLL_ANYWHERE);
nsRect  frameBounds; aFrame->GetRect(frameBounds); nsPoint offset; nsIView* closestView; aFrame->GetOffsetFromView(mPresContext, offset, &closestView); frameBounds.MoveTo(offset);    nsCOMPtr<nsIAtom> frameType; nsIFrame *prevFrame = aFrame; nsIFrame *frame = aFrame;  while (frame && (frame->GetFrameType(getter_AddRefs(frameType)), frameType == nsLayoutAtoms::inlineFrame)) { prevFrame = frame; prevFrame->GetParent(&frame); }  if (frame != aFrame && frame && frameType == nsLayoutAtoms::blockFrame) {  nsCOMPtr<nsILineIterator> lines( do_QueryInterface(frame) );  if (lines) { PRInt32 index = -1; lines->FindLineContaining(prevFrame, &index); if (index >= 0) { nsIFrame *trash1; PRInt32 trash2; nsRect lineBounds; PRUint32 trash3;  if (NS_SUCCEEDED(lines->GetLine(index, &trash1, &trash2, lineBounds, &trash3))) { nsPoint blockOffset; nsIView* blockView; frame->GetOffsetFromView(mPresContext, blockOffset, &blockView);  if (blockView == closestView) {  nscoord newoffset = lineBounds.y + blockOffset.y;  if (newoffset < frameBounds.y) frameBounds.y = newoffset; } } } } }  #ifdef DEBUG if (closestView) { nsIScrollableView* _testView = nsnull; CallQueryInterface(closestView, &_testView); NS_ASSERTION(!_testView, "What happened to the scrolled view?  " "The frame should not be directly in the scrolling view!"); } #endif     nsIScrollableView* scrollingView = nsnull; while (closestView) { nsIView* parent; closestView->GetParent(parent); if (parent) { CallQueryInterface(parent, &scrollingView); if (scrollingView) { ScrollViewToShowRect(scrollingView, frameBounds, aVPercent, aHPercent); } } nscoord x, y; closestView->GetPosition(&x, &y); frameBounds.MoveBy(x, y); closestView = parent; }
PresShell::ScrollFrameIntoView(nsIFrame *aFrame){  if (!aFrame)    return NS_ERROR_NULL_POINTER;    if (IsScrollingEnabled())    return ScrollFrameIntoView(aFrame, NS_PRESSHELL_SCROLL_ANYWHERE,                               NS_PRESSHELL_SCROLL_ANYWHERE);  return NS_OK;}