rem: var selCon = getBrowser().docShell .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsISelectionDisplay) .QueryInterface(Components.interfaces.nsISelectionController); 
context: function goToLine(line){  var viewsource = window._content.document.body;  //  // The source document is made up of a number of pre elements with  // id attributes in the format <pre id="line123">, meaning that  // the first line in the pre element is number 123.  // Do binary search to find the pre element containing the line.  //  var pre, curLine;  for (var lbound = 0, ubound = viewsource.childNodes.length; ; ) {    var middle = (lbound + ubound) >> 1;    pre = viewsource.childNodes[middle];    curLine = parseInt(pre.id.substring(4));    if (lbound == ubound - 1) {      break;    }    if (line >= curLine) {      lbound = middle;    } else {      ubound = middle;    }  }  var range = null;  //  // Walk through each of the text nodes and count newlines.  //  var treewalker = document.createTreeWalker(pre, NodeFilter.SHOW_TEXT, null, false);  for (var textNode = treewalker.firstChild();       textNode && curLine <= line + 1;       textNode = treewalker.nextNode()) {        //    // \r is not a valid character in the DOM, so we only check for \n.    //    var lineArray = textNode.data.split(/\n/);    var lastLineInNode = curLine + lineArray.length - 1;    if (lastLineInNode < line) {      curLine = lastLineInNode;      continue;    }    for (var i = 0, curPos = 0;          i < lineArray.length;         curPos += lineArray[i++].length + 1) {      if (i > 0) {        curLine++;      }      if (curLine == line && !range) {        range = document.createRange();        range.setStart(textNode, curPos);        //        // This will always be overridden later, except when we look for        // the very last line in the file (this is the only line that does         // not end with \n).        //        range.setEndAfter(pre.lastChild);      } else if (curLine == line + 1) {        range.setEnd(textNode, curPos);        curLine++;        break;      }    }  }  if (!range) {    return false;  }  var selection = window._content.getSelection();  selection.removeAllRanges();  var selCon = getBrowser().docShell    .QueryInterface(Components.interfaces.nsIInterfaceRequestor)    .getInterface(Components.interfaces.nsISelectionDisplay)    .QueryInterface(Components.interfaces.nsISelectionController);  selCon.setDisplaySelection(    Components.interfaces.nsISelectionController.SELECTION_ON);  selCon.setCaretEnabled(true);  // In our case, the range's startOffset is after "\n" on the previous line.  // Set "hintright" to tune the selection at the beginning of the next line.  selection.QueryInterface(Components.interfaces.nsISelectionPrivate)    .interlinePosition = true;	  selection.addRange(range);  // If it is a blank line, collapse to make the caret show up.  // (work-around to bug 156175)  if (range.endContainer == range.startContainer &&      range.endOffset - range.startOffset == 1) {    // note: by construction, there is just a "\n" in-bewteen    selection.collapseToStart();  }  // Scroll the beginning of the line into view.  selCon.scrollSelectionIntoView(    Components.interfaces.nsISelectionController.SELECTION_NORMAL,    Components.interfaces.nsISelectionController.SELECTION_ANCHOR_REGION,    true);  gLastLineFound = line;  return true;}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/d5a503c05033f3db953ac392a54ed472b07da30e/viewsource.js/buggy/suite/browser/viewsource.js