mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
No tracing of nop traceable fields (#29926)
* Add `no_trace` option to JSTraceable derive * NoTrace wrapper * Port some types to no_trace schematics * Fixing my unsafe mistakes (not tracing traceables) * Add docs & safety guards for no_trace Safety guards (trait shenanigans) guarantees safety usage of `no_trace` * Port canvas_traits to no_trace * Port servo_media to no_trace * Port net_traits to no_trace * Port style to no_trace * Port webgpu to no_trace * Port script_traits to no_trace * Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace * unrooted_must_root lint in seperate file * Add trace_in_no_trace_lint as script_plugin * Composable types in must_not_have_traceable * Introduced HashMapTracedValues wrapper * `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>` * Port rest of servo's types to no_trace * Port html5ever, euclid, mime and http to no_trace * Port remaining externals to no_trace * Port webxr and Arc<Mutex<_>> * Fix spelling in notrace doc
This commit is contained in:
parent
66e0d543cf
commit
9514f670d1
167 changed files with 1903 additions and 1020 deletions
|
@ -13,6 +13,7 @@ use crate::dom::bindings::inheritance::Castable;
|
|||
use crate::dom::bindings::num::Finite;
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::trace::NoTrace;
|
||||
use crate::dom::event::Event;
|
||||
use crate::dom::node::{from_untrusted_node_address, window_from_node, Node, NodeDamage};
|
||||
use crate::dom::transitionevent::TransitionEvent;
|
||||
|
@ -35,13 +36,14 @@ use style::selector_parser::PseudoElement;
|
|||
#[unrooted_must_root_lint::must_root]
|
||||
pub(crate) struct Animations {
|
||||
/// The map of nodes to their animation states.
|
||||
#[no_trace]
|
||||
pub sets: DocumentAnimationSet,
|
||||
|
||||
/// Whether or not we have animations that are running.
|
||||
has_running_animations: Cell<bool>,
|
||||
|
||||
/// A list of nodes with in-progress CSS transitions or pending events.
|
||||
rooted_nodes: DomRefCell<FxHashMap<OpaqueNode, Dom<Node>>>,
|
||||
rooted_nodes: DomRefCell<FxHashMap<NoTrace<OpaqueNode>, Dom<Node>>>,
|
||||
|
||||
/// A list of pending animation-related events.
|
||||
pending_events: DomRefCell<Vec<TransitionOrAnimationEvent>>,
|
||||
|
@ -81,7 +83,10 @@ impl Animations {
|
|||
|
||||
let sets = self.sets.sets.read();
|
||||
let rooted_nodes = self.rooted_nodes.borrow();
|
||||
for node in sets.keys().filter_map(|key| rooted_nodes.get(&key.node)) {
|
||||
for node in sets
|
||||
.keys()
|
||||
.filter_map(|key| rooted_nodes.get(&NoTrace(key.node)))
|
||||
{
|
||||
node.dirty(NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
|
||||
|
@ -332,7 +337,7 @@ impl Animations {
|
|||
let mut rooted_nodes = self.rooted_nodes.borrow_mut();
|
||||
for (key, set) in sets.iter() {
|
||||
let opaque_node = key.node;
|
||||
if rooted_nodes.contains_key(&opaque_node) {
|
||||
if rooted_nodes.contains_key(&NoTrace(opaque_node)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -342,7 +347,7 @@ impl Animations {
|
|||
let address = UntrustedNodeAddress(opaque_node.0 as *const c_void);
|
||||
unsafe {
|
||||
rooted_nodes.insert(
|
||||
opaque_node,
|
||||
NoTrace(opaque_node),
|
||||
Dom::from_ref(&*from_untrusted_node_address(address)),
|
||||
)
|
||||
};
|
||||
|
@ -355,7 +360,7 @@ impl Animations {
|
|||
let pending_events = self.pending_events.borrow();
|
||||
let nodes: FxHashSet<OpaqueNode> = sets.keys().map(|key| key.node).collect();
|
||||
self.rooted_nodes.borrow_mut().retain(|node, _| {
|
||||
nodes.contains(&node) || pending_events.iter().any(|event| event.node == *node)
|
||||
nodes.contains(&node.0) || pending_events.iter().any(|event| event.node == node.0)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -459,7 +464,7 @@ impl Animations {
|
|||
for event in events.into_iter() {
|
||||
// We root the node here to ensure that sending this event doesn't
|
||||
// unroot it as a side-effect.
|
||||
let node = match self.rooted_nodes.borrow().get(&event.node) {
|
||||
let node = match self.rooted_nodes.borrow().get(&NoTrace(event.node)) {
|
||||
Some(node) => DomRoot::from_ref(&**node),
|
||||
None => {
|
||||
warn!("Tried to send an event for an unrooted node");
|
||||
|
@ -569,12 +574,15 @@ impl TransitionOrAnimationEventType {
|
|||
/// A transition or animation event.
|
||||
pub struct TransitionOrAnimationEvent {
|
||||
/// The pipeline id of the layout task that sent this message.
|
||||
#[no_trace]
|
||||
pub pipeline_id: PipelineId,
|
||||
/// The type of transition event this should trigger.
|
||||
pub event_type: TransitionOrAnimationEventType,
|
||||
/// The address of the node which owns this transition.
|
||||
#[no_trace]
|
||||
pub node: OpaqueNode,
|
||||
/// The pseudo element for this transition or animation, if applicable.
|
||||
#[no_trace]
|
||||
pub pseudo_element: Option<PseudoElement>,
|
||||
/// The name of the property that is transitioning (in the case of a transition)
|
||||
/// or the name of the animation (in the case of an animation).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue