Bug 1394304: Part 0a - Extract method _whereToOpen in urlbarBindings. r=adw
authorYuri Khan <yuri.v.khan@gmail.com>
Sun, 28 Jan 2018 18:22:22 +0700
changeset 402515 256247373b45b3599feb86ee570004633587f864
parent 402514 95245d5d7560d1a858c0ec80c4da820dfb182063
child 402516 ff8ae0661153a0fe72cf7eead67060b4248e8372
push id99585
push usercsabou@mozilla.com
push dateTue, 06 Feb 2018 11:04:29 +0000
treeherdermozilla-inbound@420221f11352 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1394304
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394304: Part 0a - Extract method _whereToOpen in urlbarBindings. r=adw
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -513,16 +513,35 @@ file, You can obtain one at http://mozil
           }
 
           // tell widget to revert to last typed text only if the user
           // was scrolling when they hit escape
           return !isScrolling;
         ]]></body>
       </method>
 
+      <method name="_whereToOpen">
+        <parameter name="event"/>
+        <body><![CDATA[
+          let isMouseEvent = event instanceof MouseEvent;
+          let where = undefined;
+          if (isMouseEvent) {
+            where = whereToOpenLink(event, false, false);
+          } else {
+            // If the current tab is empty, ignore Alt+Enter (reuse this tab)
+            let altEnter = !isMouseEvent &&
+                           event &&
+                           event.altKey &&
+                           !isTabEmpty(gBrowser.selectedTab);
+            where = altEnter ? "tab" : "current";
+          }
+          return where;
+        ]]></body>
+      </method>
+
       <!--
         This is ultimately called by the autocomplete controller as the result
         of handleEnter when the Return key is pressed in the textbox.  Since
         onPopupClick also calls handleEnter, this is also called as a result in
         that case.
 
         @param event
                The event that triggered the command.
@@ -561,29 +580,17 @@ file, You can obtain one at http://mozil
           }
 
           // Do the command of the selected one-off if it's not an engine.
           if (selectedOneOff && !selectedOneOff.engine) {
             selectedOneOff.doCommand();
             return;
           }
 
-          let where = openUILinkWhere;
-          if (!where) {
-            if (isMouseEvent) {
-              where = whereToOpenLink(event, false, false);
-            } else {
-              // If the current tab is empty, ignore Alt+Enter (reuse this tab)
-              let altEnter = !isMouseEvent &&
-                             event &&
-                             event.altKey &&
-                             !isTabEmpty(gBrowser.selectedTab);
-              where = altEnter ? "tab" : "current";
-            }
-          }
+          let where = openUILinkWhere || this._whereToOpen(event);
 
           let url = this.value;
           if (!url) {
             return;
           }
 
           let mayInheritPrincipal = false;
           let postData = null;