style: Make media feature evaluation take a computed::Context

This has no behavior change right now, but will simplify sharing code
with container queries.

Container queries will have container information in the
computed::Context (this is necessary anyways for container-based units),
so this avoids having to have different code for media and container
queries.

Differential Revision: https://phabricator.services.mozilla.com/D144152
This commit is contained in:
Emilio Cobos Álvarez 2023-08-11 02:05:08 +02:00 committed by Martin Robinson
parent 6279504ddb
commit 8d8b5942be
6 changed files with 119 additions and 125 deletions

View file

@ -56,12 +56,12 @@ impl SourceSizeList {
/// Evaluate this <source-size-list> to get the final viewport length.
pub fn evaluate(&self, device: &Device, quirks_mode: QuirksMode) -> Au {
let matching_source_size = self
.source_sizes
.iter()
.find(|source_size| source_size.condition.matches(device, quirks_mode));
computed::Context::for_media_query_evaluation(device, quirks_mode, |context| {
let matching_source_size = self
.source_sizes
.iter()
.find(|source_size| source_size.condition.matches(context));
match matching_source_size {
Some(source_size) => source_size.value.to_computed_value(context),
None => match self.value {