Bug 1472491: Part 5q - Add SelectChild actor. r=felipe
authorKris Maglione <maglione.k@gmail.com>
Sun, 29 Jul 2018 21:59:16 -0700
changeset 486568 733c55bf5fe8e6348ad2020a3a863d01c88ab2f3
parent 486567 b1c2735a9a17f0dc87946f564f3981ba671b06ce
child 486569 cddc9e0db0d65c9d9c9a6a37ec489c59da50c929
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs1472491
milestone63.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 1472491: Part 5q - Add SelectChild actor. r=felipe MozReview-Commit-ID: J5MAJMbblyr
browser/base/content/test/forms/head.js
toolkit/actors/SelectChild.jsm
toolkit/actors/moz.build
toolkit/content/browser-content.js
toolkit/modules/ActorManagerParent.jsm
toolkit/modules/SelectContentHelper.jsm
toolkit/modules/moz.build
--- a/browser/base/content/test/forms/head.js
+++ b/browser/base/content/test/forms/head.js
@@ -1,12 +1,13 @@
 function hideSelectPopup(selectPopup, mode = "enter", win = window) {
   let browser = win.gBrowser.selectedBrowser;
   let selectClosedPromise = ContentTask.spawn(browser, null, async function() {
-    ChromeUtils.import("resource://gre/modules/SelectContentHelper.jsm");
+    let {SelectContentHelper} =
+      ChromeUtils.import("resource://gre/actors/SelectChild.jsm", {});
     return ContentTaskUtils.waitForCondition(() => !SelectContentHelper.open);
   });
 
   if (mode == "escape") {
     EventUtils.synthesizeKey("KEY_Escape", {}, win);
   } else if (mode == "enter") {
     EventUtils.synthesizeKey("KEY_Enter", {}, win);
   } else if (mode == "click") {
rename from toolkit/modules/SelectContentHelper.jsm
rename to toolkit/actors/SelectChild.jsm
--- a/toolkit/modules/SelectContentHelper.jsm
+++ b/toolkit/actors/SelectChild.jsm
@@ -1,14 +1,17 @@
+/* vim: set ts=2 sw=2 sts=2 et tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
 "use strict";
 
+var EXPORTED_SYMBOLS = ["SelectChild"];
+
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "BrowserUtils",
                                "resource://gre/modules/BrowserUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "DeferredTask",
                                "resource://gre/modules/DeferredTask.jsm");
 
 XPCOMUtils.defineLazyGlobalGetters(this, ["InspectorUtils"]);
@@ -23,20 +26,16 @@ const SUPPORTED_PROPERTIES = [
 ];
 
 // A process global state for whether or not content thinks
 // that a <select> dropdown is open or not. This is managed
 // entirely within this module, and is read-only accessible
 // via SelectContentHelper.open.
 var gOpen = false;
 
-var EXPORTED_SYMBOLS = [
-  "SelectContentHelper"
-];
-
 var SelectContentHelper = function(aElement, aOptions, aGlobal) {
   this.element = aElement;
   this.initialSelection = aElement[aElement.selectedIndex] || null;
   this.global = aGlobal;
   this.closedWithClickOn = false;
   this.isOpenedViaTouch = aOptions.isOpenedViaTouch;
   this._selectBackgroundColor = null;
   this._selectColor = null;
@@ -417,8 +416,26 @@ function buildOptionListForChildren(node
         info.textShadow = cs.textShadow;
       }
 
       result.push(info);
     }
   }
   return result;
 }
+
+class SelectChild extends ActorChild {
+  handleEvent(event) {
+    if (SelectContentHelper.open) {
+      return;
+    }
+
+    switch (event.type) {
+    case "mozshowdropdown":
+      new SelectContentHelper(event.target, {isOpenedViaTouch: false}, this.mm);
+      break;
+
+    case "mozshowdropdown-sourcetouch":
+      new SelectContentHelper(event.target, {isOpenedViaTouch: true}, this.mm);
+      break;
+    }
+  }
+}
--- a/toolkit/actors/moz.build
+++ b/toolkit/actors/moz.build
@@ -2,9 +2,10 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 FINAL_TARGET_FILES.actors += [
     'AudioPlaybackChild.jsm',
     'FindBarChild.jsm',
+    'SelectChild.jsm',
 ]
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -12,18 +12,16 @@ ChromeUtils.import("resource://gre/modul
 ChromeUtils.import("resource://gre/modules/ActorManagerChild.jsm");
 
 ActorManagerChild.attach(this);
 
 ChromeUtils.defineModuleGetter(this, "AutoCompletePopup",
   "resource://gre/modules/AutoCompletePopupContent.jsm");
 ChromeUtils.defineModuleGetter(this, "AutoScrollController",
   "resource://gre/modules/AutoScrollController.jsm");
-ChromeUtils.defineModuleGetter(this, "SelectContentHelper",
-  "resource://gre/modules/SelectContentHelper.jsm");
 ChromeUtils.defineModuleGetter(this, "FindContent",
   "resource://gre/modules/FindContent.jsm");
 ChromeUtils.defineModuleGetter(this, "PrintingContent",
   "resource://gre/modules/PrintingContent.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "formFill",
                                    "@mozilla.org/satchel/form-fill-controller;1",
                                    "nsIFormFillController");
@@ -206,34 +204,16 @@ let AutoComplete = {
       }
       break;
     }
   },
 };
 
 AutoComplete.init();
 
-addEventListener("mozshowdropdown", event => {
-  if (!event.isTrusted)
-    return;
-
-  if (!SelectContentHelper.open) {
-    new SelectContentHelper(event.target, {isOpenedViaTouch: false}, this);
-  }
-});
-
-addEventListener("mozshowdropdown-sourcetouch", event => {
-  if (!event.isTrusted)
-    return;
-
-  if (!SelectContentHelper.open) {
-    new SelectContentHelper(event.target, {isOpenedViaTouch: true}, this);
-  }
-});
-
 let ExtFind = {
   init() {
     addMessageListener("ext-Finder:CollectResults", this);
     addMessageListener("ext-Finder:HighlightResults", this);
     addMessageListener("ext-Finder:clearHighlighting", this);
     this.init = null;
   },
 
--- a/toolkit/modules/ActorManagerParent.jsm
+++ b/toolkit/modules/ActorManagerParent.jsm
@@ -115,16 +115,26 @@ let ACTORS = {
   FindBar: {
     child: {
       module: "resource://gre/actors/FindBarChild.jsm",
       events: {
         "keypress": {mozSystemGroup: true},
       },
     },
   },
+
+  Select: {
+    child: {
+      module: "resource://gre/actors/SelectChild.jsm",
+      events: {
+        "mozshowdropdown": {},
+        "mozshowdropdown-sourcetouch": {},
+      },
+    },
+  },
 };
 
 class ActorSet {
   constructor(group, actorSide) {
     this.group = group;
     this.actorSide = actorSide;
 
     this.actors = new Map();
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -237,17 +237,16 @@ EXTRA_JS_MODULES += [
     'PromiseMessage.jsm',
     'PromiseUtils.jsm',
     'RemoteController.js',
     'RemoteFinder.jsm',
     'RemoteSecurityUI.jsm',
     'RemoteWebProgress.jsm',
     'ResetProfile.jsm',
     'ResponsivenessMonitor.jsm',
-    'SelectContentHelper.jsm',
     'SelectionSourceContent.jsm',
     'SelectParentHelper.jsm',
     'ServiceRequest.jsm',
     'Services.jsm',
     'sessionstore/FormData.jsm',
     'sessionstore/ScrollPosition.jsm',
     'ShortcutUtils.jsm',
     'Sqlite.jsm',