[gtk/wip/otte/css: 15/16] selector: Make :not() selectors not radical



commit 5f6689757dac0668c5d6126e69678ea295dd2b09
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jan 27 02:49:36 2020 +0100

    selector: Make :not() selectors not radical
    
    :not() selectors cannot be radical because the bloomfilter only knows if
    a value is set in any of the nodes, but cannot determine the opposite
    (if a value is not set in at least one node), but that would be required
    for:not() selectors.
    However, this is very unlikely to happen in the real world, so it's not
    worth optimizing.
    
    Unfortunately, change tracking could know this, so by excluding the
    :not() selectors from radical changes, the change tracking will now pick
    them up. If that turns out to be a performance problem, we need to add a
    special category for radical not filters, so change tracking and bloom
    filters can deal with them.
    
    The testcase demonstrating the problem in widget-factory has been
    extrated and added.

 gtk/gtkcssselector.c                      |  2 +-
 testsuite/css/style/bloomfilter-not.css   |  1 +
 testsuite/css/style/bloomfilter-not.nodes | 20 ++++++++++++++
 testsuite/css/style/bloomfilter-not.ui    | 43 +++++++++++++++++++++++++++++++
 testsuite/css/style/meson.build           |  3 +++
 5 files changed, 68 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index bd1edb1240..8f4bbf0113 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -540,7 +540,7 @@ static const GtkCssSelectorClass GTK_CSS_SELECTOR_ ## c = { \
 \
 static const GtkCssSelectorClass GTK_CSS_SELECTOR_NOT_ ## c = { \
   "not_" G_STRINGIFY(n), \
-  ignore_for_change ? GTK_CSS_SELECTOR_CATEGORY_SIMPLE : GTK_CSS_SELECTOR_CATEGORY_SIMPLE_RADICAL, \
+  GTK_CSS_SELECTOR_CATEGORY_SIMPLE, \
   gtk_css_selector_not_ ## n ## _print, \
   gtk_css_selector_default_foreach_matcher, \
   gtk_css_selector_not_ ## n ## _match_one, \
diff --git a/testsuite/css/style/bloomfilter-not.css b/testsuite/css/style/bloomfilter-not.css
new file mode 100644
index 0000000000..8ffa7138ff
--- /dev/null
+++ b/testsuite/css/style/bloomfilter-not.css
@@ -0,0 +1 @@
+.linked:not(.vertical) > button:dir(ltr):not(:last-child) { color: pink; }
diff --git a/testsuite/css/style/bloomfilter-not.nodes b/testsuite/css/style/bloomfilter-not.nodes
new file mode 100644
index 0000000000..80bb1b234d
--- /dev/null
+++ b/testsuite/css/style/bloomfilter-not.nodes
@@ -0,0 +1,20 @@
+window.background.csd:dir(ltr)
+  decoration:dir(ltr)
+  headerbar.titlebar:dir(ltr)
+    box.horizontal.start:dir(ltr)
+    stackswitcher.linked:dir(ltr)
+      button.text-button.toggle:dir(ltr):checked
+        color: rgb(255,192,203); /* bug-bloomfilter.css:1:61-73 */
+
+        label:dir(ltr)
+      button.text-button.toggle:dir(ltr)
+        color: rgb(255,192,203); /* bug-bloomfilter.css:1:61-73 */
+
+        label:dir(ltr)
+      button.text-button.toggle:dir(ltr)
+        label:dir(ltr)
+    box.end.horizontal:dir(ltr)
+  stack:dir(ltr)
+    box.horizontal:dir(ltr)
+    box.horizontal:dir(ltr)
+    box.horizontal:dir(ltr)
diff --git a/testsuite/css/style/bloomfilter-not.ui b/testsuite/css/style/bloomfilter-not.ui
new file mode 100644
index 0000000000..cdbbfeb0ba
--- /dev/null
+++ b/testsuite/css/style/bloomfilter-not.ui
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkApplicationWindow" id="window1">
+    <child type="titlebar">
+      <object class="GtkHeaderBar">
+        <child type="title">
+          <object class="GtkStackSwitcher" id="stack_switcher">
+            <property name="stack">toplevel_stack</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkStack" id="toplevel_stack">
+        <property name="transition-duration">1000</property>
+        <child>
+          <object class="GtkStackPage">
+            <property name="title" translatable="yes">Page 1</property>
+            <property name="child">
+              <object class="GtkBox" />
+            </property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkStackPage">
+            <property name="title" translatable="yes">Page 2</property>
+            <property name="child">
+              <object class="GtkBox" />
+            </property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkStackPage">
+            <property name="title" translatable="yes">Page 3</property>
+            <property name="child">
+              <object class="GtkBox" />
+            </property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/css/style/meson.build b/testsuite/css/style/meson.build
index fa2515f313..3198b85c05 100644
--- a/testsuite/css/style/meson.build
+++ b/testsuite/css/style/meson.build
@@ -30,6 +30,9 @@ test_data = [
   'adjacent-states.css',
   'adjacent-states.nodes',
   'adjacent-states.ui',
+  'bloomfilter-not.css',
+  'bloomfilter-not.nodes',
+  'bloomfilter-not.ui',
   'colornames.css',
   'colornames.nodes',
   'colornames.ui',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]