aboutsummaryrefslogtreecommitdiffstats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-11-26 22:54:21 +0100
committerbptato <nincsnevem662@gmail.com>2024-11-26 23:05:49 +0100
commit58da6cf90ce80f0bfc77a5ebd6603bec0cbc240c (patch)
tree978921e212763eb5cfc034a64876edbb88f4bc4f /src/css
parent14c4a11eaaea5dfa13afb6f44ab9531a90445f36 (diff)
downloadchawan-58da6cf90ce80f0bfc77a5ebd6603bec0cbc240c.tar.gz
buffer: optimize hover switching
Fixed a bug that would lead to styles unnecessarily being recalculated if the root element had a :hover dependency.
Diffstat (limited to 'src/css')
-rw-r--r--src/css/match.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/css/match.nim b/src/css/match.nim
index 51dd9a6e..695f2404 100644
--- a/src/css/match.nim
+++ b/src/css/match.nim
@@ -77,6 +77,12 @@ func pseudoSelectorMatches(element: Element; sel: Selector;
return element.parentNode.firstElementChild == element and
element.parentNode.lastElementChild == element
of pcHover:
+ #TODO this is somewhat problematic.
+ # e.g. if there is a rule like ".class :hover", then you set
+ # dtHover for basically every element, even if most of them are not
+ # a .class descendant.
+ # Ideally we should try to match the rest of the selector before
+ # attaching dependencies in general.
depends.add(element, dtHover)
return element.hover
of pcRoot: return element == element.document.documentElement