Bug 827017 Simplify editor click handling r=IanN f=mconley
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sat, 26 Jan 2013 23:56:12 +0000
changeset 11848 5afc408aa274f6fd7a51850f0b69ce7287b91eef
parent 11847 cb616b4ba9b46c9ab928a82b2f6d34f580565e85
child 11849 dcdffce8cf46202d99e0c37f2ea4192adb33fa5d
push id8826
push userneil@parkwaycc.co.uk
push dateSat, 26 Jan 2013 23:58:31 +0000
treeherdercomm-central@dcdffce8cf46 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs827017
Bug 827017 Simplify editor click handling r=IanN f=mconley
editor/ui/composer/content/editor.js
editor/ui/composer/content/editor.xul
mail/components/compose/content/messengercompose.xul
suite/mailnews/compose/messengercompose.xul
--- a/editor/ui/composer/content/editor.js
+++ b/editor/ui/composer/content/editor.js
@@ -209,25 +209,16 @@ var DocumentReloadListener =
 
       // update the META charset with the current presentation charset
       editor.documentCharacterSet = charset;
 
     } catch (e) {}
   }
 };
 
-function addEditorClickEventListener()
-{
-  try {
-    var bodyelement = GetBodyElement();
-    if (bodyelement)
-      bodyelement.addEventListener("click", EditorClick, false);
-  } catch (e) {}
-}
-
 // implements nsIObserver
 var gEditorDocumentObserver =
 { 
   observe: function(aSubject, aTopic, aData)
   {
     // Should we allow this even if NOT the focused editor?
     var commandManager = GetCurrentCommandManager();
     if (commandManager != aSubject)
@@ -376,18 +367,16 @@ var gEditorDocumentObserver =
 
           // Start in "Normal" edit mode
           SetDisplayMode(kDisplayModeNormal);
         }
 
         // Add mouse click watcher if right type of editor
         if (IsHTMLEditor())
         {
-          addEditorClickEventListener();
-
           // Force color widgets to update
           onFontColorChange();
           onBackgroundColorChange();
         }
         break;
 
       case "cmd_setDocumentModified":
         window.updateCommands("save");
@@ -1447,30 +1436,20 @@ function EditorDblClick(event)
       goDoCommand("cmd_objectProperties");  
       event.preventDefault();
     }
   }
 }
 
 function EditorClick(event)
 {
-  if (!event)
-    return;
-
-  if (event.detail == 2)
-  {
-    EditorDblClick(event);
-    return;
-  }
-
   // For Web Composer: In Show All Tags Mode,
   // single click selects entire element,
   //  except for body and table elements
-  if (IsWebComposer() && event.explicitOriginalTarget && IsHTMLEditor() &&
-      gEditorDisplayMode == kDisplayModeAllTags)
+  if (gEditorDisplayMode == kDisplayModeAllTags)
   {
     try
     {
       // We check event.explicitOriginalTarget here because .target will never
       // be a textnode (bug 193689)
       var element = event.explicitOriginalTarget.QueryInterface(
                         Components.interfaces.nsIDOMElement);
       var name = element.localName.toLowerCase();
--- a/editor/ui/composer/content/editor.xul
+++ b/editor/ui/composer/content/editor.xul
@@ -314,16 +314,18 @@
       <!-- KLUDGE:  Temporary fix for bug 34414:
            The current editor tag doesn't have a view, 
            which breaks deck frame-hiding mechanism 
        -->
       <stack>
         <editor editortype="html"
                 type="content-primary"
                 id="content-frame"
+                onclick="EditorClick(event);"
+                ondblclick="EditorDblClick(event);"
                 context="contentAreaContextMenu"
                 flex="1"
                 tooltip="aHTMLTooltip"/>
       </stack>
       <vbox>
         <label id="doctype-text" crop="right"/>
         <editor type="content"
                 id="content-source"
--- a/mail/components/compose/content/messengercompose.xul
+++ b/mail/components/compose/content/messengercompose.xul
@@ -940,16 +940,17 @@
                       oncommand="doStatefulCommand('cmd_smiley', ':-X' )"/>
           </menupopup>
         </toolbarbutton>
         <spacer flex="1"/>
       </toolbar>
     </toolbox>
 
     <editor type="content-primary" id="content-frame" src="about:blank" name="browser.message.body" flex="1"
+            ondblclick="EditorDblClick(event);"
             context="msgComposeContext"/>
   </vbox>
 
   </vbox>
   </hbox>
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.dimensions;"
--- a/suite/mailnews/compose/messengercompose.xul
+++ b/suite/mailnews/compose/messengercompose.xul
@@ -618,16 +618,17 @@
 <hbox id="sidebar-parent" flex="1">
   <!-- From sidebarOverlay.xul -->
   <vbox id="sidebar-box" class="chromeclass-extrachrome" hidden="true"/>
   <splitter id="sidebar-splitter" class="chromeclass-extrachrome" hidden="true"/>
 
   <!-- The mail message body frame -->
   <vbox id="appcontent" flex="1">
     <editor type="content-primary" id="content-frame" src="about:blank" name="browser.message.body" flex="1"
+            ondblclick="EditorDblClick(event);"
             context="contentAreaContextMenu"/>
   </vbox>
 </hbox>
 
   <statusbar id="status-bar" class="chromeclass-status">
     <statusbarpanel id="component-bar"/>
     <statusbarpanel id="statusText" flex="1"/>
     <statusbarpanel class="statusbarpanel-progress" id="statusbar-progresspanel" collapsed="true">