mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add an FFI which returns computed values for a given declaration block with/without parent_style. r?heycam
The function uses document's default computed values if the parent style is not specified.
This commit is contained in:
parent
39d3c22edc
commit
bd066af640
3 changed files with 52 additions and 1 deletions
|
@ -369,7 +369,7 @@ impl PropertyDeclarationBlock {
|
|||
return false
|
||||
}
|
||||
}
|
||||
self.declarations.iter().any(|&&(ref decl, _)|
|
||||
self.declarations.iter().any(|&(ref decl, _)|
|
||||
decl.id().is_or_is_longhand_of(property) &&
|
||||
decl.get_css_wide_keyword().is_some()
|
||||
)
|
||||
|
|
|
@ -854,6 +854,33 @@ impl Stylist {
|
|||
{
|
||||
self.dependencies.compute_hint(element, snapshot)
|
||||
}
|
||||
|
||||
/// Computes styles for a given declaration with parent_style.
|
||||
pub fn compute_for_declarations(&self,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: &Arc<ComputedValues>,
|
||||
declarations: Arc<Locked<PropertyDeclarationBlock>>)
|
||||
-> Arc<ComputedValues> {
|
||||
use font_metrics::get_metrics_provider_for_product;
|
||||
|
||||
let v = vec![
|
||||
ApplicableDeclarationBlock::from_declarations(declarations.clone(),
|
||||
CascadeLevel::StyleAttributeNormal)
|
||||
];
|
||||
let rule_node =
|
||||
self.rule_tree.insert_ordered_rules(v.into_iter().map(|a| (a.source, a.level)));
|
||||
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
Arc::new(properties::cascade(&self.device,
|
||||
&rule_node,
|
||||
guards,
|
||||
Some(parent_style),
|
||||
Some(parent_style),
|
||||
None,
|
||||
&StdoutErrorReporter,
|
||||
&metrics,
|
||||
CascadeFlags::empty()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Stylist {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue