Bug 1493145 - [CSD] Enable round corners by default by -moz-gtk-csd-transparent-background media query, r=dao
authorMartin Stransky <stransky@redhat.com>
Tue, 25 Sep 2018 11:53:04 +0000
changeset 493853 9bde1b9b0810e1c3eb170fbace15eb6aa250b637
parent 493852 59d4d98688e4cfd32a267f97720bc7fe07305b07
child 493854 9f3cde2c84c32a13568a610a74222be64553a6b7
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1493145
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1493145 - [CSD] Enable round corners by default by -moz-gtk-csd-transparent-background media query, r=dao Replace mozilla.widget.use-argb-visuals pref by -moz-gtk-csd-transparent-background media query at browser.css to draw transparent background. The media query is set by toolkit code and enabled when compatible window manager is detected. Differential Revision: https://phabricator.services.mozilla.com/D6658
browser/themes/linux/browser.css
layout/style/nsMediaFeatures.cpp
layout/style/test/chrome/bug418986-2.js
layout/style/test/test_media_queries.html
servo/components/style/gecko/media_features.rs
widget/LookAndFeel.h
widget/gtk/nsLookAndFeel.cpp
widget/headless/HeadlessLookAndFeelGTK.cpp
widget/nsXPLookAndFeel.cpp
xpcom/ds/StaticAtoms.py
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -633,20 +633,21 @@ notification[value="translation"] menuli
   #titlebar {
     display: none;
   }
 }
 
 /* We draw to titlebar when Gkt+ CSD is available */
 @media (-moz-gtk-csd-available) {
   /* Some Gtk+ themes use non-rectangular toplevel windows. To fully support
-   * such themes we need to make toplevel window transparent with ARGB visual.
-   * It may cause performanance issue so let's put it under a preference
-   * and allow distros to enable it per default theme. */
-  @supports -moz-bool-pref("mozilla.widget.use-argb-visuals") {
+   * such themes we need to make toplevel window transparent.
+   * It may cause performanance issues so let's put it under a preference
+   * and enable it for desktop environment which do that by default.
+   * See nsWindow::TopLevelWindowUseARGBVisual() for details. */
+  @media (-moz-gtk-csd-transparent-background) {
     :root[tabsintitlebar]:not(:-moz-lwtheme) {
       background-color: transparent;
       -moz-appearance: none;
     }
   }
 
   :root[tabsintitlebar] > #titlebar:-moz-lwtheme {
     visibility: hidden;
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -394,16 +394,22 @@ nsMediaFeatures::InitSystemMetrics()
   }
 
   rv = LookAndFeel::GetInt(LookAndFeel::eIntID_GTKCSDAvailable,
                            &metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::_moz_gtk_csd_available);
   }
 
+  rv = LookAndFeel::GetInt(LookAndFeel::eIntID_GTKCSDTransparentBackground,
+                           &metricResult);
+  if (NS_SUCCEEDED(rv) && metricResult) {
+    sSystemMetrics->AppendElement(nsGkAtoms::_moz_gtk_csd_transparent_background);
+  }
+
   rv = LookAndFeel::GetInt(LookAndFeel::eIntID_GTKCSDMinimizeButton,
                            &metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::_moz_gtk_csd_minimize_button);
   }
 
   rv = LookAndFeel::GetInt(LookAndFeel::eIntID_GTKCSDMaximizeButton,
                            &metricResult);
--- a/layout/style/test/chrome/bug418986-2.js
+++ b/layout/style/test/chrome/bug418986-2.js
@@ -49,16 +49,17 @@ var suppressed_toggles = [
   "-moz-scrollbar-start-backward",
   "-moz-scrollbar-start-forward",
   "-moz-scrollbar-thumb-proportional",
   "-moz-touch-enabled",
   "-moz-windows-compositor",
   "-moz-windows-default-theme",
   "-moz-windows-glass",
   "-moz-gtk-csd-available",
+  "-moz-gtk-csd-transparent-background",
   "-moz-gtk-csd-minimize-button",
   "-moz-gtk-csd-maximize-button",
   "-moz-gtk-csd-close-button",
 ];
 
 var toggles_enabled_in_content = [
   "-moz-touch-enabled",
 ];
