6
6
7
7
use crate :: computed_value_flags:: ComputedValueFlags ;
8
8
use crate :: context:: { SharedStyleContext , StackLimitChecker } ;
9
- use crate :: dom:: TElement ;
9
+ use crate :: dom:: { TElement , TRestyleDamage } ;
10
10
use crate :: invalidation:: element:: invalidator:: InvalidationResult ;
11
11
use crate :: invalidation:: element:: restyle_hints:: RestyleHint ;
12
12
use crate :: properties:: ComputedValues ;
13
- use crate :: selector_parser:: { PseudoElement , RestyleDamage , EAGER_PSEUDO_COUNT } ;
13
+ use crate :: selector_parser:: { PseudoElement , EAGER_PSEUDO_COUNT } ;
14
14
use crate :: style_resolver:: { PrimaryStyle , ResolvedElementStyles , ResolvedStyle } ;
15
15
#[ cfg( feature = "gecko" ) ]
16
16
use malloc_size_of:: MallocSizeOfOps ;
@@ -249,13 +249,13 @@ impl fmt::Debug for ElementStyles {
249
249
/// inside of layout data, which itself hangs directly off the Element. In
250
250
/// both cases, it is wrapped inside an AtomicRefCell to ensure thread safety.
251
251
#[ derive( Debug , Default ) ]
252
- pub struct ElementData {
252
+ pub struct ElementData < E : TElement > {
253
253
/// The styles for the element and its pseudo-elements.
254
254
pub styles : ElementStyles ,
255
255
256
256
/// The restyle damage, indicating what kind of layout changes are required
257
257
/// afte restyling.
258
- pub damage : RestyleDamage ,
258
+ pub damage : E :: RestyleDamage ,
259
259
260
260
/// The restyle hint, which indicates whether selectors need to be rematched
261
261
/// for this element, its children, and its descendants.
@@ -266,7 +266,14 @@ pub struct ElementData {
266
266
}
267
267
268
268
// There's one of these per rendered elements so it better be small.
269
- size_of_test ! ( ElementData , 24 ) ;
269
+ // mod element_data_test {
270
+ // use crate::dom::TRestyleDamage;
271
+ // use super::ElementData;
272
+ // #[derive(Debug, Copy, Clone, Default)]
273
+ // struct SizeOfRestyleDamage(u32);
274
+ // impl TRestyleDamage for SizeOfRestyleDamage {}
275
+ // size_of_test!(ElementData<SizeOfRestyleDamage>, 24);
276
+ // }
270
277
271
278
/// The kind of restyle that a single element should do.
272
279
#[ derive( Debug ) ]
@@ -282,11 +289,11 @@ pub enum RestyleKind {
282
289
CascadeOnly ,
283
290
}
284
291
285
- impl ElementData {
292
+ impl < E : TElement > ElementData < E > {
286
293
/// Invalidates style for this element, its descendants, and later siblings,
287
294
/// based on the snapshot of the element that we took when attributes or
288
295
/// state changed.
289
- pub fn invalidate_style_if_needed < ' a , E : TElement > (
296
+ pub fn invalidate_style_if_needed < ' a > (
290
297
& mut self ,
291
298
element : E ,
292
299
shared_context : & SharedStyleContext ,
@@ -389,8 +396,8 @@ impl ElementData {
389
396
return None ;
390
397
}
391
398
392
- let needs_to_match_self = hint. intersects ( RestyleHint :: RESTYLE_SELF ) ||
393
- ( hint. intersects ( RestyleHint :: RESTYLE_SELF_IF_PSEUDO ) && style. is_pseudo_style ( ) ) ;
399
+ let needs_to_match_self = hint. intersects ( RestyleHint :: RESTYLE_SELF )
400
+ || ( hint. intersects ( RestyleHint :: RESTYLE_SELF_IF_PSEUDO ) && style. is_pseudo_style ( ) ) ;
394
401
if needs_to_match_self {
395
402
return Some ( RestyleKind :: MatchAndCascade ) ;
396
403
}
@@ -405,9 +412,9 @@ impl ElementData {
405
412
) ) ;
406
413
}
407
414
408
- let needs_to_recascade_self = hint. intersects ( RestyleHint :: RECASCADE_SELF ) ||
409
- ( hint. intersects ( RestyleHint :: RECASCADE_SELF_IF_INHERIT_RESET_STYLE ) &&
410
- style
415
+ let needs_to_recascade_self = hint. intersects ( RestyleHint :: RECASCADE_SELF )
416
+ || ( hint. intersects ( RestyleHint :: RECASCADE_SELF_IF_INHERIT_RESET_STYLE )
417
+ && style
411
418
. flags
412
419
. contains ( ComputedValueFlags :: INHERITS_RESET_STYLE ) ) ;
413
420
if needs_to_recascade_self {
@@ -447,9 +454,9 @@ impl ElementData {
447
454
) ) ;
448
455
}
449
456
450
- let needs_to_recascade_self = hint. intersects ( RestyleHint :: RECASCADE_SELF ) ||
451
- ( hint. intersects ( RestyleHint :: RECASCADE_SELF_IF_INHERIT_RESET_STYLE ) &&
452
- style
457
+ let needs_to_recascade_self = hint. intersects ( RestyleHint :: RECASCADE_SELF )
458
+ || ( hint. intersects ( RestyleHint :: RECASCADE_SELF_IF_INHERIT_RESET_STYLE )
459
+ && style
453
460
. flags
454
461
. contains ( ComputedValueFlags :: INHERITS_RESET_STYLE ) ) ;
455
462
if needs_to_recascade_self {
@@ -471,7 +478,7 @@ impl ElementData {
471
478
/// Drops restyle flags and damage from the element.
472
479
#[ inline]
473
480
pub fn clear_restyle_flags_and_damage ( & mut self ) {
474
- self . damage = RestyleDamage :: empty ( ) ;
481
+ self . damage . clear ( ) ;
475
482
self . flags . remove ( ElementDataFlags :: WAS_RESTYLED ) ;
476
483
}
477
484
@@ -521,8 +528,8 @@ impl ElementData {
521
528
/// we need for style sharing, the latter does not.
522
529
pub fn safe_for_cousin_sharing ( & self ) -> bool {
523
530
if self . flags . intersects (
524
- ElementDataFlags :: TRAVERSED_WITHOUT_STYLING |
525
- ElementDataFlags :: PRIMARY_STYLE_REUSED_VIA_RULE_NODE ,
531
+ ElementDataFlags :: TRAVERSED_WITHOUT_STYLING
532
+ | ElementDataFlags :: PRIMARY_STYLE_REUSED_VIA_RULE_NODE ,
526
533
) {
527
534
return false ;
528
535
}
0 commit comments