Matthias Clasen
b4a9cf2bfb
Remove no longer needed code
...
We no longer use superset or any matchers to find changes.
2020-01-17 23:47:34 -05:00
Matthias Clasen
2a919a4d4f
Go back to the tree for computing change
2020-01-17 23:47:34 -05:00
Matthias Clasen
b2775d9bdd
Redo the way we compute change
...
Instead of expecting a superset matcher, call
gtk_css_selector_match_for_change while walking the tree with the
original matcher. This fixes the handling of :not while determining
changes.
2020-01-17 23:47:34 -05:00
Matthias Clasen
7d72703d54
Revert "Remove no longer used code"
...
This reverts commit 105acfe908
.
2020-01-17 23:47:34 -05:00
Matthias Clasen
93b5b487ae
cssmatcher: Change get_state to has_state
...
This matches all the other vfuncs, and it gets us
out of keeping several big state flag enumerations
in sync.
Update all callers.
2020-01-16 19:24:43 -05:00
Matthias Clasen
105acfe908
Remove no longer used code
...
We no longer consult the selector tree to find changes,
so this code is no longer needed.
2020-01-16 17:24:34 -05:00
Matthias Clasen
192a24fa1f
css: Track selected state separately
...
Like the previous change, this reduces the number of
css nodes reacting to parent-state changes. The remaining
parent-state cases here are due to :link.
Before (numbers from widget-factory with Adwaita):
2247 nodes
class 612
name 2246
id 2
first-child 148
last-child 156
state 2245
hover 562
disabled 859
backdrop 1080
sibling-name 63
sibling-disabled 51
parent-class 586
parent-name 788
parent-id 2
parent-first-child 78
parent-last-child 78
parent-state 236
parent-hover 5
parent-disabled 91
parent-backdrop 4
After:
2247 nodes
class 612
name 2246
id 2
first-child 148
last-child 156
state 2245
hover 562
disabled 859
backdrop 1080
selected 579
sibling-name 63
sibling-disabled 51
parent-class 586
parent-name 788
parent-id 2
parent-first-child 78
parent-last-child 78
parent-state 115
parent-hover 5
parent-disabled 91
parent-backdrop 4
parent-selected 144
2020-01-16 11:26:46 -05:00
Matthias Clasen
2426b9e23a
css: Track backdrop state separately
...
Like the previous change, this reduces the number of
css nodes reacting to parent-state changes.
Before (numbers from widget-factory with Adwaita):
2247 nodes
class 612
name 2246
id 2
first-child 148
last-child 156
state 2247
hover 562
disabled 859
sibling-name 63
sibling-disabled 51
parent-class 586
parent-name 788
parent-id 2
parent-first-child 78
parent-last-child 78
parent-state 236
parent-hover 5
parent-disabled 91
After:
2247 nodes
class 612
name 2246
id 2
first-child 148
last-child 156
state 2245
hover 562
disabled 859
backdrop 1080
sibling-name 63
sibling-disabled 51
parent-class 586
parent-name 788
parent-id 2
parent-first-child 78
parent-last-child 78
parent-state 236
parent-hover 5
parent-disabled 91
parent-backdrop 4
2020-01-16 11:25:04 -05:00
Matthias Clasen
64848aebf4
css: Track disabled state separately
...
Significantly reduces the number of nodes that react to
parent-state changes.
Before (numbers from widget-factory with Adwaita):
2247 nodes
class 612
name 2246
id 2
first-child 148
last-child 156
state 2247
hover 2247
sibling-name 63
sibling-state 51
parent-class 586
parent-name 788
parent-id 2
parent-first-child 78
parent-last-child 78
parent-state 2226
parent-hover 5
After:
2247 nodes
class 612
name 2246
id 2
first-child 148
last-child 156
state 2247
hover 562
disabled 859
sibling-name 63
sibling-disabled 51
parent-class 586
parent-name 788
parent-id 2
parent-first-child 78
parent-last-child 78
parent-state 236
parent-hover 5
parent-disabled 91
2020-01-16 11:23:25 -05:00
Matthias Clasen
fcceac6d11
css: Track hover state changes separately
...
The idea is that this reduce the amount of frequently
changing state that css nodes are sensitive to.
This is going to reduce the amount of style recomputation.
2020-01-16 11:17:48 -05:00
Benjamin Otte
292371932b
css: Handle invalid :not() selectors
...
We weren't correctly ending the ( ) block when encountering an error.
Testcases added.
Fixes #2281
2019-12-03 18:12:25 +01:00
Timm Bäder
d8df197489
cssprovider: Don't lookup on empty css providers
...
This should not have a huge performance impact, but debugging is easier
if we don't lookup in empty css providers.
2019-09-09 17:36:24 +02:00
Дилян Палаузов
6ded38de2b
Minor typos in the Documentation (a/an)
2019-08-25 12:52:46 +00:00
Benjamin Otte
e1cd996617
selector: Inlcude : sign when reporting errors
2019-04-12 19:34:28 +02:00
Benjamin Otte
e0a01ba174
css: Redo for new parser
...
This commit is still way too big, but I couldn't make it smaller.
It transitions the old CSS parser to the new parser. CSS parsing is now
tokenized, everything else is probably still buggy.
2019-04-12 19:34:28 +02:00
Benjamin Otte
7f99c1e588
cssparser: Split integer gettig into has/consume functions
...
We can't try to get an integer because ultimately integer getters
support the same shenanigans that numbers and percentages do with calc()
and whatnot.
2019-04-12 19:34:28 +02:00
Benjamin Otte
dce8c11b07
cssparser: Drop _gtk_css_parser_has_prefix()
...
Replace it with has_ident/has_function. The old function is a typical
string matching API, not a tokenizing one.
2019-04-12 19:34:28 +02:00
Benjamin Otte
7ccec19501
parser: Get rid of _gtk_css_parser_is_eof()
...
Use gtk_css_parser_has_token() instead.
2019-04-12 19:34:28 +02:00
Benjamin Otte
684b6459f1
cssparser: Get rid of _gtk_css_parser_begins_with()
...
Replace it with calls to gtk_css_parser_has_token().
2019-04-12 19:34:28 +02:00
Matthias Clasen
a8531605db
Some more interning
...
This avoids more strdups at startup.
2017-11-18 08:18:11 -05:00
Matthias Clasen
4209c1762d
Support the new state in CSS selectors
...
Make :focus(visible) match the new state.
2017-10-25 17:59:00 -04:00
Benjamin Otte
8549e62d85
Add default return values to switch statements
...
We are using g_assert_not_reached() without doing anything, assuming it
aborts the program. In release builds however, it is ignored.
2017-10-24 18:21:03 +02:00
Matthias Clasen
d3198536a4
Drop support for deprecated pseudo-classes
...
We no longer have any of those.
2017-09-17 17:04:16 -04:00
Daniel Boles
79bbd4aca5
cssselector: Ensure we do not index out of bounds
...
This would only happen if the last element was deprecated, but it should
be avoided anyway.
CID 1388852 (#1 of 1): Out-of-bounds read (OVERRUN)
12. overrun-local: Overrunning array pseudo_classes of 16 32-byte
elements at element index 16 (byte offset 512) using index i + 1U (which
evaluates to 16).
2017-08-01 20:17:02 +01:00
Timm Bäder
b52966a318
cssselector: Stop parsing deprecated selectors
2017-03-02 15:16:08 +01:00
Daniel Boles
a1239a9a6a
CssSelector: Fix warning for bad pseudo-class name
...
It was "Missing name of pseudo-class", but the real problem is exactly
the opposite: we /have/ been given a name, but it is not a valid one.
Change it to "Invalid name of pseudo-class" to minimise confusion.
2017-02-18 21:01:38 +00:00
Benjamin Otte
9b9b475f0a
API: stylecontext: Remove regions
2016-10-16 18:17:21 +02:00
Benjamin Otte
35c96c2c1f
Add braces to appease gcc
...
-ftrack-macro-expansion=0 doesn't like if statements without braces when
evaluating indentation levels.
2016-08-25 23:02:27 +02:00
Matthias Clasen
6108c646c5
cssselector: Don't invoke undefined behavior
...
Avoid undefined behavior in the calculation of some
hash values. Found by gcc's undefined behavior sanitizer.
2016-02-26 15:52:19 -05:00
Benjamin Otte
d48d3b359c
cssselector: Remove type references
...
We don't use types anymore.
2016-02-05 23:47:48 +01:00
Benjamin Otte
e8fca5bbbe
cssmatcher: Remove type argument from name matcher
...
We no longer use types when matching names.
2016-02-05 23:43:05 +01:00
Matthias Clasen
33bb1af277
css: Privately export a function to get pseudoclass names
...
This function centralizes the mapping for widget states
to pseudoclass names in one place, for easier maintenance.
2016-01-24 10:59:46 -05:00
Matthias Clasen
eb09bee492
css: Deprecate :sorted pseudo class
...
This was used with regions in GtkTreeView, and is not used
anymore, so deprecate it.
2015-12-27 18:37:19 -05:00
Matthias Clasen
f3069d7e94
css: Redo the pseudo class deprecation warnings
...
Putting the deprecated class behind the official variant does
not work for the case of :focus and :focused - we were matching
:focus and leave a dangling 'ed'. So, put the deprecated classes
before the official variant, and explicitly mark them as deprecated.
2015-12-27 17:32:11 -05:00
Matthias Clasen
b3dbf3f41c
Drop the :dnd syntax altogether
...
This was only introduced a few weeks ago. We don't need to keep
this around, now that we support the proper CSS syntax.
2015-12-25 22:58:28 -05:00
Matthias Clasen
c998fae5ac
Add deprecation warnings for pseudo states
...
Emit a deprecation error in the cases where we have
a CSS name for a custom pseudo class.
2015-12-25 22:58:28 -05:00
Matthias Clasen
158dbbc88f
Use CSS syntax for drop highlighting
...
I hadn't noticed the :drop() pseudo state in the CSS4 Selectors
spec when I added this a while ago. This commit renames
GTK_STATE_FLAG_DND to GTK_STATE_FLAG_DROP_ACTIVE and adds
:drop(active) as equivalent to the :dnd pseudo state.
2015-12-25 22:58:28 -05:00
Matthias Clasen
6f889e832c
css: Support CSS names for pseudo states
...
What we call :insensitive is called :disabled in CSS, and
:inconsistent is :indeterminate. Recognize these names, but
still support the old ones.
2015-12-21 08:26:58 -05:00
Matthias Clasen
cbde3ee01f
css: Add a :dnd pseudoclass
...
This will be used for drag highlighting.
2015-12-02 23:23:36 -05:00
Benjamin Otte
e3ddbc544c
cssselector: Print name and any selector first
...
When printing a "compound selector", make sure the name and universal
selectors are printed at the beginning and class, id, etc. selectors are
printed last.
2015-10-27 20:12:38 +01:00
Benjamin Otte
24dde6346a
API: cssselector: Stop supporting regions
...
The namespace that belonged to regions is supposed to be used for
CssNode names.
2015-10-22 16:42:46 +02:00
Benjamin Otte
385fda80b4
cssmatcher: Marshal name to matcher
...
... and use it in the node matcher.
Also rename function from _gtk_css_matcher_get_type() to
_gtk_css_matcher_get_name().
2015-10-22 16:35:14 +02:00
Chun-wei Fan
ac62479c9e
Fix Visual Studio Build Since a080cb4
...
The patch did not check for Visual Studio 2008 correctly, plus it
would break the build on later Visual Studio versions, as it should
be __popcnt(), not __popcount(). Fix that.
2015-09-23 23:24:36 +08:00
Emmanuele Bassi
a080cb40b9
Improve compiler detection for __builtin_popcount()
...
The popcount builtin was added in GCC after version 4.2 (which is what
some *BSDs are using), which means we need to be more specific when
using it than just asking for GCC.
While we're at it, we can improve the compiler detection, and use a
builtin popcount on Clang ≥ 3.1 and MSVC 2008.
https://bugzilla.gnome.org/show_bug.cgi?id=755455
2015-09-23 13:58:50 +01:00
Matthias Clasen
83d68ea107
css selector: Use a builtin to count bits
2015-09-12 11:24:43 -04:00
Matthias Clasen
11d3582333
css selector: Take advantage of interned strings
...
We know these strings are interned, no need to use strcmp or
g_str_hash for hem.
2015-09-12 11:24:42 -04:00
Matthias Clasen
a9481cb410
match_all: Only allocate an array when needed
...
My statistics show that more than half of all calls end up
with 0 matches, so we can avoid some overhead by not allocating
an array at all in this case.
2015-09-09 11:17:13 -04:00
Matthias Clasen
117b50f8fb
Optimize gtk_css_selector_match_all
...
We are dealing with really short lists here.
95% are < 10 matches, and the longest I've been able to record was 19.
So just do away with the hash table and do sorted insertion in
the array directly.
2015-09-09 11:17:13 -04:00
Matthias Clasen
0e86278fcc
css selector: Use the quarks we have
...
Unless I'm missing something, there is no reason to go from
quarks back to strings to implement hasing or comparison.
2015-09-09 06:32:47 -04:00
Benjamin Otte
69e396ea0a
cssselector: Report finer granularity for position changes
2015-07-06 15:33:50 +02:00