Bug 1790652 - Split in_media_query and in_container_query bits from computed::Context. r=dshin

No behavior change, but it makes more sense this way :)

Differential Revision: https://phabricator.services.mozilla.com/D159851
This commit is contained in:
Emilio Cobos Álvarez 2022-10-20 14:24:36 +00:00
parent 32728dff0f
commit 9f9bdc7ccb
2 changed files with 16 additions and 4 deletions

View File

@ -166,9 +166,12 @@ pub struct Context<'a> {
#[cfg(feature = "servo")]
pub cached_system_font: Option<()>,
/// Whether or not we are computing the media list in a media query
/// Whether or not we are computing the media list in a media query.
pub in_media_query: bool,
/// Whether or not we are computing the container query condition.
pub in_container_query: bool,
/// The quirks mode of this context.
pub quirks_mode: QuirksMode,
@ -215,6 +218,7 @@ impl<'a> Context<'a> {
builder: StyleBuilder::for_inheritance(device, None, None),
cached_system_font: None,
in_media_query: true,
in_container_query: true,
quirks_mode,
for_smil_animation: false,
container_info: None,
@ -248,7 +252,8 @@ impl<'a> Context<'a> {
let context = Context {
builder: StyleBuilder::for_inheritance(device, style, None),
cached_system_font: None,
in_media_query: true,
in_media_query: false,
in_container_query: true,
quirks_mode,
for_smil_animation: false,
container_info,
@ -271,6 +276,7 @@ impl<'a> Context<'a> {
builder,
cached_system_font: None,
in_media_query: false,
in_container_query: false,
quirks_mode,
container_info: None,
for_smil_animation: false,
@ -292,6 +298,7 @@ impl<'a> Context<'a> {
builder,
cached_system_font: None,
in_media_query: false,
in_container_query: false,
quirks_mode,
container_info: None,
for_smil_animation,
@ -344,7 +351,7 @@ impl<'a> Context<'a> {
vertical,
font,
size,
self.in_media_query,
self.in_media_or_container_query(),
retrieve_math_scales,
)
}
@ -359,6 +366,11 @@ impl<'a> Context<'a> {
.au_viewport_size_for_viewport_unit_resolution(variant)
}
/// Whether we're in a media or container query.
pub fn in_media_or_container_query(&self) -> bool {
self.in_media_query || self.in_container_query
}
/// The default computed style we're getting our reset style from.
pub fn default_style(&self) -> &ComputedValues {
self.builder.default_style()

View File

@ -264,7 +264,7 @@ impl FontRelativeLength {
// element, the rem units refer to the property's initial
// value.
//
let reference_size = if context.builder.is_root_element || context.in_media_query {
let reference_size = if context.builder.is_root_element || context.in_media_or_container_query() {
reference_font_size
} else {
context.device().root_font_size()