--- a/layout/style/test/test_media_queries.html
+++ b/layout/style/test/test_media_queries.html
@@ -689,16 +689,17 @@ function run() {
   expression_should_not_be_parseable("-moz-mac-graphite-theme");
   expression_should_not_be_parseable("-moz-mac-yosemite-theme");
   expression_should_not_be_parseable("-moz-windows-accent-color-in-titlebar");
   expression_should_not_be_parseable("-moz-windows-compositor");
   expression_should_not_be_parseable("-moz-windows-classic");
   expression_should_not_be_parseable("-moz-windows-glass");
   expression_should_not_be_parseable("-moz-swipe-animation-enabled");
   expression_should_not_be_parseable("-moz-gtk-csd-available");
+  expression_should_not_be_parseable("-moz-gtk-csd-transparent-background");
   expression_should_not_be_parseable("-moz-gtk-csd-minimize-button");
   expression_should_not_be_parseable("-moz-gtk-csd-maximize-button");
   expression_should_not_be_parseable("-moz-gtk-csd-close-button");
   expression_should_be_parseable("-moz-touch-enabled");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: 0");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: 0");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: 0");
@@ -709,16 +710,17 @@ function run() {
   expression_should_not_be_parseable("-moz-mac-graphite-theme: 0");
   expression_should_not_be_parseable("-moz-mac-yosemite-theme: 0");
   expression_should_not_be_parseable("-moz-windows-accent-color-in-titlebar: 0");
   expression_should_not_be_parseable("-moz-windows-compositor: 0");
   expression_should_not_be_parseable("-moz-windows-classic: 0");
   expression_should_not_be_parseable("-moz-windows-glass: 0");
   expression_should_not_be_parseable("-moz-swipe-animation-enabled: 0");
   expression_should_not_be_parseable("-moz-gtk-csd-available: 0");
+  expression_should_not_be_parseable("-moz-gtk-csd-transparent-background: 0");
   expression_should_not_be_parseable("-moz-gtk-csd-minimize-button: 0");
   expression_should_not_be_parseable("-moz-gtk-csd-maximize-button: 0");
   expression_should_not_be_parseable("-moz-gtk-csd-close-button: 0");
   expression_should_be_parseable("-moz-touch-enabled: 0");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: 1");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: 1");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: 1");
