pub struct PropertyDeclarationBlock {
declarations: Vec<PropertyDeclaration>,
declarations_importance: SmallBitVec,
longhands: LonghandIdSet,
}
Expand description
Overridden declarations are skipped.
Fields§
§declarations: Vec<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
.
longhands: LonghandIdSet
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>,
default_values: &'a ComputedValues,
extra_custom_properties: Option<&'a Arc<CustomPropertiesMap>>
) -> AnimationValueIterator<'a, 'cx, 'cx_a> ⓘ
pub fn to_animation_value_iter<'a, 'cx, 'cx_a: 'cx>(
&'a self,
context: &'cx mut Context<'cx_a>,
default_values: &'a ComputedValues,
extra_custom_properties: Option<&'a Arc<CustomPropertiesMap>>
) -> 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 contains(&self, id: LonghandId) -> bool
pub fn contains(&self, id: LonghandId) -> bool
Returns whether this block contains a declaration of a given longhand.
sourcepub fn contains_any_reset(&self) -> bool
pub fn contains_any_reset(&self) -> bool
Returns whether this block contains any reset longhand.
sourcepub fn longhands(&self) -> &LonghandIdSet
pub fn longhands(&self) -> &LonghandIdSet
Returns a LonghandIdSet
representing the properties that are changed in
this block.
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
sourcefn is_definitely_new(&self, decl: &PropertyDeclaration) -> bool
fn is_definitely_new(&self, decl: &PropertyDeclaration) -> bool
Returns whether the property is definitely new for this declaration block. It returns true when the declaration is a non-custom longhand and it doesn’t exist in the block, and returns false otherwise.
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>,
custom_properties_block: Option<&PropertyDeclarationBlock>,
device: &Device
) -> Result
pub fn single_value_to_css(
&self,
property: &PropertyId,
dest: &mut CssStringWriter,
computed_values: Option<&ComputedValues>,
custom_properties_block: Option<&PropertyDeclarationBlock>,
device: &Device
) -> 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 cascade_custom_properties_with_context(
&self,
context: &Context<'_>
) -> Option<Arc<CustomPropertiesMap>>
pub fn cascade_custom_properties_with_context(
&self,
context: &Context<'_>
) -> Option<Arc<CustomPropertiesMap>>
Returns a custom properties map which is the result of cascading custom properties in this declaration block along with context’s custom properties.
sourcefn cascade_custom_properties(
&self,
inherited_custom_properties: Option<&Arc<CustomPropertiesMap>>,
device: &Device
) -> Option<Arc<CustomPropertiesMap>>
fn cascade_custom_properties(
&self,
inherited_custom_properties: Option<&Arc<CustomPropertiesMap>>,
device: &Device
) -> Option<Arc<CustomPropertiesMap>>
Returns a custom properties map which is the result of cascading custom properties in this declaration block along with the given custom properties.
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 more