Bug 1472491: Part 5c - Add PageStyleChild actor. r=felipe
authorKris Maglione <maglione.k@gmail.com>
Sun, 29 Jul 2018 19:54:17 -0700
changeset 431457 271ac4e75c900d5a41602ca7de1c1b9823385e34
parent 431456 a7d69dc796d1fec209805c1dc9b0875f1b3ef056
child 431458 13dc8b7b72f3fc5f774a00335f68c4815338ff07
push id34443
push usercsabou@mozilla.com
push dateWed, 15 Aug 2018 00:53:32 +0000
treeherdermozilla-central@b80906e2fbc9 [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 5c - Add PageStyleChild actor. r=felipe MozReview-Commit-ID: DccnrQyiBAd
browser/actors/PageStyleChild.jsm
browser/actors/moz.build
browser/base/content/tab-content.js
browser/base/content/test/performance/browser_startup_content.js
browser/components/nsBrowserGlue.js
browser/modules/PageStyleHandler.jsm
browser/modules/moz.build
rename from browser/modules/PageStyleHandler.jsm
rename to browser/actors/PageStyleChild.jsm
--- a/browser/modules/PageStyleHandler.jsm
+++ b/browser/actors/PageStyleChild.jsm
@@ -1,91 +1,93 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-var EXPORTED_SYMBOLS = ["PageStyleHandler"];
+var EXPORTED_SYMBOLS = ["PageStyleChild"];
 
-var PageStyleHandler = {
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
+
+class PageStyleChild extends ActorChild {
   getViewer(content) {
     return content.docShell.contentViewer;
-  },
+  }
 
   sendStyleSheetInfo(mm) {
     let content = mm.content;
     let filteredStyleSheets = this._filterStyleSheets(this.getAllStyleSheets(content), content);
 
     mm.sendAsyncMessage("PageStyle:StyleSheets", {
       filteredStyleSheets,
       authorStyleDisabled: this.getViewer(content).authorStyleDisabled,
       preferredStyleSheetSet: content.document.preferredStyleSheetSet
     });
-  },
+  }
 
   getAllStyleSheets(frameset) {
     let selfSheets = Array.slice(frameset.document.styleSheets);
     let subSheets = Array.map(frameset.frames, frame => this.getAllStyleSheets(frame));
     return selfSheets.concat(...subSheets);
-  },
+  }
 
   receiveMessage(msg) {
     let content = msg.target.content;
     switch (msg.name) {
       case "PageStyle:Switch":
         this.getViewer(content).authorStyleDisabled = false;
         this._stylesheetSwitchAll(content, msg.data.title);
         break;
 
       case "PageStyle:Disable":
         this.getViewer(content).authorStyleDisabled = true;
         break;
     }
 
     this.sendStyleSheetInfo(msg.target);
-  },
+  }
 
   handleEvent(event) {
     let win = event.target.ownerGlobal;
     if (win != win.top) {
       return;
     }
 
     let mm = win.docShell.messageManager;
     this.sendStyleSheetInfo(mm);
-  },
+  }
 
   _stylesheetSwitchAll(frameset, title) {
     if (!title || this._stylesheetInFrame(frameset, title)) {
       this._stylesheetSwitchFrame(frameset, title);
     }
 
     for (let i = 0; i < frameset.frames.length; i++) {
       // Recurse into sub-frames.
       this._stylesheetSwitchAll(frameset.frames[i], title);
     }
-  },
+  }
 
   _stylesheetSwitchFrame(frame, title) {
     var docStyleSheets = frame.document.styleSheets;
 
     for (let i = 0; i < docStyleSheets.length; ++i) {
       let docStyleSheet = docStyleSheets[i];
       if (docStyleSheet.title) {
         docStyleSheet.disabled = (docStyleSheet.title != title);
       } else if (docStyleSheet.disabled) {
         docStyleSheet.disabled = false;
       }
     }
-  },
+  }
 
   _stylesheetInFrame(frame, title) {
     return Array.some(frame.document.styleSheets, (styleSheet) => styleSheet.title == title);
-  },
+  }
 
   _filterStyleSheets(styleSheets, content) {
     let result = [];
 
     for (let currentStyleSheet of styleSheets) {
       if (!currentStyleSheet.title)
         continue;
 
@@ -118,10 +120,10 @@ var PageStyleHandler = {
       result.push({
         title: currentStyleSheet.title,
         disabled: currentStyleSheet.disabled,
         href: sentURI,
       });
     }
 
     return result;
-  },
-};
+  }
+}
--- a/browser/actors/moz.build
+++ b/browser/actors/moz.build
@@ -1,10 +1,14 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # 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/.
 
+with Files("PageStyleChild.jsm"):
+    BUG_COMPONENT = ("Firefox", "Menus")
+
 FINAL_TARGET_FILES.actors += [
     'AboutReaderChild.jsm',
     'BrowserTabChild.jsm',
+    'PageStyleChild.jsm',
 ]
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -9,18 +9,16 @@
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 ChromeUtils.defineModuleGetter(this, "E10SUtils",
   "resource://gre/modules/E10SUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "BrowserUtils",
   "resource://gre/modules/BrowserUtils.jsm");
