Only check StyleSheet dirty flag at the start (once) of operation

This commit is contained in:
Karl Seguin
2026-03-24 07:55:11 +08:00
parent c91eac17d0
commit d4bcfa974f

View File

@@ -199,6 +199,8 @@ fn rebuildIfDirty(self: *StyleManager) !void {
// By default only checks display:none.
// Walks up the tree to check ancestors.
pub fn isHidden(self: *StyleManager, el: *Element, cache: ?*VisibilityCache, options: CheckVisibilityOptions) bool {
self.rebuildIfDirty() catch return false;
var current: ?*Element = el;
while (current) |elem| {
@@ -283,8 +285,6 @@ fn isElementHidden(self: *StyleManager, el: *Element, options: CheckVisibilityOp
return false;
}
self.rebuildIfDirty() catch return false;
// Helper to check a single rule
const Ctx = struct {
display_none: *?bool,
@@ -378,6 +378,8 @@ fn isElementHidden(self: *StyleManager, el: *Element, options: CheckVisibilityOp
/// Checks inline style first - if set, skips stylesheet lookup.
/// Walks up the tree to check ancestors.
pub fn hasPointerEventsNone(self: *StyleManager, el: *Element, cache: ?*PointerEventsCache) bool {
self.rebuildIfDirty() catch return false;
var current: ?*Element = el;
while (current) |elem| {
@@ -417,9 +419,6 @@ fn elementHasPointerEventsNone(self: *StyleManager, el: *Element) bool {
return false;
}
// Check stylesheet rules
self.rebuildIfDirty() catch return false;
var result: ?bool = null;
var best_priority: u64 = 0;