rem:  gSourceContentWindow.setAttribute("oninput", "oninputHTMLSource();"); 
add:  gSourceContentWindow.addEventListener("input", oninputHTMLSource, false); 
context: function SetEditMode(mode){  if (gIsHTMLEditor)  {    var bodyNode = editorShell.editorDocument.getElementsByTagName("body").item(0);    if (!bodyNode)    {      dump("SetEditMode: We don't have a body node!\n");      return;    }    // Switch the UI mode before inserting contents    //   so user can't type in source window while new window is being filled    var previousMode = gEditorDisplayMode;    if (!SetDisplayMode(mode))      return;    if (mode == DisplayModeSource)    {      // Display the DOCTYPE as a non-editable string above edit area      var domdoc;      try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n");}      if (domdoc)      {        var doctypeNode = document.getElementById("doctype-text");        var dt = domdoc.doctype;        if (doctypeNode)        {          if (dt)          {            doctypeNode.removeAttribute("collapsed");            var doctypeText = "<!DOCTYPE " + domdoc.doctype.name;            if (dt.publicId)              doctypeText += " PUBLIC \"" + domdoc.doctype.publicId;            if (dt.systemId)              doctypeText += " "+"\"" + dt.systemId;            doctypeText += "\">"            doctypeNode.setAttribute("value", doctypeText);          }          else            doctypeNode.setAttribute("collapsed", "true");        }      }      // Get the entire document's source string      var flags = gOutputEncodeEntities;      try {         var prettyPrint = gPrefs.GetBoolPref("editor.prettyprint");        if (prettyPrint)          flags |= gOutputFormatted;      } catch (e) {}      var source = editorShell.GetContentsAs("text/html", flags);      var start = source.search(/<html/i);      if (start == -1) start = 0;      gSourceContentWindow.value = source.slice(start);      gSourceContentWindow.focus();      // Set oninput handler so we know if user made any changes      gSourceContentWindow.setAttribute("oninput", "oninputHTMLSource();");      gHTMLSourceChanged = false;    }    else if (previousMode == DisplayModeSource)    {      // Only rebuild document if a change was made in source window      if (gHTMLSourceChanged)      {        editorShell.BeginBatchChanges();        try {          // We are comming from edit source mode,          //   so transfer that back into the document          source = gSourceContentWindow.value;          editorShell.RebuildDocumentFromSource(source);          // Get the text for the <title> from the newly-parsed document          // (must do this for proper conversion of "escaped" characters)          var title = "";          var titlenodelist = window.editorShell.editorDocument.getElementsByTagName("title");          if (titlenodelist)          {            var titleNode = titlenodelist.item(0);            if (titleNode && titleNode.firstChild && titleNode.firstChild.data)              title = titleNode.firstChild.data;          }          if (window.editorShell.editorDocument.title != title)          {            window.editorShell.editorDocument.title = title;            ResetWindowTitleWithFilename();          }          // reset selection to top of doc (wish we could preserve it!)          if (bodyNode)            editorShell.editorSelection.collapse(bodyNode, 0);        } catch (ex) {          dump(ex);        }        editorShell.EndBatchChanges();      }      gHTMLSourceChanged = false;      // Clear out the string buffers      gSourceContentWindow.value = null;      gContentWindow.focus();    }  }}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/5fcd69051503dd6083205beca1fcf5f8bd054e37/editor.js/buggy/editor/ui/composer/content/editor.js