rem: var treewalker = window._content.document 
add: var treewalker = window.content.document 
context: function findLocation(pre, line, node, offset, interlinePosition, result){  if (node && !pre) {    //    // Look upwards to find the current pre element.    //    for (pre = node;         pre.nodeName != "PRE";         pre = pre.parentNode);  }  //  // 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.  //  var curLine = parseInt(pre.id.substring(4));  //  // Walk through each of the text nodes and count newlines.  //  var treewalker = window._content.document      .createTreeWalker(pre, NodeFilter.SHOW_TEXT, null, false);  //  // The column number of the first character in the current text node.  //  var firstCol = 1;  var found = false;  for (var textNode = treewalker.firstChild();       textNode && !found;       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;    //    // Check if we can skip the text node without further inspection.    //    if (node ? (textNode != node) : (lastLineInNode < line)) {      if (lineArray.length > 1) {        firstCol = 1;      }      firstCol += lineArray[lineArray.length - 1].length;      curLine = lastLineInNode;      continue;    }    //    // curPos is the offset within the current text node of the first    // character in the current line.    //    for (var i = 0, curPos = 0;         i < lineArray.length;         curPos += lineArray[i++].length + 1) {      if (i > 0) {        curLine++;      }      if (node) {        if (offset >= curPos && offset <= curPos + lineArray[i].length) {          //          // If we are right after the \n of a line and interlinePosition is          // false, the caret looks as if it were at the end of the previous          // line, so we display that line and column instead.          //          if (i > 0 && offset == curPos && !interlinePosition) {            result.line = curLine - 1;            var prevPos = curPos - lineArray[i - 1].length;            result.col = (i == 1 ? firstCol : 1) + offset - prevPos;          } else {            result.line = curLine;            result.col = (i == 0 ? firstCol : 1) + offset - curPos;          }          found = true;          break;        }      } else {        if (curLine == line && !("range" in result)) {          result.range = document.createRange();          result.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).          //          result.range.setEndAfter(pre.lastChild);        } else if (curLine == line + 1) {          result.range.setEnd(textNode, curPos - 1);          found = true;          break;        }      }    }  }  return found;}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/2d615b33f1278e79940a8b238593a0fe94b879a0/viewsource.js/buggy/suite/browser/viewsource.js