Skip to content

Commit

Permalink
(new script) fix titlebar button tooltips;
Browse files Browse the repository at this point in the history
(CSS) fix the app menu exit fullscreen button's icon;
(CSS) style the parsererror page so the yellow isn't so blinding.
  • Loading branch information
aminomancer committed Nov 15, 2021
1 parent 5394e70 commit add1784
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 19 deletions.
36 changes: 36 additions & 0 deletions JS/fixTitlebarTooltips.uc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ==UserScript==
// @name Fix Titlebar Button Tooltips
// @version 1.0
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description Since bug 1718629 (https://bugzilla.mozilla.org/show_bug.cgi?id=1718629), Firefox has tried to make the titlebar buttons (window controls) function more like native controls. In doing so, it allows the OS to draw tooltips for these buttons. So it prevents itself from showing redundant tooltips. That means we can't style the titlebar buttons' tooltips, they don't obey preferences, they disappear after 5 seconds on Windows, and they don't appear at all in fullscreen mode. Personally I would not be a fan of this change even if I didn't heavily customize Firefox's tooltips, because no matter what, OS tooltips are not going to be consistent with Firefox's tooltips, for reasons I mentioned. But in any case, we can fix this issue with JavaScript. It's caused by the titlebar-btn attribute. But removing that programmatically won't work because it's parsed by a C++ component when the buttons are connected. It's already too late by the time the script is running. So we need to recreate the DOM nodes without this attribute.
// @include *
// ==/UserScript==

class FixTitlebarTooltips {
constructor() {
this.markup = `<hbox class="titlebar-buttonbox-container" skipintoolbarset="true">
<hbox class="titlebar-buttonbox titlebar-color">
<toolbarbutton class="titlebar-button titlebar-min"
oncommand="window.minimize();"
data-l10n-id="browser-window-minimize-button"
/>
<toolbarbutton class="titlebar-button titlebar-max"
oncommand="window.maximize();"
data-l10n-id="browser-window-maximize-button"
/>
<toolbarbutton class="titlebar-button titlebar-restore"
oncommand="window.fullScreen ? BrowserFullScreen() : window.restore();"
data-l10n-id="browser-window-restore-down-button"
/>
<toolbarbutton class="titlebar-button titlebar-close"
command="cmd_closeWindow"
data-l10n-id="browser-window-close-button"
/>
</hbox>
</hbox>`;
let boxes = document.querySelectorAll(".titlebar-buttonbox-container");
boxes.forEach((box) => box.replaceWith(MozXULElement.parseXULToFragment(this.markup)));
}
}
new FixTitlebarTooltips();
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ Adds a toolbar button that implements the color picker without launching the dev

</details>

#### [Fix Titlebar Button Tooltips](/JS/fixTitlebarTooltips.uc.js):

\* This script is important if you use my theme or if you customize Firefox's tooltips on your own. Without it, the titlebar buttons' tooltips can't be styled. Since [bug 1718629](https://bugzilla.mozilla.org/show_bug.cgi?id=1718629), Firefox has tried to make the titlebar buttons (window controls) function more like native controls. In doing so, it allows the OS to draw tooltips for these buttons. So it prevents itself from showing redundant tooltips. That means we can't style the titlebar buttons' tooltips, they don't obey preferences, they disappear after 5 seconds on Windows, and they don't appear at all in fullscreen mode. Personally I would not be a fan of this change even if I didn't heavily customize Firefox's tooltips, because no matter what, OS tooltips are not going to be consistent with Firefox's tooltips, for reasons I mentioned. But in any case, we can fix this issue with JavaScript. If you were curious, it's caused by the [_titlebar-btn_](https://searchfox.org/mozilla-central/source/browser/base/content/titlebar-items.inc.xhtml#8) attribute.

#### [Floating Sidebar Resizer](/JS/floatingSidebarResizer.uc.js):

\* [uc-sidebar.css](/uc-sidebar.css) makes the sidebar float over the content without flexing it, but that changes the way sidebar resizing works. This script is required to make the floating sidebar resizable. It also optionally improves the hotkeys a little bit so that Ctrl+B (or Cmd+B) toggles the sidebar on/off instead of exclusively opening the bookmarks sidebar. Instead the hotkey to jump to the bookmarks sidebar has been remapped to Ctrl+Shift+B. This key combination normally toggles the bookmarks toolbar on and off, but I figured it was worth replacing, since you probably either never use the bookmarks toolbar, or keep it open it all the time. Whereas the sidebar is something you're going to want to turn off when you're done using it, since it takes up a lot of space. My stylesheet makes the bookmarks toolbar hide automatically and only show when the navbar is being hovered, so a hotkey isn't really necessary. (bookmarks toolbar hiding is further enhanced with [Auto-hide Navbar Support](#auto-hide-navbar-support), FYI)
Expand Down
4 changes: 4 additions & 0 deletions uc-app-menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@
list-style-image: url(chrome://userchrome/content/skin/fullscreen.svg) !important;
}

#appMenu-fullscreen-button2[checked] {
list-style-image: url(chrome://userchrome/content/skin/fullscreen-exit.svg) !important;
}

#appMenu-fxa-status2 > #appMenu-fxa-label2 {
padding-block: 4px !important;
min-height: 40px !important;
Expand Down
46 changes: 28 additions & 18 deletions uc-tabs-bar.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,18 @@ this sheet controls their appearance as well. */
}

