@@ -9,7 +9,7 @@ use context::{SharedStyleContext, StyleContext, ThreadLocalStyleContext};
9
9
use data:: { ElementData , ElementStyles , StoredRestyleHint } ;
10
10
use dom:: { DirtyDescendants , NodeInfo , OpaqueNode , TElement , TNode } ;
11
11
use matching:: { ChildCascadeRequirement , MatchMethods , StyleSharingBehavior } ;
12
- use restyle_hints:: RestyleHint ;
12
+ use restyle_hints:: { HintComputationContext , RestyleHint } ;
13
13
use selector_parser:: RestyleDamage ;
14
14
#[ cfg( feature = "servo" ) ] use servo_config:: opts;
15
15
use std:: borrow:: BorrowMut ;
@@ -123,7 +123,8 @@ pub trait DomTraversal<E: TElement> : Sync {
123
123
type ThreadLocalContext : Send + BorrowMut < ThreadLocalStyleContext < E > > ;
124
124
125
125
/// Process `node` on the way down, before its children have been processed.
126
- fn process_preorder ( & self , data : & PerLevelTraversalData ,
126
+ fn process_preorder ( & self ,
127
+ data : & PerLevelTraversalData ,
127
128
thread_local : & mut Self :: ThreadLocalContext ,
128
129
node : E :: ConcreteNode ) ;
129
130
@@ -227,7 +228,10 @@ pub trait DomTraversal<E: TElement> : Sync {
227
228
// Expanding snapshots here may create a LATER_SIBLINGS restyle hint, which
228
229
// we propagate to the next sibling element.
229
230
if let Some ( mut data) = root. mutate_data ( ) {
230
- let later_siblings = data. compute_final_hint ( root, shared_context) ;
231
+ let later_siblings =
232
+ data. compute_final_hint ( root,
233
+ shared_context,
234
+ HintComputationContext :: Root ) ;
231
235
if later_siblings {
232
236
if let Some ( next) = root. next_sibling_element ( ) {
233
237
if let Some ( mut next_data) = next. mutate_data ( ) {
@@ -669,11 +673,12 @@ pub fn recalc_style_at<E, D>(traversal: &D,
669
673
r. damage_handled ( ) | r. damage . handled_for_descendants ( )
670
674
} ) ;
671
675
672
- preprocess_children ( traversal,
673
- element,
674
- propagated_hint,
675
- damage_handled,
676
- inherited_style_changed) ;
676
+ preprocess_children :: < E , D > ( context,
677
+ traversal_data,
678
+ element,
679
+ propagated_hint,
680
+ damage_handled,
681
+ inherited_style_changed) ;
677
682
}
678
683
679
684
// If we are in a restyle for reconstruction, drop the existing restyle
@@ -740,7 +745,8 @@ fn compute_style<E, D>(_traversal: &D,
740
745
MatchAndCascade => {
741
746
// Ensure the bloom filter is up to date.
742
747
context. thread_local . bloom_filter
743
- . insert_parents_recovering ( element, traversal_data. current_dom_depth ) ;
748
+ . insert_parents_recovering ( element,
749
+ traversal_data. current_dom_depth ) ;
744
750
745
751
context. thread_local . bloom_filter . assert_complete ( element) ;
746
752
context. thread_local . statistics . elements_matched += 1 ;
@@ -770,15 +776,17 @@ fn compute_style<E, D>(_traversal: &D,
770
776
}
771
777
}
772
778
773
- fn preprocess_children < E , D > ( traversal : & D ,
779
+ fn preprocess_children < E , D > ( context : & mut StyleContext < E > ,
780
+ parent_traversal_data : & PerLevelTraversalData ,
774
781
element : E ,
775
782
mut propagated_hint : StoredRestyleHint ,
776
783
damage_handled : RestyleDamage ,
777
784
parent_inherited_style_changed : bool )
778
785
where E : TElement ,
779
- D : DomTraversal < E >
786
+ D : DomTraversal < E > ,
780
787
{
781
788
trace ! ( "preprocess_children: {:?}" , element) ;
789
+
782
790
// Loop over all the children.
783
791
for child in element. as_node ( ) . children ( ) {
784
792
// FIXME(bholley): Add TElement::element_children instead of this.
@@ -787,7 +795,8 @@ fn preprocess_children<E, D>(traversal: &D,
787
795
None => continue ,
788
796
} ;
789
797
790
- let mut child_data = unsafe { D :: ensure_element_data ( & child) . borrow_mut ( ) } ;
798
+ let mut child_data =
799
+ unsafe { D :: ensure_element_data ( & child) . borrow_mut ( ) } ;
791
800
792
801
// If the child is unstyled, we don't need to set up any restyling.
793
802
if !child_data. has_styles ( ) {
@@ -798,7 +807,12 @@ fn preprocess_children<E, D>(traversal: &D,
798
807
//
799
808
// NB: This will be a no-op if there's no restyle data and no snapshot.
800
809
let later_siblings =
801
- child_data. compute_final_hint ( child, traversal. shared_context ( ) ) ;
810
+ child_data. compute_final_hint ( child,
811
+ & context. shared ,
812
+ HintComputationContext :: Child {
813
+ local_context : & mut context. thread_local ,
814
+ dom_depth : parent_traversal_data. current_dom_depth + 1 ,
815
+ } ) ;
802
816
803
817
trace ! ( " > {:?} -> {:?} + {:?}, pseudo: {:?}, later_siblings: {:?}" ,
804
818
child,
0 commit comments