From 869807f437dde1213ed1aae2ef637b5ea7df9b90 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Wed, 4 Dec 2024 13:12:05 +1300 Subject: [PATCH] Remove unconditional root restyle hint --- packages/blitz-dom/src/node.rs | 8 ++++---- packages/blitz-dom/src/stylo.rs | 22 ---------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/packages/blitz-dom/src/node.rs b/packages/blitz-dom/src/node.rs index 68d7ff95..d05a3aa3 100644 --- a/packages/blitz-dom/src/node.rs +++ b/packages/blitz-dom/src/node.rs @@ -198,25 +198,25 @@ impl Node { pub fn hover(&mut self) { self.is_hovered = true; self.element_state.insert(ElementState::HOVER); - self.set_restyle_hint(RestyleHint::RESTYLE_SELF); + self.set_restyle_hint(RestyleHint::restyle_subtree()); } pub fn unhover(&mut self) { self.is_hovered = false; self.element_state.remove(ElementState::HOVER); - self.set_restyle_hint(RestyleHint::RESTYLE_SELF); + self.set_restyle_hint(RestyleHint::restyle_subtree()); } pub fn focus(&mut self) { self.element_state .insert(ElementState::FOCUS | ElementState::FOCUSRING); - self.set_restyle_hint(RestyleHint::RESTYLE_SELF); + self.set_restyle_hint(RestyleHint::restyle_subtree()); } pub fn blur(&mut self) { self.element_state .remove(ElementState::FOCUS | ElementState::FOCUSRING); - self.set_restyle_hint(RestyleHint::RESTYLE_SELF); + self.set_restyle_hint(RestyleHint::restyle_subtree()); } } diff --git a/packages/blitz-dom/src/stylo.rs b/packages/blitz-dom/src/stylo.rs index bffd235a..fdace87e 100644 --- a/packages/blitz-dom/src/stylo.rs +++ b/packages/blitz-dom/src/stylo.rs @@ -19,7 +19,6 @@ use selectors::{ }; use style::applicable_declarations::ApplicableDeclarationBlock; use style::color::AbsoluteColor; -use style::invalidation::element::restyle_hints::RestyleHint; use style::properties::{Importance, PropertyDeclaration}; use style::rule_tree::CascadeLevel; use style::selector_parser::PseudoElement; @@ -158,17 +157,6 @@ impl crate::document::Document { pub fn resolve_stylist(&mut self) { style::thread_state::enter(ThreadState::LAYOUT); - self.iter_subtree_mut(self.root_node().id, |node_id, doc| { - doc.snapshot_node(node_id); - let node = &doc.nodes[node_id]; - let mut stylo_element_data = node.stylo_element_data.borrow_mut(); - if let Some(data) = &mut *stylo_element_data { - data.hint |= RestyleHint::restyle_subtree(); - data.hint |= RestyleHint::recascade_subtree(); - data.hint |= RestyleHint::RESTYLE_PSEUDOS; - } - }); - let guard = &self.guard; let guards = StylesheetGuards { author: &guard.read(), @@ -181,16 +169,6 @@ impl crate::document::Document { .as_element() .unwrap(); - // Force restyle all nodes - // TODO: finer grained style invalidation - let mut stylo_element_data = root.stylo_element_data.borrow_mut(); - if let Some(data) = &mut *stylo_element_data { - data.hint |= RestyleHint::restyle_subtree(); - data.hint |= RestyleHint::recascade_subtree(); - data.hint |= RestyleHint::RESTYLE_PSEUDOS; - } - drop(stylo_element_data); - self.stylist .flush(&guards, Some(root), Some(&self.snapshots));