gecko-dev/browser/actors/PageStyleParent.jsm
James Jahns 8a6c8f36ef Bug 1576918 - Port PageStyle actor to JSWindowActors for Fission compatibility. r=mconley,Gijs
These actors handle implementation of alternative stylesheets functionality.
 r=mconley,Gijs

Differential Revision: https://phabricator.services.mozilla.com/D46861

--HG--
extra : moz-landing-system : lando
2019-10-27 18:08:02 +00:00

38 lines
1.1 KiB
JavaScript

/* 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 = ["PageStyleParent"];
class PageStyleParent extends JSWindowActorParent {
receiveMessage(msg) {
// The top browser.
let browser = this.browsingContext.top.embedderElement;
if (!browser) {
return;
}
let permanentKey = browser.permanentKey;
let window = browser.ownerGlobal;
if (window.closed) {
return;
}
let styleMenu = window.gPageStyleMenu;
switch (msg.name) {
case "PageStyle:Add":
if (browser.outerBrowser) {
// We are in RDM mode and we probably
// want to work with the outer browser.
browser = browser.outerBrowser;
}
styleMenu.addBrowserStyleSheets(msg.data, permanentKey);
break;
case "PageStyle:Clear":
styleMenu.clearBrowserStyleSheets(permanentKey);
break;
}
}
}