mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Let legacy layout serialize shorthands in getComputedStyle (#32149)
* Let legacy layout serialize shorthands in getComputedStyle This ports #31277 (with the changes from #32066) into legacy layout. Otherwise, turning white-space into a shorthand (#32146) would fail some tests that expect the property to be serializable. * Update text expecatations
This commit is contained in:
parent
1a0565bbec
commit
fdb6fb7920
59 changed files with 270 additions and 1920 deletions
|
@ -766,13 +766,9 @@ pub fn process_resolved_style_request<'dom>(
|
|||
);
|
||||
let style = styles.primary();
|
||||
let longhand_id = match *property {
|
||||
PropertyId::NonCustom(id) => {
|
||||
match id.unaliased().as_longhand() {
|
||||
Some(id) => id,
|
||||
// Firefox returns blank strings for the computed value of shorthands,
|
||||
// so this should be web-compatible.
|
||||
None => return String::new(),
|
||||
}
|
||||
PropertyId::NonCustom(id) => match id.longhand_or_shorthand() {
|
||||
Ok(longhand_id) => longhand_id,
|
||||
Err(shorthand_id) => return shorthand_to_css_string(shorthand_id, style),
|
||||
},
|
||||
PropertyId::Custom(ref name) => {
|
||||
return style.computed_value_to_string(PropertyDeclarationId::Custom(name));
|
||||
|
@ -815,13 +811,9 @@ fn process_resolved_style_request_internal<'dom>(
|
|||
|
||||
let style = &*layout_el.resolved_style();
|
||||
let longhand_id = match *property {
|
||||
PropertyId::NonCustom(id) => {
|
||||
match id.unaliased().as_longhand() {
|
||||
Some(id) => id,
|
||||
// Firefox returns blank strings for the computed value of shorthands,
|
||||
// so this should be web-compatible.
|
||||
None => return String::new(),
|
||||
}
|
||||
PropertyId::NonCustom(id) => match id.longhand_or_shorthand() {
|
||||
Ok(longhand_id) => longhand_id,
|
||||
Err(shorthand_id) => return shorthand_to_css_string(shorthand_id, style),
|
||||
},
|
||||
PropertyId::Custom(ref name) => {
|
||||
return style.computed_value_to_string(PropertyDeclarationId::Custom(name));
|
||||
|
@ -934,6 +926,25 @@ fn process_resolved_style_request_internal<'dom>(
|
|||
}
|
||||
}
|
||||
|
||||
fn shorthand_to_css_string(
|
||||
id: style::properties::ShorthandId,
|
||||
style: &style::properties::ComputedValues,
|
||||
) -> String {
|
||||
use style::values::resolved::Context;
|
||||
let mut block = PropertyDeclarationBlock::new();
|
||||
let mut dest = String::new();
|
||||
for longhand in id.longhands() {
|
||||
block.push(
|
||||
style.computed_or_resolved_declaration(longhand, Some(&Context { style })),
|
||||
Importance::Normal,
|
||||
);
|
||||
}
|
||||
match block.shorthand_to_css(id, &mut dest) {
|
||||
Ok(_) => dest.to_owned(),
|
||||
Err(_) => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process_offset_parent_query(
|
||||
requested_node: OpaqueNode,
|
||||
layout_root: &mut dyn Flow,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue