@@ -10,7 +10,7 @@ use context::SharedStyleContext;
10
10
use dom:: TElement ;
11
11
use properties:: ComputedValues ;
12
12
use properties:: longhands:: display:: computed_value as display;
13
- use restyle_hints:: { RESTYLE_DESCENDANTS , RESTYLE_LATER_SIBLINGS , RESTYLE_SELF , RestyleHint } ;
13
+ use restyle_hints:: { RestyleReplacements , RestyleHint } ;
14
14
use rule_tree:: StrongRuleNode ;
15
15
use selector_parser:: { EAGER_PSEUDO_COUNT , PseudoElement , RestyleDamage } ;
16
16
use shared_lock:: StylesheetGuards ;
@@ -198,21 +198,18 @@ impl StoredRestyleHint {
198
198
// In the middle of an animation only restyle, we don't need to
199
199
// propagate any restyle hints, and we need to remove ourselves.
200
200
if traversal_flags. for_animation_only ( ) {
201
- self . 0 . remove ( RestyleHint :: for_animations ( ) ) ;
201
+ self . 0 . remove_animation_hints ( ) ;
202
202
return Self :: empty ( ) ;
203
203
}
204
204
205
- debug_assert ! ( !self . 0 . intersects ( RestyleHint :: for_animations ( ) ) ,
205
+ debug_assert ! ( !self . 0 . has_animation_hint ( ) ,
206
206
"There should not be any animation restyle hints \
207
207
during normal traversal") ;
208
208
209
209
// Else we should clear ourselves, and return the propagated hint.
210
- let hint = mem:: replace ( & mut self . 0 , RestyleHint :: empty ( ) ) ;
211
- StoredRestyleHint ( if hint. contains ( RESTYLE_DESCENDANTS ) {
212
- RESTYLE_SELF | RESTYLE_DESCENDANTS
213
- } else {
214
- RestyleHint :: empty ( )
215
- } )
210
+ let new_hint = mem:: replace ( & mut self . 0 , RestyleHint :: empty ( ) )
211
+ . propagate_for_non_animation_restyle ( ) ;
212
+ StoredRestyleHint ( new_hint)
216
213
}
217
214
218
215
/// Creates an empty `StoredRestyleHint`.
@@ -223,25 +220,25 @@ impl StoredRestyleHint {
223
220
/// Creates a restyle hint that forces the whole subtree to be restyled,
224
221
/// including the element.
225
222
pub fn subtree ( ) -> Self {
226
- StoredRestyleHint ( RESTYLE_SELF | RESTYLE_DESCENDANTS )
223
+ StoredRestyleHint ( RestyleHint :: subtree ( ) )
227
224
}
228
225
229
226
/// Creates a restyle hint that forces the element and all its later
230
227
/// siblings to have their whole subtrees restyled, including the elements
231
228
/// themselves.
232
229
pub fn subtree_and_later_siblings ( ) -> Self {
233
- StoredRestyleHint ( RESTYLE_SELF | RESTYLE_DESCENDANTS | RESTYLE_LATER_SIBLINGS )
230
+ StoredRestyleHint ( RestyleHint :: subtree_and_later_siblings ( ) )
234
231
}
235
232
236
233
/// Returns true if the hint indicates that our style may be invalidated.
237
234
pub fn has_self_invalidations ( & self ) -> bool {
238
- self . 0 . intersects ( RestyleHint :: for_self ( ) )
235
+ self . 0 . affects_self ( )
239
236
}
240
237
241
238
/// Returns true if the hint indicates that our sibling's style may be
242
239
/// invalidated.
243
240
pub fn has_sibling_invalidations ( & self ) -> bool {
244
- self . 0 . intersects ( RESTYLE_LATER_SIBLINGS )
241
+ self . 0 . affects_later_siblings ( )
245
242
}
246
243
247
244
/// Whether the restyle hint is empty (nothing requires to be restyled).
@@ -250,13 +247,18 @@ impl StoredRestyleHint {
250
247
}
251
248
252
249
/// Insert another restyle hint, effectively resulting in the union of both.
253
- pub fn insert ( & mut self , other : & Self ) {
254
- self . 0 |= other. 0
250
+ pub fn insert ( & mut self , other : Self ) {
251
+ self . 0 . insert ( other. 0 )
252
+ }
253
+
254
+ /// Insert another restyle hint, effectively resulting in the union of both.
255
+ pub fn insert_from ( & mut self , other : & Self ) {
256
+ self . 0 . insert_from ( & other. 0 )
255
257
}
256
258
257
259
/// Returns true if the hint has animation-only restyle.
258
260
pub fn has_animation_hint ( & self ) -> bool {
259
- self . 0 . intersects ( RestyleHint :: for_animations ( ) )
261
+ self . 0 . has_animation_hint ( )
260
262
}
261
263
}
262
264
@@ -356,7 +358,7 @@ pub enum RestyleKind {
356
358
MatchAndCascade ,
357
359
/// We need to recascade with some replacement rule, such as the style
358
360
/// attribute, or animation rules.
359
- CascadeWithReplacements ( RestyleHint ) ,
361
+ CascadeWithReplacements ( RestyleReplacements ) ,
360
362
/// We only need to recascade, for example, because only inherited
361
363
/// properties in the parent changed.
362
364
CascadeOnly ,
@@ -381,7 +383,7 @@ impl ElementData {
381
383
context. traversal_flags) ;
382
384
383
385
let mut hint = match self . get_restyle ( ) {
384
- Some ( r) => r. hint . 0 ,
386
+ Some ( r) => r. hint . 0 . clone ( ) ,
385
387
None => RestyleHint :: empty ( ) ,
386
388
} ;
387
389
@@ -393,7 +395,7 @@ impl ElementData {
393
395
element. implemented_pseudo_element( ) ) ;
394
396
395
397
if element. has_snapshot ( ) && !element. handled_snapshot ( ) {
396
- hint |= context. stylist . compute_restyle_hint ( & element, context. snapshot_map ) ;
398
+ hint. insert ( context. stylist . compute_restyle_hint ( & element, context. snapshot_map ) ) ;
397
399
unsafe { element. set_handled_snapshot ( ) }
398
400
debug_assert ! ( element. handled_snapshot( ) ) ;
399
401
}
@@ -402,8 +404,7 @@ impl ElementData {
402
404
403
405
// If the hint includes a directive for later siblings, strip it out and
404
406
// notify the caller to modify the base hint for future siblings.
405
- let later_siblings = hint. contains ( RESTYLE_LATER_SIBLINGS ) ;
406
- hint. remove ( RESTYLE_LATER_SIBLINGS ) ;
407
+ let later_siblings = hint. remove_later_siblings_hint ( ) ;
407
408
408
409
// Insert the hint, overriding the previous hint. This effectively takes
409
410
// care of removing the later siblings restyle hint.
@@ -445,13 +446,13 @@ impl ElementData {
445
446
debug_assert ! ( self . restyle. is_some( ) ) ;
446
447
let restyle_data = self . restyle . as_ref ( ) . unwrap ( ) ;
447
448
448
- let hint = restyle_data. hint . 0 ;
449
- if hint. contains ( RESTYLE_SELF ) {
449
+ let hint = & restyle_data. hint . 0 ;
450
+ if hint. match_self ( ) {
450
451
return RestyleKind :: MatchAndCascade ;
451
452
}
452
453
453
454
if !hint. is_empty ( ) {
454
- return RestyleKind :: CascadeWithReplacements ( hint) ;
455
+ return RestyleKind :: CascadeWithReplacements ( hint. replacements ) ;
455
456
}
456
457
457
458
debug_assert ! ( restyle_data. recascade,
0 commit comments