Bug 894715 - Part 2 - Fix trimming issue. r=ally
authorJonathan Wilde <jwilde@jwilde.me>
Fri, 09 Aug 2013 22:42:55 -0700
changeset 142077 6ad5e7c6ecf29a2670cada2ecc3d327b0f2f7429
parent 142076 141402d84ef59eea70457d352846323fbf2c9afa
child 142078 09b366c13cb02428046a3a06f228c2ec61711850
push id2136
push userhello@jwilde.me
push dateSat, 10 Aug 2013 06:41:30 +0000
treeherderfx-team@6ad5e7c6ecf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersally
bugs894715
milestone26.0a1
Bug 894715 - Part 2 - Fix trimming issue. r=ally
browser/metro/base/content/ContextCommands.js
browser/metro/base/content/bindings/bindings.xml
browser/metro/base/content/bindings/urlbar.xml
--- a/browser/metro/base/content/ContextCommands.js
+++ b/browser/metro/base/content/ContextCommands.js
@@ -32,69 +32,76 @@ var ContextCommands = {
    * Context menu handlers
    */
 
   // Text specific
 
   cut: function cc_cut() {
     let target = ContextMenuUI.popupState.target;
 
-    if (!target)
+    if (!target) {
       return;
+    }
 
     if (target.localName === "browser") {
       // content
       if (ContextMenuUI.popupState.string) {
         this.sendCommand("cut");
 
         SelectionHelperUI.closeEditSession(true);
       }
     } else {
       // chrome
-      target.editor.cut();
+      CommandUpdater.doCommand("cmd_cut");
     }
 
     target.focus();
   },
 
   copy: function cc_copy() {
     let target = ContextMenuUI.popupState.target;
 
-    if (!target)
+    if (!target) {
       return;
+    }
 
     if (target.localName == "browser") {
       // content
       if (ContextMenuUI.popupState.string) {
         this.sendCommand("copy");
 
         SelectionHelperUI.closeEditSession(true);
       }
     } else if (ContextMenuUI.popupState.string) {
       this.clipboard.copyString(ContextMenuUI.popupState.string, this.docRef);
     } else {
       // chrome
-      target.editor.copy();
+      CommandUpdater.doCommand("cmd_copy");
     }
 
     target.focus();
   },
 
   paste: function cc_paste() {
     let target = ContextMenuUI.popupState.target;
+
+    if (!target) {
+      return;
+    }
+
     if (target.localName == "browser") {
       // content
       let x = ContextMenuUI.popupState.x;
       let y = ContextMenuUI.popupState.y;
       let json = {x: x, y: y, command: "paste" };
       target.messageManager.sendAsyncMessage("Browser:ContextCommand", json);
       SelectionHelperUI.closeEditSession();
     } else {
       // chrome
-      target.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
+      CommandUpdater.doCommand("cmd_paste");
       target.focus();
     }
   },
 
   pasteAndGo: function cc_pasteAndGo() {
     let target = ContextMenuUI.popupState.target;
     target.editor.selectAll();
     target.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
--- a/browser/metro/base/content/bindings/bindings.xml
+++ b/browser/metro/base/content/bindings/bindings.xml
@@ -255,20 +255,16 @@
         <body><![CDATA[
           let selectionStart = aTextbox.selectionStart;
           let selectionEnd = aTextbox.selectionEnd;
 
           let json = { types: ["input-text"], string: "" };
           if (selectionStart != selectionEnd) {
             json.types.push("cut");
             json.types.push("copy");
-            json.string = aTextbox.value.slice(selectionStart, selectionEnd);
-          } else if (aTextbox.value) {
-            json.types.push("copy-all");
-            json.string = aTextbox.value;
           }
 
           if (selectionStart > 0 || selectionEnd < aTextbox.textLength)
             json.types.push("select-all");
 
           let clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].
                                             getService(Ci.nsIClipboard);
           let flavors = ["text/unicode"];
--- a/browser/metro/base/content/bindings/urlbar.xml
+++ b/browser/metro/base/content/bindings/urlbar.xml
@@ -152,17 +152,17 @@
         </body>
       </method>
 
       <method name="_getSelectedValueForClipboard">
         <body>
           <![CDATA[
             // Grab the actual input field's value, not our value, which could include moz-action:
             let inputVal = this.inputField.value;
-            let selectedVal = inputVal.substring(this.selectionStart, this.electionEnd);
+            let selectedVal = inputVal.substring(this.selectionStart, this.selectionEnd);
 
             // If the selection doesn't start at the beginning or doesn't span the full domain or
             // the URL bar is modified, nothing else to do here.
             if (this.selectionStart > 0 || this.valueIsTyped)
               return selectedVal;
 
             // The selection doesn't span the full domain if it doesn't contain a slash and is
             // followed by some character other than a slash.