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

source

pub fn len(&self) -> usize

Returns the number of declarations in the block.

source

pub fn is_empty(&self) -> bool

Returns whether the block is empty.

source

pub fn new() -> Self

Create an empty block

source

pub fn with_one( declaration: PropertyDeclaration, importance: Importance ) -> Self

Create a block with a single declaration

source

pub fn declarations(&self) -> &[PropertyDeclaration]

The declarations in this block

source

pub fn declarations_importance(&self) -> &SmallBitVec

The important flags for declarations in this block

source

pub fn declaration_importance_iter(&self) -> DeclarationImportanceIterator<'_>

Iterate over (PropertyDeclaration, Importance) pairs

source

pub fn normal_declaration_iter<'a>( &'a self ) -> impl DoubleEndedIterator<Item = &'a PropertyDeclaration>

Iterate over PropertyDeclaration for Importance::Normal

source

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).

source

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.

source

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.

source

pub fn longhands(&self) -> &LonghandIdSet

Returns a LonghandIdSet representing the properties that are changed in this block.

source

pub fn contains(&self, id: PropertyDeclarationId<'_>) -> bool

Returns whether this block contains a declaration of a given property id.

source

pub fn contains_any_reset(&self) -> bool

Returns whether this block contains any reset longhand.

source

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.

source

pub fn shorthand_to_css( &self, shorthand: ShorthandId, dest: &mut CssStringWriter ) -> Result

Tries to serialize a given shorthand from the declarations in this block.

source

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

source

pub fn property_priority(&self, property: &PropertyId) -> Importance

source

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.

source

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.

source

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.

source

pub fn update( &mut self, drain: SourcePropertyDeclarationDrain<'_>, importance: Importance, updates: &mut SourcePropertyDeclarationUpdate )

Update this declaration block with the given data.

source

pub fn first_declaration_to_remove( &self, property: &PropertyId ) -> Option<usize>

Returns the first declaration that would be removed by removing property.

source

fn remove_declaration_at(&mut self, i: usize)

Removes a given declaration at a given index.

source

pub fn clear(&mut self)

Clears all the declarations from this block.

source

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.

source

pub fn single_value_to_css( &self, property: &PropertyId, dest: &mut CssStringWriter, computed_values: Option<&ComputedValues>, custom_properties_block: Option<&PropertyDeclarationBlock>, stylist: &Stylist ) -> Result

Take a declaration block known to contain a single property and serialize it.

source

pub fn from_animation_value_map(animation_value_map: &AnimationValueMap) -> Self

Convert AnimationValueMap to PropertyDeclarationBlock.

source

pub fn has_css_wide_keyword(&self, property: &PropertyId) -> bool

Returns true if the declaration block has a CSSWideKeyword for the given property.

source

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.

source

fn cascade_custom_properties( &self, inherited_custom_properties: Option<&Arc<CustomPropertiesMap>>, stylist: &Stylist ) -> 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.

source

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

source§

fn clone(&self) -> PropertyDeclarationBlock

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PropertyDeclarationBlock

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PropertyDeclarationBlock

source§

fn default() -> PropertyDeclarationBlock

Returns the “default value” for a type. Read more
source§

impl ToShmem for PropertyDeclarationBlock

source§

fn to_shmem(&self, builder: &mut SharedMemoryBuilder) -> Result<Self>

Clones this value into a form suitable for writing into a SharedMemoryBuilder. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> MaybeBoxed<Box<T, Global>> for T

source§

fn maybe_boxed(self) -> Box<T, Global>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Erased for T