Skip to content

Commit

Permalink
Remove unconditional root restyle hint
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Dec 4, 2024
1 parent 2b76e54 commit 869807f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
8 changes: 4 additions & 4 deletions packages/blitz-dom/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
22 changes: 0 additions & 22 deletions packages/blitz-dom/src/stylo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand All @@ -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));

Expand Down

0 comments on commit 869807f

Please sign in to comment.