mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +09:00
parent
53e8bd2ac0
commit
ef8ecc5bcd
7 changed files with 123 additions and 0 deletions
92
application/palemoon/base/content/browser-devtools-theme.js
Normal file
92
application/palemoon/base/content/browser-devtools-theme.js
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listeners for the DevEdition theme. This adds an extra stylesheet
|
||||||
|
* to browser.xul if a pref is set and no other themes are applied.
|
||||||
|
*/
|
||||||
|
var DevToolsTheme = {
|
||||||
|
_devtoolsThemePrefName: "devtools.theme",
|
||||||
|
styleSheet: null,
|
||||||
|
initialized: false,
|
||||||
|
|
||||||
|
get isStyleSheetEnabled() {
|
||||||
|
return this.styleSheet && !this.styleSheet.sheet.disabled;
|
||||||
|
},
|
||||||
|
|
||||||
|
init: function () {
|
||||||
|
this.initialized = true;
|
||||||
|
Services.prefs.addObserver(this._devtoolsThemePrefName, this, false);
|
||||||
|
Services.obs.addObserver(this, "lightweight-theme-styling-update", false);
|
||||||
|
Services.obs.addObserver(this, "lightweight-theme-window-updated", false);
|
||||||
|
this._updateDevtoolsThemeAttribute();
|
||||||
|
},
|
||||||
|
|
||||||
|
observe: function (subject, topic, data) {
|
||||||
|
if (topic == "lightweight-theme-styling-update") {
|
||||||
|
let newTheme = JSON.parse(data);
|
||||||
|
this._toggleStyleSheet();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topic == "nsPref:changed" && data == this._devtoolsThemePrefName) {
|
||||||
|
this._updateDevtoolsThemeAttribute();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_inferBrightness: function() {
|
||||||
|
ToolbarIconColor.inferFromText();
|
||||||
|
// Get an inverted full screen button if the dark theme is applied.
|
||||||
|
if (this.isStyleSheetEnabled &&
|
||||||
|
document.documentElement.getAttribute("devtoolstheme") == "dark") {
|
||||||
|
document.documentElement.setAttribute("brighttitlebarforeground", "true");
|
||||||
|
} else {
|
||||||
|
document.documentElement.removeAttribute("brighttitlebarforeground");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateDevtoolsThemeAttribute: function() {
|
||||||
|
// Set an attribute on root element to make it possible
|
||||||
|
// to change colors based on the selected devtools theme.
|
||||||
|
let devtoolsTheme = Services.prefs.getCharPref(this._devtoolsThemePrefName);
|
||||||
|
if (devtoolsTheme != "dark") {
|
||||||
|
devtoolsTheme = "light";
|
||||||
|
}
|
||||||
|
document.documentElement.setAttribute("devtoolstheme", devtoolsTheme);
|
||||||
|
this._inferBrightness();
|
||||||
|
},
|
||||||
|
|
||||||
|
handleEvent: function(e) {
|
||||||
|
if (e.type === "load") {
|
||||||
|
this.styleSheet.removeEventListener("load", this);
|
||||||
|
this.refreshBrowserDisplay();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshBrowserDisplay: function() {
|
||||||
|
// Don't touch things on the browser if gBrowserInit.onLoad hasn't
|
||||||
|
// yet fired.
|
||||||
|
if (this.initialized) {
|
||||||
|
gBrowser.tabContainer._positionPinnedTabs();
|
||||||
|
this._inferBrightness();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_toggleStyleSheet: function() {
|
||||||
|
let wasEnabled = this.isStyleSheetEnabled;
|
||||||
|
if (wasEnabled) {
|
||||||
|
this.styleSheet.sheet.disabled = true;
|
||||||
|
this.refreshBrowserDisplay();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
uninit: function () {
|
||||||
|
Services.prefs.removeObserver(this._devtoolsThemePrefName, this);
|
||||||
|
Services.obs.removeObserver(this, "lightweight-theme-styling-update", false);
|
||||||
|
Services.obs.removeObserver(this, "lightweight-theme-window-updated", false);
|
||||||
|
if (this.styleSheet) {
|
||||||
|
this.styleSheet.removeEventListener("load", this);
|
||||||
|
}
|
||||||
|
this.styleSheet = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -722,6 +722,14 @@ var gBrowserInit = {
|
||||||
|
|
||||||
window.addEventListener("AppCommand", HandleAppCommandEvent, true);
|
window.addEventListener("AppCommand", HandleAppCommandEvent, true);
|
||||||
|
|
||||||
|
// These routines add message listeners. They must run before
|
||||||
|
// loading the frame script to ensure that we don't miss any
|
||||||
|
// message sent between when the frame script is loaded and when
|
||||||
|
// the listener is registered.
|
||||||
|
#ifdef MOZ_DEVTOOLS
|
||||||
|
DevToolsTheme.init();
|
||||||
|
#endif
|
||||||
|
|
||||||
messageManager.loadFrameScript("chrome://browser/content/content.js", true);
|
messageManager.loadFrameScript("chrome://browser/content/content.js", true);
|
||||||
messageManager.loadFrameScript("chrome://browser/content/content-sessionStore.js", true);
|
messageManager.loadFrameScript("chrome://browser/content/content-sessionStore.js", true);
|
||||||
|
|
||||||
|
|
@ -1281,6 +1289,10 @@ var gBrowserInit = {
|
||||||
|
|
||||||
ToolbarIconColor.uninit();
|
ToolbarIconColor.uninit();
|
||||||
|
|
||||||
|
#ifdef MOZ_DEVTOOLS
|
||||||
|
DevToolsTheme.uninit();
|
||||||
|
#endif
|
||||||
|
|
||||||
var enumerator = Services.wm.getEnumerator(null);
|
var enumerator = Services.wm.getEnumerator(null);
|
||||||
enumerator.getNext();
|
enumerator.getNext();
|
||||||
if (!enumerator.hasMoreElements()) {
|
if (!enumerator.hasMoreElements()) {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,9 @@
|
||||||
# wishes to include *must* go into the global-scripts.inc file
|
# wishes to include *must* go into the global-scripts.inc file
|
||||||
# so that they can be shared by macBrowserOverlay.xul.
|
# so that they can be shared by macBrowserOverlay.xul.
|
||||||
#include global-scripts.inc
|
#include global-scripts.inc
|
||||||
|
#ifdef MOZ_DEVTOOLS
|
||||||
|
#include global-devtools-theme-scripts.inc
|
||||||
|
#endif
|
||||||
<script type="application/javascript" src="chrome://browser/content/nsContextMenu.js"/>
|
<script type="application/javascript" src="chrome://browser/content/nsContextMenu.js"/>
|
||||||
|
|
||||||
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
|
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
# 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/.
|
||||||
|
|
||||||
|
<script type="application/javascript" src="chrome://browser/content/browser-devtools-theme.js"/>
|
||||||
|
|
@ -24,6 +24,9 @@
|
||||||
# wishes to include *must* go into the global-scripts.inc file
|
# wishes to include *must* go into the global-scripts.inc file
|
||||||
# so that they can be shared by this overlay.
|
# so that they can be shared by this overlay.
|
||||||
#include global-scripts.inc
|
#include global-scripts.inc
|
||||||
|
#ifdef MOZ_DEVTOOLS
|
||||||
|
#include global-devtools-theme-scripts.inc
|
||||||
|
#endif
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
function OpenBrowserWindowFromDockMenu(options) {
|
function OpenBrowserWindowFromDockMenu(options) {
|
||||||
|
|
|
||||||
|
|
@ -2882,6 +2882,10 @@
|
||||||
onget="return this.mCurrentBrowser.contentDocument;"
|
onget="return this.mCurrentBrowser.contentDocument;"
|
||||||
readonly="true"/>
|
readonly="true"/>
|
||||||
|
|
||||||
|
<property name="contentDocumentAsCPOW"
|
||||||
|
onget="return this.mCurrentBrowser.contentDocument;"
|
||||||
|
readonly="true"/>
|
||||||
|
|
||||||
<property name="contentTitle"
|
<property name="contentTitle"
|
||||||
onget="return this.mCurrentBrowser.contentTitle;"
|
onget="return this.mCurrentBrowser.contentTitle;"
|
||||||
readonly="true"/>
|
readonly="true"/>
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@ browser.jar:
|
||||||
content/browser/browser-title.css (content/browser-title.css)
|
content/browser/browser-title.css (content/browser-title.css)
|
||||||
* content/browser/browser.js (content/browser.js)
|
* content/browser/browser.js (content/browser.js)
|
||||||
* content/browser/browser.xul (content/browser.xul)
|
* content/browser/browser.xul (content/browser.xul)
|
||||||
|
#ifdef MOZ_DEVTOOLS
|
||||||
|
content/browser/browser-devtools-theme.js (content/browser-devtools-theme.js)
|
||||||
|
#endif
|
||||||
* content/browser/browser-tabPreviews.xml (content/browser-tabPreviews.xml)
|
* content/browser/browser-tabPreviews.xml (content/browser-tabPreviews.xml)
|
||||||
content/browser/content.js (content/content.js)
|
content/browser/content.js (content/content.js)
|
||||||
content/browser/padlock.xul (content/padlock.xul)
|
content/browser/padlock.xul (content/padlock.xul)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue