From 20727133f34785e06124c374fe1bce919b175f2e Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Fri, 24 Nov 2023 23:14:12 +0100 Subject: [PATCH] previewer: Set CSS priority to APPLICATION --- src/Previewer/Internal.js | 5 ++--- src/Previewer/Previewer.js | 24 ------------------------ src/Previewer/previewer.vala | 3 +-- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/src/Previewer/Internal.js b/src/Previewer/Internal.js index 8e35d75fd..ba768dbe0 100644 --- a/src/Previewer/Internal.js +++ b/src/Previewer/Internal.js @@ -215,8 +215,7 @@ export default function Internal({ Gtk.StyleContext.add_provider_for_display( output.get_display(), css_provider, - // STYLE_PROVIDER_PRIORITY_THEME is 200; only values below that behave correctly - Gtk.STYLE_PROVIDER_PRIORITY_THEME - 1, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION, ); } @@ -245,7 +244,7 @@ export default function Internal({ // https://github.com/prettier/prettier/issues/9114 // We are not using https://github.com/pazams/postcss-scopify // because it's not compatible with postcss 8 -export function scopeStylesheet(style, id) { +function scopeStylesheet(style, id) { const ast = postcss.parse(style); id = id || "workbench_output"; diff --git a/src/Previewer/Previewer.js b/src/Previewer/Previewer.js index 732ac57a5..992012e72 100644 --- a/src/Previewer/Previewer.js +++ b/src/Previewer/Previewer.js @@ -6,7 +6,6 @@ import Gio from "gi://Gio"; import { gettext as _ } from "gettext"; import * as xml from "../langs/xml/xml.js"; -import * as postcss from "../lib/postcss.js"; import { encode, @@ -333,29 +332,6 @@ export default function Previewer({ }; } -// We are using postcss because it's also a dependency of prettier -// it would be great to keep the ast around and pass that to prettier -// so there is no need to re-parse but that's not supported yet -// https://github.com/prettier/prettier/issues/9114 -// We are not using https://github.com/pazams/postcss-scopify -// because it's not compatible with postcss 8 -export function scopeStylesheet(style) { - const ast = postcss.parse(style); - - for (const node of ast.nodes) { - if (node.selector) { - node.selector = `#workbench_output ${node.selector}`; - } - } - - let str = ""; - postcss.stringify(ast, (s) => { - str += s; - }); - - return str; -} - function getTemplate(tree) { const template = tree.getChild("template"); if (!template) return; diff --git a/src/Previewer/previewer.vala b/src/Previewer/previewer.vala index 21e1389eb..d0be54cc4 100644 --- a/src/Previewer/previewer.vala +++ b/src/Previewer/previewer.vala @@ -128,8 +128,7 @@ namespace Workbench { Gtk.StyleContext.add_provider_for_display ( Gdk.Display.get_default (), this.css, - // STYLE_PROVIDER_PRIORITY_THEME is 200; only values below that behave correctly - Gtk.STYLE_PROVIDER_PRIORITY_THEME - 1); + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } public void run (string filename, string uri) {