From 98a04e7e1292b3a75b949416126e692f271f5b17 Mon Sep 17 00:00:00 2001 From: EnderDev Date: Wed, 17 Jan 2024 21:29:05 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Improve=20and=20refine=20styles?= =?UTF-8?q?=20for=20tooltips?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actors/DotUAStylesChild.sys.mjs | 30 ++++++++++++++++++++++++++++++ actors/moz.build | 1 + components/DotGlue.sys.mjs | 13 +++++++++++++ themes/shared/browser-shared.css | 1 + themes/shared/jar.inc.mn | 3 ++- themes/shared/xul/tooltip.css | 19 +++++++++++++++++++ 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 actors/DotUAStylesChild.sys.mjs create mode 100644 themes/shared/xul/tooltip.css diff --git a/actors/DotUAStylesChild.sys.mjs b/actors/DotUAStylesChild.sys.mjs new file mode 100644 index 0000000000..7773dc3b20 --- /dev/null +++ b/actors/DotUAStylesChild.sys.mjs @@ -0,0 +1,30 @@ +/* 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/. */ + +export class DotUAStylesChild extends JSWindowActorChild { + /** + * Loads a stylesheet into the browser frame + * @param {string} uri + */ + loadSheet(uri) { + const { windowUtils } = this.contentWindow; + + try { + windowUtils.loadSheetUsingURIString(uri, windowUtils.AGENT_SHEET); + } catch (e) {} + } + + init() { + this.loadSheet("chrome://dot/skin/tooltip.css"); + } + + handleEvent(event) { + switch (event.type) { + case "DOMDocElementInserted": + case "DOMContentLoaded": + this.init(); + break; + } + } +} diff --git a/actors/moz.build b/actors/moz.build index a0d366286f..861f71c19a 100644 --- a/actors/moz.build +++ b/actors/moz.build @@ -12,4 +12,5 @@ FINAL_TARGET_FILES.actors += [ "DotGeckoCommandsChild.sys.mjs", "DotLinkHandlerParent.sys.mjs", "DotPopupHandlerParent.sys.mjs", + "DotUAStylesChild.sys.mjs", ] diff --git a/components/DotGlue.sys.mjs b/components/DotGlue.sys.mjs index e5b3ff1095..7bc8fcc1bb 100644 --- a/components/DotGlue.sys.mjs +++ b/components/DotGlue.sys.mjs @@ -99,6 +99,19 @@ const JSWINDOWACTORS = { allFrames: true }, + DotUAStyles: { + child: { + esModuleURI: "resource:///actors/DotUAStylesChild.sys.mjs", + + events: { + DOMDocElementInserted: { capture: true }, + DOMContentLoaded: { capture: true } + } + }, + + includeChrome: true + }, + LightweightTheme: { child: { esModuleURI: "resource:///actors/LightweightThemeChild.sys.mjs", diff --git a/themes/shared/browser-shared.css b/themes/shared/browser-shared.css index d1a30f24a3..df9080072d 100644 --- a/themes/shared/browser-shared.css +++ b/themes/shared/browser-shared.css @@ -37,6 +37,7 @@ /* XUL */ @import url("chrome://dot/skin/input.css"); +@import url("chrome://dot/skin/tooltip.css"); /* Define LWT variables */ :root { diff --git a/themes/shared/jar.inc.mn b/themes/shared/jar.inc.mn index 77780b4cf3..bcc4e09355 100644 --- a/themes/shared/jar.inc.mn +++ b/themes/shared/jar.inc.mn @@ -168,4 +168,5 @@ % override chrome://global/content/commonDialog.css chrome://dot/skin/dialog.css skin/classic/dot/dialog.css (../shared/xul/dialog.css) - skin/classic/dot/input.css (../shared/xul/input.css) \ No newline at end of file + skin/classic/dot/input.css (../shared/xul/input.css) + skin/classic/dot/tooltip.css (../shared/xul/tooltip.css) \ No newline at end of file diff --git a/themes/shared/xul/tooltip.css b/themes/shared/xul/tooltip.css new file mode 100644 index 0000000000..a430175f80 --- /dev/null +++ b/themes/shared/xul/tooltip.css @@ -0,0 +1,19 @@ +/* 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/. */ + +@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); +@namespace html url("http://www.w3.org/1999/xhtml"); + +tooltip, +html|tooltip { + appearance: none; + + padding: 8px 10px; + + background-color: InfoBackground; + color: InfoText; + + border-radius: 10px; + border: 1px solid color-mix(in srgb, currentColor 20%, transparent 100%); +} \ No newline at end of file