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>
impl<'a> Context<'a>
sourcepub fn get_container_size_query(&self) -> ContainerSizeQueryResult
pub fn get_container_size_query(&self) -> ContainerSizeQueryResult
Lazily evaluate the container size query, returning the result.
sourcepub fn for_media_query_evaluation<F, R>(
device: &Device,
quirks_mode: QuirksMode,
f: F,
) -> R
pub fn for_media_query_evaluation<F, R>( device: &Device, quirks_mode: QuirksMode, f: F, ) -> R
Creates a suitable context for media query evaluation, in which
font-relative units compute against the system_font, and executes f
with it.
sourcepub 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
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
Creates a suitable context for container query evaluation for the style specified.
sourcepub fn new(
builder: StyleBuilder<'a>,
quirks_mode: QuirksMode,
rule_cache_conditions: &'a mut RuleCacheConditions,
container_size_query: ContainerSizeQuery<'a>,
) -> Self
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.
sourcepub 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
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.
sourcepub fn new_for_initial_at_property_value(
stylist: &'a Stylist,
rule_cache_conditions: &'a mut RuleCacheConditions,
) -> Self
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.
sourcepub fn inherited_custom_properties(&self) -> &ComputedCustomProperties
pub fn inherited_custom_properties(&self) -> &ComputedCustomProperties
Get the inherited custom properties map.
sourcepub fn is_root_element(&self) -> bool
pub fn is_root_element(&self) -> bool
Whether the style is for the root element.
sourcepub fn query_font_metrics(
&self,
base_size: FontBaseSize,
orientation: FontMetricsOrientation,
retrieve_math_scales: bool,
) -> FontMetrics
pub fn query_font_metrics( &self, base_size: FontBaseSize, orientation: FontMetricsOrientation, retrieve_math_scales: bool, ) -> FontMetrics
Queries font metrics.
sourcepub fn viewport_size_for_viewport_unit_resolution(
&self,
variant: ViewportVariant,
) -> Size2D<Au>
pub fn viewport_size_for_viewport_unit_resolution( &self, variant: ViewportVariant, ) -> Size2D<Au>
The current viewport size, used to resolve viewport units.
sourcepub fn in_media_or_container_query(&self) -> bool
pub fn in_media_or_container_query(&self) -> bool
Whether we’re in a media or container query.
sourcepub fn default_style(&self) -> &ComputedValues
pub fn default_style(&self) -> &ComputedValues
The default computed style we’re getting our reset style from.
sourcepub fn style(&self) -> &StyleBuilder<'_>
pub fn style(&self) -> &StyleBuilder<'_>
The current style.
sourcepub fn maybe_zoom_text(&self, size: CSSPixelLength) -> CSSPixelLength
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> 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> 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