-ChromeUtils.defineModuleGetter(this, "PageStyleHandler",
-  "resource:///modules/PageStyleHandler.jsm");
 
 ChromeUtils.import("resource://gre/modules/ActorManagerChild.jsm");
 
 ActorManagerChild.attach(this, "browsers");
 
 // TabChildGlobal
 var global = this;
 
@@ -109,20 +107,16 @@ var ContentSearchMediator = {
       },
     }, content);
     content.dispatchEvent(new content.CustomEvent("ContentSearchService",
                                                   event));
   },
 };
 ContentSearchMediator.init(this);
 
-addMessageListener("PageStyle:Switch", PageStyleHandler);
-addMessageListener("PageStyle:Disable", PageStyleHandler);
-addEventListener("pageshow", PageStyleHandler);
-
 // Keep a reference to the translation content handler to avoid it it being GC'ed.
 var trHandler = null;
 if (Services.prefs.getBoolPref("browser.translation.detectLanguage")) {
   ChromeUtils.import("resource:///modules/translation/TranslationContentHandler.jsm");
   trHandler = new TranslationContentHandler(global, docShell);
 }
 
 function gKeywordURIFixup(fixupInfo) {
--- a/browser/base/content/test/performance/browser_startup_content.js
+++ b/browser/base/content/test/performance/browser_startup_content.js
@@ -47,17 +47,17 @@ const whitelist = {
     "resource://formautofill/FormAutofill.jsm",
     "resource://formautofill/FormAutofillContent.jsm",
 
     // Browser front-end
     "resource:///actors/AboutReaderChild.jsm",
     "resource:///actors/BrowserTabChild.jsm",
     "resource:///modules/ContentLinkHandler.jsm",
     "resource:///modules/ContentMetaHandler.jsm",
-    "resource:///modules/PageStyleHandler.jsm",
+    "resource:///actors/PageStyleChild.jsm",
     "resource://gre/modules/ActorChild.jsm",
     "resource://gre/modules/ActorManagerChild.jsm",
     "resource://gre/modules/BrowserUtils.jsm",
     "resource://gre/modules/E10SUtils.jsm",
     "resource://gre/modules/PrivateBrowsingUtils.jsm",
     "resource://gre/modules/ReaderMode.jsm",
     "resource://gre/modules/WebProgressChild.jsm",
     "resource://gre/modules/WebNavigationChild.jsm",
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -47,16 +47,30 @@ let ACTORS = {
         "Browser:HasSiblings",
         "Browser:Reload",
         "MixedContent:ReenableProtection",
         "SwitchDocumentDirection",
         "UpdateCharacterSet",
       ],
     },
   },
+
+  PageStyle: {
+    child: {
+      module: "resource:///actors/PageStyleChild.jsm",
+      group: "browsers",
+      events: {
+        "pageshow": {},
+      },
+      messages: [
+        "PageStyle:Switch",
+        "PageStyle:Disable",
+      ]
+    },
+  },
 };
 
 (function earlyBlankFirstPaint() {
   if (!Services.prefs.getBoolPref("browser.startup.blankWindow", false))
     return;
 
   let store = Services.xulStore;
   let getValue = attr =>
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -71,19 +71,16 @@ with Files("LightWeightThemeWebInstallLi
     BUG_COMPONENT = ("Firefox", "Theme")
 
 with Files("OpenInTabsUtils.jsm"):
     BUG_COMPONENT = ("Firefox", "Tabbed Browser")
 
 with Files("PageInfoListener.jsm"):
     BUG_COMPONENT = ("Firefox", "Page Info Window")
 
-with Files("PageStyleHandler.jsm"):
-    BUG_COMPONENT = ("Firefox", "Menus")
-
 with Files("PermissionUI.jsm"):
    BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels")
 
 with Files("PluginContent.jsm"):
     BUG_COMPONENT = ("Core", "Plug-ins")
 
 with Files("ProcessHangMonitor.jsm"):
     BUG_COMPONENT = ("Core", "DOM: Content Processes")
@@ -154,17 +151,16 @@ EXTRA_JS_MODULES += [
     'HomePage.jsm',
     'LaterRun.jsm',
     'LightweightThemeChildHelper.jsm',
     'LightWeightThemeWebInstallListener.jsm',
     'NetErrorContent.jsm',
     'OpenInTabsUtils.jsm',
     'PageActions.jsm',
     'PageInfoListener.jsm',
-    'PageStyleHandler.jsm',
     'PermissionUI.jsm',
     'PingCentre.jsm',
     'PluginContent.jsm',
     'ProcessHangMonitor.jsm',
     'ReaderParent.jsm',
     'RemotePrompt.jsm',
     'Sanitizer.jsm',
     'SavantShieldStudy.jsm',