Skip to main content

PropertyDeclarationBlock

Struct PropertyDeclarationBlock 

Source
pub struct PropertyDeclarationBlock {
    declarations: ThinVec<PropertyDeclaration>,
    declarations_importance: SmallBitVec,
    property_ids: PropertyDeclarationIdSet,
    pub immutable: AtomicBool,
}
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.

§immutable: AtomicBool

Whether this declaration block may be mutated by CSSOM without copying. Set when a declaration is shared across elements and needs to be copied, even when not in the rule tree, e.g. via the style attribute or the XUL prototype caches.

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>, style: &'a ComputedValues, default_values: &'a ComputedValues, ) -> 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 property_ids(&self) -> &PropertyDeclarationIdSet

Returns a PropertyDeclarationIdSet 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 property_value_to_typed_value_list( &self, property: &PropertyId, ) -> Result<Option<TypedValueList>, ()>

Find the value of the given property in this block and reify it. Returns Err(()) if the property is not present in this declaration block.

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>, 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 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) -> Self

Returns a duplicate 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 PartialEq for PropertyDeclarationBlock

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

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.
Source§

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> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T