@@ -729,16 +731,17 @@ function run() {
   expression_should_not_be_parseable("-moz-mac-graphite-theme: 1");
   expression_should_not_be_parseable("-moz-mac-yosemite-theme: 1");
   expression_should_not_be_parseable("-moz-windows-accent-color-in-titlebar: 1");
   expression_should_not_be_parseable("-moz-windows-compositor: 1");
   expression_should_not_be_parseable("-moz-windows-classic: 1");
   expression_should_not_be_parseable("-moz-windows-glass: 1");
   expression_should_not_be_parseable("-moz-swipe-animation-enabled: 1");
   expression_should_not_be_parseable("-moz-gtk-csd-available: 1");
+  expression_should_not_be_parseable("-moz-gtk-csd-transparent-background: 1");
   expression_should_not_be_parseable("-moz-gtk-csd-minimize-button: 1");
   expression_should_not_be_parseable("-moz-gtk-csd-maximize-button: 1");
   expression_should_not_be_parseable("-moz-gtk-csd-close-button: 1");
   expression_should_be_parseable("-moz-touch-enabled: 1");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: -1");
@@ -750,16 +753,17 @@ function run() {
   expression_should_not_be_parseable("-moz-mac-yosemite-theme: -1");
   expression_should_not_be_parseable("-moz-windows-accent-color-in-titlebar: -1");
   expression_should_not_be_parseable("-moz-windows-compositor: -1");
   expression_should_not_be_parseable("-moz-windows-classic: -1");
   expression_should_not_be_parseable("-moz-windows-glass: -1");
   expression_should_not_be_parseable("-moz-touch-enabled: -1");
   expression_should_not_be_parseable("-moz-swipe-animation-enabled: -1");
   expression_should_not_be_parseable("-moz-gtk-csd-available: -1");
+  expression_should_not_be_parseable("-moz-gtk-csd-transparent-background: -1");
   expression_should_not_be_parseable("-moz-gtk-csd-minimize-button: -1");
   expression_should_not_be_parseable("-moz-gtk-csd-maximize-button: -1");
   expression_should_not_be_parseable("-moz-gtk-csd-close-button: -1");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: true");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: true");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: true");
   expression_should_not_be_parseable("-moz-scrollbar-end-forward: true");
@@ -770,16 +774,17 @@ function run() {
   expression_should_not_be_parseable("-moz-mac-yosemite-theme: true");
   expression_should_not_be_parseable("-moz-windows-accent-color-in-titlebar: true");
   expression_should_not_be_parseable("-moz-windows-compositor: true");
   expression_should_not_be_parseable("-moz-windows-classic: true");
   expression_should_not_be_parseable("-moz-windows-glass: true");
   expression_should_not_be_parseable("-moz-touch-enabled: true");
   expression_should_not_be_parseable("-moz-swipe-animation-enabled: true");
   expression_should_not_be_parseable("-moz-gtk-csd-available: true");
+  expression_should_not_be_parseable("-moz-gtk-csd-transparent-background: true");
   expression_should_not_be_parseable("-moz-gtk-csd-minimize-button: true");
   expression_should_not_be_parseable("-moz-gtk-csd-maximize-button: true");
   expression_should_not_be_parseable("-moz-gtk-csd-close-button: true");
 
   // os version media queries (currently windows only)
   expression_should_not_be_parseable("-moz-os-version: windows-win7");
   expression_should_not_be_parseable("-moz-os-version: windows-win8");
   expression_should_not_be_parseable("-moz-os-version: windows-win10");
--- a/servo/components/style/gecko/media_features.rs
+++ b/servo/components/style/gecko/media_features.rs
@@ -474,17 +474,17 @@ macro_rules! system_metric_feature {
 }
 
 lazy_static! {
     /// Adding new media features requires (1) adding the new feature to this
     /// array, with appropriate entries (and potentially any new code needed
     /// to support new types in these entries and (2) ensuring that either
     /// nsPresContext::MediaFeatureValuesChanged is called when the value that
     /// would be returned by the evaluator function could change.
-    pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 47] = [
+    pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 48] = [
         feature!(
             atom!("width"),
             AllowsRanges::Yes,
             Evaluator::Length(eval_width),
             ParsingRequirements::empty(),
         ),
         feature!(
             atom!("height"),
@@ -655,16 +655,17 @@ lazy_static! {
         system_metric_feature!(atom!("-moz-mac-yosemite-theme")),
         system_metric_feature!(atom!("-moz-windows-accent-color-in-titlebar")),
         system_metric_feature!(atom!("-moz-windows-compositor")),
         system_metric_feature!(atom!("-moz-windows-classic")),
         system_metric_feature!(atom!("-moz-windows-glass")),
         system_metric_feature!(atom!("-moz-menubar-drag")),
         system_metric_feature!(atom!("-moz-swipe-animation-enabled")),
         system_metric_feature!(atom!("-moz-gtk-csd-available")),
+        system_metric_feature!(atom!("-moz-gtk-csd-transparent-background")),
         system_metric_feature!(atom!("-moz-gtk-csd-minimize-button")),
         system_metric_feature!(atom!("-moz-gtk-csd-maximize-button")),
         system_metric_feature!(atom!("-moz-gtk-csd-close-button")),
         system_metric_feature!(atom!("-moz-system-dark-theme")),
         // This is the only system-metric media feature that's accessible to
         // content as of today.
         // FIXME(emilio): Restrict (or remove?) when bug 1035774 lands.
         feature!(
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -414,16 +414,22 @@ public:
      /*
       * A boolean value indicating whether client-side decorations are
       * supported by the user's GTK version.
       */
      eIntID_GTKCSDAvailable,
 
      /*
       * A boolean value indicating whether client-side decorations should
+      * have transparent background.
+      */
+     eIntID_GTKCSDTransparentBackground,
+
+     /*
+      * A boolean value indicating whether client-side decorations should
       * contain a minimize button.
       */
      eIntID_GTKCSDMinimizeButton,
 
      /*
       * A boolean value indicating whether client-side decorations should
       * contain a maximize button.
       */
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -722,16 +722,19 @@ nsLookAndFeel::GetIntImpl(IntID aID, int
     case eIntID_GTKCSDMinimizeButton:
         EnsureInit();
         aResult = mCSDMinimizeButton;
         break;
     case eIntID_GTKCSDCloseButton:
         EnsureInit();
         aResult = mCSDCloseButton;
         break;
+    case eIntID_GTKCSDTransparentBackground:
+        aResult = nsWindow::TopLevelWindowUseARGBVisual();
+        break;
     case eIntID_PrefersReducedMotion: {
         GtkSettings *settings;
         gboolean enableAnimations;
 
         settings = gtk_settings_get_default();
         g_object_get(settings,
                      "gtk-enable-animations",
                      &enableAnimations, nullptr);
--- a/widget/headless/HeadlessLookAndFeelGTK.cpp
+++ b/widget/headless/HeadlessLookAndFeelGTK.cpp
@@ -275,16 +275,17 @@ HeadlessLookAndFeel::GetIntImpl(IntID aI
       break;
     case eIntID_ContextMenuOffsetVertical:
       aResult = -6;
       break;
     case eIntID_ContextMenuOffsetHorizontal:
       aResult = 1;
       break;
     case eIntID_GTKCSDAvailable:
+    case eIntID_GTKCSDTransparentBackground:
       aResult = 0;
       break;
     case eIntID_GTKCSDMinimizeButton:
       aResult = 0;
       break;
     case eIntID_GTKCSDMaximizeButton:
       aResult = 0;
       break;
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -121,16 +121,19 @@ nsLookAndFeelIntPref nsXPLookAndFeel::sI
     eIntID_ContextMenuOffsetVertical,
     false, 0 },
   { "ui.contextMenuOffsetHorizontal",
     eIntID_ContextMenuOffsetHorizontal,
     false, 0 },
   { "ui.GtkCSDAvailable",
     eIntID_GTKCSDAvailable,
     false, 0 },
+  { "ui.GtkCSDTransparentBackground",
+    eIntID_GTKCSDTransparentBackground,
+    false, 0 },
   { "ui.GtkCSDMinimizeButton",
     eIntID_GTKCSDMinimizeButton,
     false, 0 },
   { "ui.GtkCSDMaximizeButton",
     eIntID_GTKCSDMaximizeButton,
     false, 0 },
   { "ui.GtkCSDCloseButton",
     eIntID_GTKCSDCloseButton,
--- a/xpcom/ds/StaticAtoms.py
+++ b/xpcom/ds/StaticAtoms.py
@@ -2017,16 +2017,17 @@ STATIC_ATOMS = [
     Atom("_moz_os_version", "-moz-os-version"),
     Atom("_moz_touch_enabled", "-moz-touch-enabled"),
     Atom("_moz_menubar_drag", "-moz-menubar-drag"),
     Atom("_moz_device_pixel_ratio", "-moz-device-pixel-ratio"),
     Atom("_moz_device_orientation", "-moz-device-orientation"),
     Atom("_moz_is_resource_document", "-moz-is-resource-document"),
     Atom("_moz_swipe_animation_enabled", "-moz-swipe-animation-enabled"),
     Atom("_moz_gtk_csd_available", "-moz-gtk-csd-available"),
+    Atom("_moz_gtk_csd_transparent_background", "-moz-gtk-csd-transparent-background"),
     Atom("_moz_gtk_csd_minimize_button", "-moz-gtk-csd-minimize-button"),
     Atom("_moz_gtk_csd_maximize_button", "-moz-gtk-csd-maximize-button"),
     Atom("_moz_gtk_csd_close_button", "-moz-gtk-csd-close-button"),
     Atom("_moz_system_dark_theme", "-moz-system-dark-theme"),
 
     # application commands
     Atom("Back", "Back"),
     Atom("Forward", "Forward"),