pub struct PropertyDeclarationBlock {
declarations: ThinVec<PropertyDeclaration>,
declarations_importance: SmallBitVec,
property_ids: PropertyDeclarationIdSet,
}
Expand description
Overridden declarations are skipped.
Fields§
§declarations: ThinVec<PropertyDeclaration>
The group of declarations, along with their importance.
Only deduplicated declarations appear here.
declarations_importance: SmallBitVec
The “important” flag for each declaration in declarations
.
property_ids: PropertyDeclarationIdSet
The set of properties that are present in the block.
Implementations§
source§impl PropertyDeclarationBlock
impl PropertyDeclarationBlock
sourcepub fn with_one(
declaration: PropertyDeclaration,
importance: Importance,
) -> Self
pub fn with_one( declaration: PropertyDeclaration, importance: Importance, ) -> Self
Create a block with a single declaration
sourcepub fn declarations(&self) -> &[PropertyDeclaration]
pub fn declarations(&self) -> &[PropertyDeclaration]
The declarations in this block
sourcepub fn declarations_importance(&self) -> &SmallBitVec
pub fn declarations_importance(&self) -> &SmallBitVec
The important
flags for declarations in this block
sourcepub fn declaration_importance_iter(&self) -> DeclarationImportanceIterator<'_> ⓘ
pub fn declaration_importance_iter(&self) -> DeclarationImportanceIterator<'_> ⓘ
Iterate over (PropertyDeclaration, Importance)
pairs
sourcepub fn normal_declaration_iter<'a>(
&'a self,
) -> impl DoubleEndedIterator<Item = &'a PropertyDeclaration>
pub fn normal_declaration_iter<'a>( &'a self, ) -> impl DoubleEndedIterator<Item = &'a PropertyDeclaration>
Iterate over PropertyDeclaration
for Importance::Normal
sourcepub fn to_animation_value_iter<'a, 'cx, 'cx_a: 'cx>(
&'a self,
context: &'cx mut Context<'cx_a>,
style: &'a ComputedValues,
default_values: &'a ComputedValues,
) -> AnimationValueIterator<'a, 'cx, 'cx_a> ⓘ
pub fn to_animation_value_iter<'a, 'cx, 'cx_a: 'cx>( &'a self, context: &'cx mut Context<'cx_a>, style: &'a ComputedValues, default_values: &'a ComputedValues, ) -> AnimationValueIterator<'a, 'cx, 'cx_a> ⓘ
Return an iterator of (AnimatableLonghand, AnimationValue).
sourcepub fn any_important(&self) -> bool
pub fn any_important(&self) -> bool
Returns whether this block contains any declaration with !important
.
This is based on the declarations_importance
bit-vector,
which should be maintained whenever declarations
is changed.
sourcepub fn any_normal(&self) -> bool
pub fn any_normal(&self) -> bool
Returns whether this block contains any declaration without !important
.
This is based on the declarations_importance
bit-vector,
which should be maintained whenever declarations
is changed.
sourcepub fn property_ids(&self) -> &PropertyDeclarationIdSet
pub fn property_ids(&self) -> &PropertyDeclarationIdSet
Returns a PropertyDeclarationIdSet
representing the properties that are changed in
this block.
sourcepub fn contains(&self, id: PropertyDeclarationId<'_>) -> bool
pub fn contains(&self, id: PropertyDeclarationId<'_>) -> bool
Returns whether this block contains a declaration of a given property id.
sourcepub fn contains_any_reset(&self) -> bool
pub fn contains_any_reset(&self) -> bool
Returns whether this block contains any reset longhand.
sourcepub fn get(
&self,
property: PropertyDeclarationId<'_>,
) -> Option<(&PropertyDeclaration, Importance)>
pub fn get( &self, property: PropertyDeclarationId<'_>, ) -> Option<(&PropertyDeclaration, Importance)>
Get a declaration for a given property.
NOTE: This is linear time in the case of custom properties or in the case the longhand is actually in the declaration block.
sourcepub fn shorthand_to_css(
&self,
shorthand: ShorthandId,
dest: &mut CssStringWriter,
) -> Result
pub fn shorthand_to_css( &self, shorthand: ShorthandId, dest: &mut CssStringWriter, ) -> Result
Tries to serialize a given shorthand from the declarations in this block.
sourcepub fn property_value_to_css(
&self,
property: &PropertyId,
dest: &mut CssStringWriter,
) -> Result
pub fn property_value_to_css( &self, property: &PropertyId, dest: &mut CssStringWriter, ) -> Result
Find the value of the given property in this block and serialize it
https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue
sourcepub fn property_priority(&self, property: &PropertyId) -> Importance
pub fn property_priority(&self, property: &PropertyId) -> Importance
sourcepub fn extend(
&mut self,
drain: SourcePropertyDeclarationDrain<'_>,
importance: Importance,
) -> bool
pub fn extend( &mut self, drain: SourcePropertyDeclarationDrain<'_>, importance: Importance, ) -> bool
Adds or overrides the declaration for a given property in this block.
See the documentation of push
to see what impact source
has when the
property is already there.
sourcepub fn push(
&mut self,
declaration: PropertyDeclaration,
importance: Importance,
) -> bool
pub fn push( &mut self, declaration: PropertyDeclaration, importance: Importance, ) -> bool
Adds or overrides the declaration for a given property in this block.
Returns whether the declaration has changed.
This is only used for parsing and internal use.
sourcepub fn prepare_for_update(
&self,
source_declarations: &SourcePropertyDeclaration,
importance: Importance,
updates: &mut SourcePropertyDeclarationUpdate,
) -> bool
pub fn prepare_for_update( &self, source_declarations: &SourcePropertyDeclaration, importance: Importance, updates: &mut SourcePropertyDeclarationUpdate, ) -> bool
Prepares updating this declaration block with the given
SourcePropertyDeclaration
and importance, and returns whether
there is something to update.
sourcepub fn update(
&mut self,
drain: SourcePropertyDeclarationDrain<'_>,
importance: Importance,
updates: &mut SourcePropertyDeclarationUpdate,
)
pub fn update( &mut self, drain: SourcePropertyDeclarationDrain<'_>, importance: Importance, updates: &mut SourcePropertyDeclarationUpdate, )
Update this declaration block with the given data.
sourcepub fn first_declaration_to_remove(
&self,
property: &PropertyId,
) -> Option<usize>
pub fn first_declaration_to_remove( &self, property: &PropertyId, ) -> Option<usize>
Returns the first declaration that would be removed by removing
property
.
sourcefn remove_declaration_at(&mut self, i: usize)
fn remove_declaration_at(&mut self, i: usize)
Removes a given declaration at a given index.
sourcepub fn remove_property(
&mut self,
property: &PropertyId,
first_declaration: usize,
)
pub fn remove_property( &mut self, property: &PropertyId, first_declaration: usize, )
https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
first_declaration
needs to be the result of
first_declaration_to_remove
.
sourcepub fn single_value_to_css(
&self,
property: &PropertyId,
dest: &mut CssStringWriter,
computed_values: Option<&ComputedValues>,
stylist: &Stylist,
) -> Result
pub fn single_value_to_css( &self, property: &PropertyId, dest: &mut CssStringWriter, computed_values: Option<&ComputedValues>, stylist: &Stylist, ) -> Result
Take a declaration block known to contain a single property and serialize it.
sourcepub fn from_animation_value_map(animation_value_map: &AnimationValueMap) -> Self
pub fn from_animation_value_map(animation_value_map: &AnimationValueMap) -> Self
Convert AnimationValueMap to PropertyDeclarationBlock.
sourcepub fn has_css_wide_keyword(&self, property: &PropertyId) -> bool
pub fn has_css_wide_keyword(&self, property: &PropertyId) -> bool
Returns true if the declaration block has a CSSWideKeyword for the given property.
sourcepub fn to_css(&self, dest: &mut CssStringWriter) -> Result
pub fn to_css(&self, dest: &mut CssStringWriter) -> Result
Like the method on ToCss, but without the type parameter to avoid accidentally monomorphizing this large function multiple times for different writers.
https://drafts.csswg.org/cssom/#serialize-a-css-declaration-block
Trait Implementations§
source§impl Clone for PropertyDeclarationBlock
impl Clone for PropertyDeclarationBlock
source§fn clone(&self) -> PropertyDeclarationBlock
fn clone(&self) -> PropertyDeclarationBlock
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PropertyDeclarationBlock
impl Debug for PropertyDeclarationBlock
source§impl Default for PropertyDeclarationBlock
impl Default for PropertyDeclarationBlock
source§fn default() -> PropertyDeclarationBlock
fn default() -> PropertyDeclarationBlock
source§impl ToShmem for PropertyDeclarationBlock
impl ToShmem for PropertyDeclarationBlock
Auto Trait Implementations§
impl Freeze for PropertyDeclarationBlock
impl RefUnwindSafe for PropertyDeclarationBlock
impl Send for PropertyDeclarationBlock
impl Sync for PropertyDeclarationBlock
impl Unpin for PropertyDeclarationBlock
impl UnwindSafe for PropertyDeclarationBlock
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more