mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 07:45:30 +00:00
Bug 1235845 - add the pocket stylesheet to browser windows instead of using the stylesheet service, r=mixedpuppy
--HG-- extra : commitid : DjpsZC9VWBa extra : rebase_source : 87356b25a5acb338b239a0f5586614f3a2130563
This commit is contained in:
parent
f55c95eaa4
commit
db544f5e5b
35
browser/extensions/pocket/bootstrap.js
vendored
35
browser/extensions/pocket/bootstrap.js
vendored
@ -286,7 +286,6 @@ function pktUIGetter(prop, window) {
|
||||
|
||||
var PocketOverlay = {
|
||||
startup: function(reason) {
|
||||
this.registerStylesheet();
|
||||
CreatePocketWidget(reason);
|
||||
Services.obs.addObserver(this,
|
||||
"browser-delayed-startup-finished",
|
||||
@ -298,6 +297,7 @@ var PocketOverlay = {
|
||||
if (reason == ADDON_ENABLE) {
|
||||
for (let win of allBrowserWindows()) {
|
||||
this.setWindowScripts(win);
|
||||
this.addStyles(win);
|
||||
this.updateWindow(win);
|
||||
}
|
||||
}
|
||||
@ -312,6 +312,7 @@ var PocketOverlay = {
|
||||
if (element)
|
||||
element.remove();
|
||||
}
|
||||
this.removeStyles(window);
|
||||
// remove script getters/objects
|
||||
delete window.Pocket;
|
||||
delete window.pktUI;
|
||||
@ -320,12 +321,12 @@ var PocketOverlay = {
|
||||
CustomizableUI.destroyWidget("pocket-button");
|
||||
PocketContextMenu.shutdown();
|
||||
PocketReader.shutdown();
|
||||
this.unregisterStylesheet();
|
||||
},
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// new browser window, initialize the "overlay"
|
||||
let window = aSubject;
|
||||
this.setWindowScripts(window);
|
||||
this.addStyles(window);
|
||||
this.updateWindow(window);
|
||||
},
|
||||
setWindowScripts: function(window) {
|
||||
@ -433,25 +434,21 @@ var PocketOverlay = {
|
||||
}
|
||||
},
|
||||
|
||||
registerStylesheet: function() {
|
||||
let styleSheetService= Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService);
|
||||
let styleSheetURI = Services.io.newURI("chrome://pocket/skin/pocket.css", null, null);
|
||||
styleSheetService.loadAndRegisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
|
||||
styleSheetURI = Services.io.newURI("chrome://pocket-shared/skin/pocket.css", null, null);
|
||||
styleSheetService.loadAndRegisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
|
||||
addStyles: function(win) {
|
||||
let xmlPI = win.document.createProcessingInstruction("xml-stylesheet",
|
||||
"type=\"text/css\" href=\"chrome://pocket/skin/pocket.css\"");
|
||||
win.document.insertBefore(xmlPI, win.document.documentElement);
|
||||
},
|
||||
|
||||
unregisterStylesheet: function() {
|
||||
let styleSheetService = Components.classes["@mozilla.org/content/style-sheet-service;1"]
|
||||
.getService(Components.interfaces.nsIStyleSheetService);
|
||||
let styleSheetURI = Services.io.newURI("chrome://pocket/skin/pocket.css", null, null);
|
||||
if (styleSheetService.sheetRegistered(styleSheetURI, styleSheetService.AUTHOR_SHEET)) {
|
||||
styleSheetService.unregisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
|
||||
}
|
||||
styleSheetURI = Services.io.newURI("chrome://pocket-shared/skin/pocket.css", null, null);
|
||||
if (styleSheetService.sheetRegistered(styleSheetURI, styleSheetService.AUTHOR_SHEET)) {
|
||||
styleSheetService.unregisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
|
||||
removeStyles: function(win) {
|
||||
let el = win.document.documentElement.previousSibling;
|
||||
while (el) {
|
||||
if (el.nodeType == el.PROCESSING_INSTRUCTION_NODE &&
|
||||
el.sheet && el.sheet.href == "chrome://pocket/skin/pocket.css") {
|
||||
el.remove();
|
||||
break;
|
||||
}
|
||||
el = el.previousSibling;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
@import url("chrome://pocket-shared/skin/pocket.css");
|
@ -1,3 +1,5 @@
|
||||
@import url("chrome://pocket-shared/skin/pocket.css");
|
||||
|
||||
#pocket-button[cui-areatype="toolbar"][open] {
|
||||
-moz-image-region: rect(36px, 774px, 54px, 756px);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
@import url("chrome://pocket-shared/skin/pocket.css");
|
||||
|
||||
@media (min-resolution: 1.1dppx) {
|
||||
#pocket-button[cui-areatype="toolbar"] {
|
||||
-moz-image-region: rect(0, 1548px, 36px, 1512px);
|
||||
|
Loading…
Reference in New Issue
Block a user