mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Introduce SourceSizeList.
MozReview-Commit-ID: 9QMF45VcBFB
This commit is contained in:
parent
001c50bcca
commit
3fa75bbdf6
5 changed files with 131 additions and 54 deletions
|
@ -7,7 +7,7 @@
|
|||
use {Atom, Namespace};
|
||||
use context::QuirksMode;
|
||||
use euclid::Size2D;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
use font_metrics::{FontMetricsProvider, get_metrics_provider_for_product};
|
||||
use media_queries::Device;
|
||||
#[cfg(feature = "gecko")]
|
||||
use properties;
|
||||
|
@ -136,6 +136,36 @@ pub struct Context<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
/// Creates a suitable context for media query evaluation, in which
|
||||
/// font-relative units compute against the system_font, and executes `f`
|
||||
/// with it.
|
||||
pub fn for_media_query_evaluation<F, R>(
|
||||
device: &Device,
|
||||
quirks_mode: QuirksMode,
|
||||
f: F,
|
||||
) -> R
|
||||
where
|
||||
F: FnOnce(&Context) -> R
|
||||
{
|
||||
let mut conditions = RuleCacheConditions::default();
|
||||
let default_values = device.default_computed_values();
|
||||
let provider = get_metrics_provider_for_product();
|
||||
|
||||
let context = Context {
|
||||
is_root_element: false,
|
||||
builder: StyleBuilder::for_derived_style(device, default_values, None, None),
|
||||
font_metrics_provider: &provider,
|
||||
cached_system_font: None,
|
||||
in_media_query: true,
|
||||
quirks_mode,
|
||||
for_smil_animation: false,
|
||||
for_non_inherited_property: None,
|
||||
rule_cache_conditions: RefCell::new(&mut conditions),
|
||||
};
|
||||
|
||||
f(&context)
|
||||
}
|
||||
|
||||
/// Whether the current element is the root element.
|
||||
pub fn is_root_element(&self) -> bool {
|
||||
self.is_root_element
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue