mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add some wrapper types to propagate styles out of style resolver.
We'll use these next to propagate information about style reuse to the ElementDataFlags. MozReview-Commit-ID: Dya6vgzydpL
This commit is contained in:
parent
9092e6b4c2
commit
7a7070e075
5 changed files with 118 additions and 57 deletions
|
@ -17,7 +17,9 @@ use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage};
|
|||
use servo_arc::Arc;
|
||||
use shared_lock::StylesheetGuards;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use style_resolver::{PrimaryStyle, ResolvedElementStyles, ResolvedStyle};
|
||||
|
||||
bitflags! {
|
||||
#[derive(Default)]
|
||||
|
@ -264,6 +266,24 @@ impl ElementData {
|
|||
self.styles.primary.is_some()
|
||||
}
|
||||
|
||||
/// Returns this element's styles as resolved styles to use for sharing.
|
||||
pub fn share_styles(&self) -> ResolvedElementStyles {
|
||||
ResolvedElementStyles {
|
||||
primary: self.share_primary_style(),
|
||||
pseudos: self.styles.pseudos.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns this element's primary style as a resolved style to use for sharing.
|
||||
pub fn share_primary_style(&self) -> PrimaryStyle {
|
||||
PrimaryStyle(ResolvedStyle::new(self.styles.primary().clone()))
|
||||
}
|
||||
|
||||
/// Sets a new set of styles, returning the old ones.
|
||||
pub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles {
|
||||
mem::replace(&mut self.styles, new_styles.into())
|
||||
}
|
||||
|
||||
/// Returns the kind of restyling that we're going to need to do on this
|
||||
/// element, based of the stored restyle hint.
|
||||
pub fn restyle_kind(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue