Struct style::values::computed::Context

source ·
pub struct Context<'a> {
    pub builder: StyleBuilder<'a>,
    pub cached_system_font: Option<()>,
    pub in_media_query: bool,
    pub in_container_query: bool,
    pub quirks_mode: QuirksMode,
    pub for_smil_animation: bool,
    pub container_info: Option<ContainerInfo>,
    pub for_non_inherited_property: bool,
    pub rule_cache_conditions: RefCell<&'a mut RuleCacheConditions>,
    container_size_query: RefCell<ContainerSizeQuery<'a>>,
}
Expand description

A Context is all the data a specified value could ever need to compute itself and be transformed to a computed value.

Fields§

§builder: StyleBuilder<'a>

Values accessed through this need to be in the properties “computed early”: color, text-decoration, font-size, display, position, float, border-*-style, outline-style, font-family, writing-mode…

§cached_system_font: Option<()>

A dummy option for servo so initializing a computed::Context isn’t painful.

TODO(emilio): Make constructors for Context, and drop this.

§in_media_query: bool

Whether or not we are computing the media list in a media query.

§in_container_query: bool

Whether or not we are computing the container query condition.

§quirks_mode: QuirksMode

The quirks mode of this context.

§for_smil_animation: bool

Whether this computation is being done for a SMIL animation.

This is used to allow certain properties to generate out-of-range values, which SMIL allows.

§container_info: Option<ContainerInfo>

Returns the container information to evaluate a given container query.

§for_non_inherited_property: bool

Whether we’re computing a value for a non-inherited property. False if we are computed a value for an inherited property or not computing for a property at all (e.g. in a media query evaluation).

§rule_cache_conditions: RefCell<&'a mut RuleCacheConditions>

The conditions to cache a rule node on the rule cache.

FIXME(emilio): Drop the refcell.

§container_size_query: RefCell<ContainerSizeQuery<'a>>

Container size query for this context.

Implementations§

source§

impl<'a> Context<'a>

source

pub fn get_container_size_query(&self) -> ContainerSizeQueryResult

Lazily evaluate the container size query, returning the result.

source

pub fn for_media_query_evaluation<F, R>( device: &Device, quirks_mode: QuirksMode, f: F, ) -> R
where F: FnOnce(&Context<'_>) -> R,

Creates a suitable context for media query evaluation, in which font-relative units compute against the system_font, and executes f with it.

source

pub fn for_container_query_evaluation<F, R>( device: &Device, stylist: Option<&Stylist>, container_info_and_style: Option<(ContainerInfo, Arc<ComputedValues>)>, container_size_query: ContainerSizeQuery<'_>, f: F, ) -> R
where F: FnOnce(&Context<'_>) -> R,

Creates a suitable context for container query evaluation for the style specified.

source

pub fn new( builder: StyleBuilder<'a>, quirks_mode: QuirksMode, rule_cache_conditions: &'a mut RuleCacheConditions, container_size_query: ContainerSizeQuery<'a>, ) -> Self

Creates a context suitable for more general cases.

source

pub fn new_for_animation( builder: StyleBuilder<'a>, for_smil_animation: bool, quirks_mode: QuirksMode, rule_cache_conditions: &'a mut RuleCacheConditions, container_size_query: ContainerSizeQuery<'a>, ) -> Self

Creates a context suitable for computing animations.

source

pub fn new_for_initial_at_property_value( stylist: &'a Stylist, rule_cache_conditions: &'a mut RuleCacheConditions, ) -> Self

Creates a context suitable for computing the initial value of @property.

source

pub fn device(&self) -> &Device

The current device.

source

pub fn inherited_custom_properties(&self) -> &ComputedCustomProperties

Get the inherited custom properties map.

source

pub fn is_root_element(&self) -> bool

Whether the style is for the root element.

source

pub fn query_font_metrics( &self, base_size: FontBaseSize, orientation: FontMetricsOrientation, retrieve_math_scales: bool, ) -> FontMetrics

Queries font metrics.

source

pub fn viewport_size_for_viewport_unit_resolution( &self, variant: ViewportVariant, ) -> Size2D<Au>

The current viewport size, used to resolve viewport units.

source

pub fn in_media_or_container_query(&self) -> bool

Whether we’re in a media or container query.

source

pub fn default_style(&self) -> &ComputedValues

The default computed style we’re getting our reset style from.

source

pub fn style(&self) -> &StyleBuilder<'_>

The current style.

source

pub fn maybe_zoom_text(&self, size: CSSPixelLength) -> CSSPixelLength

(Servo doesn’t do text-zoom)

Auto Trait Implementations§

§

impl<'a> !Freeze for Context<'a>

§

impl<'a> !RefUnwindSafe for Context<'a>

§

impl<'a> !Send for Context<'a>

§

impl<'a> !Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> !UnwindSafe for Context<'a>

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