/* macOS style window controls */
.titlebar-button {
.titlebar-button,
.uc-titlebar-button {
display: -moz-box !important;
border: none;
margin: 0 !important;
padding: 8px 17px;
-moz-context-properties: stroke;
stroke: currentColor;
}

:root:not([sizemode="maximized"], [inFullscreen]) .titlebar-restore,
:root:is([sizemode="maximized"], [inFullscreen]) .titlebar-max {
:root:not([sizemode="maximized"], [inFullscreen]) :is(.titlebar-restore, .uc-titlebar-restore),
:root:is([sizemode="maximized"], [inFullscreen]) :is(.titlebar-max, .uc-titlebar-max) {
display: none !important;
}

Expand All @@ -259,7 +265,7 @@ this sheet controls their appearance as well. */
opacity: 1 !important;
}

.titlebar-button > .toolbarbutton-icon {
:is(.titlebar-button, .uc-titlebar-button) > .toolbarbutton-icon {
appearance: none !important;
width: 15.3px !important;
height: 15.3px !important;
Expand All @@ -271,7 +277,9 @@ this sheet controls their appearance as well. */
}

.titlebar-max,
.titlebar-restore {
.uc-titlebar-max,
.titlebar-restore,
.uc-titlebar-restore {
appearance: none !important;
padding: 0px !important;
padding-left: 7px !important;
Expand All @@ -287,16 +295,16 @@ this sheet controls their appearance as well. */
-moz-box-ordinal-group: 1 !important;
}

.titlebar-max:hover {
:is(.titlebar-max, .uc-titlebar-max):hover {
list-style-image: url(chrome://userchrome/content/window/maximize-hover.svg) !important;
}

:root:is([sizemode="maximized"], [inFullscreen]) .titlebar-max:hover,
.titlebar-restore:hover {
:root:is([sizemode="maximized"], [inFullscreen]) :is(.titlebar-max, .uc-titlebar-max):hover,
:is(.titlebar-restore, .uc-titlebar-restore):hover {
list-style-image: url(chrome://userchrome/content/window/maximize-restore.svg) !important;
}

.titlebar-min {
:is(.titlebar-min, .uc-titlebar-min) {
appearance: none !important;
padding: 0px !important;
padding-left: 7px !important;
Expand All @@ -310,11 +318,12 @@ this sheet controls their appearance as well. */
-moz-box-ordinal-group: 2 !important;
}

.titlebar-min:hover {
:is(.titlebar-min, .uc-titlebar-min):hover {
list-style-image: url(chrome://userchrome/content/window/minimize-hover.svg) !important;
}

.titlebar-close {
.titlebar-close,
.uc-titlebar-close {
appearance: none !important;
padding: 0px !important;
padding-left: 7px !important;
Expand All @@ -328,7 +337,7 @@ this sheet controls their appearance as well. */
-moz-box-ordinal-group: 3 !important;
}

.titlebar-close:hover {
:is(.titlebar-close, .uc-titlebar-close):hover {
list-style-image: url(chrome://userchrome/content/window/close-hover.svg) !important;
}

Expand Down Expand Up @@ -606,15 +615,15 @@ panelview .all-tabs-button:not([disabled], [open]):focus {
-moz-box-ordinal-group: 0 !important;
}

:root:is([operatingsystem="macosx"], [operatingsystem="linux"]) :is(.titlebar-min, #minimize-button) {
:root:is([operatingsystem="macosx"], [operatingsystem="linux"]) :is(.titlebar-min, .uc-titlebar-min) {
-moz-box-ordinal-group: 2 !important;
}

:root:is([operatingsystem="macosx"], [operatingsystem="linux"]) :is(.titlebar-max, .titlebar-restore, #restore-button) {
:root:is([operatingsystem="macosx"], [operatingsystem="linux"]) :is(.titlebar-max, .uc-titlebar-max, .titlebar-restore, .uc-titlebar-restore) {
-moz-box-ordinal-group: 3 !important;
}

:root:is([operatingsystem="macosx"], [operatingsystem="linux"]) :is(.titlebar-close, #close-button) {
:root:is([operatingsystem="macosx"], [operatingsystem="linux"]) :is(.titlebar-close, .uc-titlebar-close) {
-moz-box-ordinal-group: 1 !important;
}

Expand Down Expand Up @@ -670,18 +679,19 @@ panelview .all-tabs-button:not([disabled], [open]):focus {
}

.titlebar-min,
#minimize-button {
.uc-titlebar-min {
-moz-box-ordinal-group: 2 !important;
}

.titlebar-max,
.uc-titlebar-max,
.titlebar-restore,
#restore-button {
.uc-titlebar-restore {
-moz-box-ordinal-group: 3 !important;
}

.titlebar-close,
#close-button {
.uc-titlebar-close {
-moz-box-ordinal-group: 1 !important;
}

Expand Down
6 changes: 6 additions & 0 deletions userChrome.ag.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ and in particular, tooltips and scrollbars. */

@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
@namespace html url(http://www.w3.org/1999/xhtml);
@namespace parsererror url(http://www.mozilla.org/newlayout/xml/parsererror.xml);

/* browser scrollbars */
scrollbar {
Expand Down Expand Up @@ -394,3 +395,8 @@ html|progress:not([value]):indeterminate::-moz-progress-bar {
html|*.videocontrols .controlBar {
background-color: var(--content-principal-box-background);
}

parsererror|parsererror {
color: var(--plaintext-color) !important;
background-color: var(--in-content-bg-dark) !important;
}
2 changes: 1 addition & 1 deletion userChrome.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@author aminomancer
@homepage https://github.com/aminomancer
@description A dark indigo theme integrated with extensive functional and visual scripts.
This stylesheet is just used to load all the other parent-process stylesheets into the chrome window.
This stylesheet is just used to load all the individual parent-process stylesheets into chrome windows.
*/

@import url(uc-globals.css);
Expand Down
2 changes: 2 additions & 0 deletions utils/chrome.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ override chrome://browser/skin/places/folder-smart.svg ../resources/material/pla
override chrome://browser/skin/places/tag.svg ../resources/material/places/tag.svg
override chrome://browser/skin/places/history.svg ../resources/skin/history.svg
override chrome://browser/skin/downloads/downloads.svg ../resources/downloads/downloads.svg
override chrome://browser/skin/fullscreen.svg ../resources/skin/fullscreen.svg
override chrome://browser/skin/fullscreen-exit.svg ../resources/skin/fullscreen-exit.svg
override chrome://browser/skin/preferences/android-menu.svg ../resources/preferences/android-menu.svg
override chrome://browser/skin/preferences/category-general.svg ../resources/preferences/category-general.svg
override chrome://browser/skin/preferences/category-privacy-security.svg ../resources/preferences/category-privacy-security.svg
Expand Down

0 comments on commit add1784

Please sign in to comment.