Skip to content

Commit

Permalink
Upgrade Stylo to 2024-01-16 (#32066)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loirooriol committed Apr 13, 2024
1 parent 93bb276 commit a5e9752
Show file tree
Hide file tree
Showing 66 changed files with 104 additions and 9,369 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Expand Up @@ -64,7 +64,7 @@ keyboard-types = "0.6"
lazy_static = "1.4"
libc = "0.2"
log = "0.4"
malloc_size_of = { git = "https://github.com/servo/stylo", branch = "2023-12-01", features = ["servo"] }
malloc_size_of = { git = "https://github.com/servo/stylo", branch = "2024-01-16", features = ["servo"] }
malloc_size_of_derive = "0.1"
mime = "0.3.13"
mime_guess = "2.0.3"
Expand All @@ -87,31 +87,31 @@ rustls = { version = "0.21.10", features = ["dangerous_configuration"] }
rustls-pemfile = "1.0.4"
script_layout_interface = { path = "components/shared/script_layout" }
script_traits = { path = "components/shared/script" }
selectors = { git = "https://github.com/servo/stylo", branch = "2023-12-01" }
selectors = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
serde = "1.0.197"
serde_bytes = "0.11"
serde_json = "1.0"
servo-media = { git = "https://github.com/servo/media" }
servo-media-dummy = { git = "https://github.com/servo/media" }
servo-media-gstreamer = { git = "https://github.com/servo/media" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2023-12-01" }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2023-12-01" }
size_of_test = { git = "https://github.com/servo/stylo", branch = "2023-12-01" }
servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
size_of_test = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
smallbitvec = "2.5.3"
smallvec = "1.13"
sparkle = "0.1.26"
string_cache = "0.8"
string_cache_codegen = "0.5"
style = { git = "https://github.com/servo/stylo", branch = "2023-12-01", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2023-12-01" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2023-12-01", features = ["servo"] }
style = { git = "https://github.com/servo/stylo", branch = "2024-01-16", features = ["servo"] }
style_config = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2024-01-16", features = ["servo"] }
# NOTE: the sm-angle feature only enables ANGLE on Windows, not other platforms!
surfman = { version = "0.9", features = ["chains", "sm-angle", "sm-angle-default"] }
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
synstructure = "0.13"
thin-vec = "0.2.13"
time = "0.1.41"
to_shmem = { git = "https://github.com/servo/stylo", branch = "2023-12-01" }
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-01-16" }
tokio = "1"
tokio-rustls = "0.24"
tungstenite = "0.20"
Expand Down
26 changes: 17 additions & 9 deletions components/layout/query.rs
Expand Up @@ -637,7 +637,7 @@ fn create_font_declaration(
let mut declarations = SourcePropertyDeclaration::default();
let result = parse_one_declaration_into(
&mut declarations,
PropertyId::Shorthand(ShorthandId::Font),
PropertyId::NonCustom(ShorthandId::Font.into()),
value,
Origin::Author,
&UrlExtraData(url_data.get_arc()),
Expand Down Expand Up @@ -766,10 +766,14 @@ pub fn process_resolved_style_request<'dom>(
);
let style = styles.primary();
let longhand_id = match *property {
PropertyId::LonghandAlias(id, _) | PropertyId::Longhand(id) => id,
// Firefox returns blank strings for the computed value of shorthands,
// so this should be web-compatible.
PropertyId::ShorthandAlias(..) | PropertyId::Shorthand(_) => return String::new(),
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::Custom(ref name) => {
return style.computed_value_to_string(PropertyDeclarationId::Custom(name));
},
Expand Down Expand Up @@ -811,10 +815,14 @@ fn process_resolved_style_request_internal<'dom>(

let style = &*layout_el.resolved_style();
let longhand_id = match *property {
PropertyId::LonghandAlias(id, _) | PropertyId::Longhand(id) => id,
// Firefox returns blank strings for the computed value of shorthands,
// so this should be web-compatible.
PropertyId::ShorthandAlias(..) | PropertyId::Shorthand(_) => return String::new(),
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::Custom(ref name) => {
return style.computed_value_to_string(PropertyDeclarationId::Custom(name));
},
Expand Down
14 changes: 7 additions & 7 deletions components/layout_2020/query.rs
Expand Up @@ -127,9 +127,9 @@ pub fn process_resolved_style_request<'dom>(

let style = &*layout_element.resolved_style();
let longhand_id = match *property {
PropertyId::LonghandAlias(id, _) | PropertyId::Longhand(id) => id,
PropertyId::ShorthandAlias(id, _) | PropertyId::Shorthand(id) => {
return shorthand_to_css_string(id, style);
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));
Expand Down Expand Up @@ -263,9 +263,9 @@ pub fn process_resolved_style_request_for_unstyled_node<'dom>(
);
let style = styles.primary();
let longhand_id = match *property {
PropertyId::LonghandAlias(id, _) | PropertyId::Longhand(id) => id,
PropertyId::ShorthandAlias(id, _) | PropertyId::Shorthand(id) => {
return shorthand_to_css_string(id, style);
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));
Expand Down Expand Up @@ -528,7 +528,7 @@ where
let mut declarations = SourcePropertyDeclaration::default();
let result = parse_one_declaration_into(
&mut declarations,
PropertyId::Shorthand(ShorthandId::Font),
PropertyId::NonCustom(ShorthandId::Font.into()),
value,
Origin::Author,
&UrlExtraData(url_data.get_arc()),
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/cssrule.rs
Expand Up @@ -116,6 +116,7 @@ impl CSSRule {
},
StyleCssRule::FontPaletteValues(_) => unimplemented!(), // TODO
StyleCssRule::Property(_) => unimplemented!(), // TODO
StyleCssRule::Margin(_) => unimplemented!(), // TODO
}
}

Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/cssstyledeclaration.rs
Expand Up @@ -349,10 +349,10 @@ lazy_static! {
// The 'all' shorthand contains all the enabled longhands with 2 exceptions:
// 'direction' and 'unicode-bidi', so these must be added afterward.
let mut enabled_longhands: Vec<LonghandId> = ShorthandId::All.longhands().collect();
if PropertyId::Longhand(LonghandId::Direction).enabled_for_all_content() {
if PropertyId::NonCustom(LonghandId::Direction.into()).enabled_for_all_content() {
enabled_longhands.push(LonghandId::Direction);
}
if PropertyId::Longhand(LonghandId::UnicodeBidi).enabled_for_all_content() {
if PropertyId::NonCustom(LonghandId::UnicodeBidi.into()).enabled_for_all_content() {
enabled_longhands.push(LonghandId::UnicodeBidi);
}

Expand Down Expand Up @@ -459,13 +459,13 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {

// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn CssFloat(&self) -> DOMString {
self.get_property_value(PropertyId::Longhand(LonghandId::Float))
self.get_property_value(PropertyId::NonCustom(LonghandId::Float.into()))
}

// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
fn SetCssFloat(&self, value: DOMString) -> ErrorResult {
self.set_property(
PropertyId::Longhand(LonghandId::Float),
PropertyId::NonCustom(LonghandId::Float.into()),
value,
DOMString::new(),
)
Expand Down
15 changes: 9 additions & 6 deletions tests/unit/style/custom_properties.rs
Expand Up @@ -4,10 +4,12 @@

use cssparser::{Parser, ParserInput};
use euclid::{Scale, Size2D};
use servo_arc::Arc;
use style::applicable_declarations::CascadePriority;
use style::context::QuirksMode;
use style::custom_properties::{
ComputedCustomProperties, CustomPropertiesBuilder, Name, SpecifiedValue,
ComputedCustomProperties, CustomPropertiesBuilder, DeferFontRelativeCustomPropertyResolution,
Name, SpecifiedValue,
};
use style::font_metrics::FontMetrics;
use style::media_queries::{Device, MediaType};
Expand Down Expand Up @@ -51,9 +53,9 @@ fn cascade(
let mut input = ParserInput::new(value);
let mut parser = Parser::new(&mut input);
let name = Name::from(name);
let value = CustomDeclarationValue::Value(
let value = CustomDeclarationValue::Value(Arc::new(
SpecifiedValue::parse(&mut parser, &dummy_url_data).unwrap(),
);
));
CustomDeclaration { name, value }
})
.collect::<Vec<_>>();
Expand All @@ -69,13 +71,13 @@ fn cascade(
let mut builder = StyleBuilder::new(stylist.device(), Some(&stylist), None, None, None, false);
builder.custom_properties = inherited.clone();
let mut rule_cache_conditions = RuleCacheConditions::default();
let context = Context::new(
let mut context = Context::new(
builder,
stylist.quirks_mode(),
&mut rule_cache_conditions,
ContainerSizeQuery::none(),
);
let mut builder = CustomPropertiesBuilder::new(&stylist, &context);
let mut builder = CustomPropertiesBuilder::new(&stylist, &mut context);

for declaration in &declarations {
builder.cascade(
Expand All @@ -84,7 +86,8 @@ fn cascade(
);
}

builder.build()
builder.build(DeferFontRelativeCustomPropertyResolution::No);
context.builder.custom_properties
}

#[bench]
Expand Down
Expand Up @@ -172,30 +172,3 @@

[Property color value 'color(display-p3 184 1.00001 2347329746587)' [Display P3 color with component > 1 should not clamp\]]
expected: FAIL

[Property color value 'color(srgb calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(srgb-linear calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(a98-rgb calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(rec2020 calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(prophoto-rgb calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(display-p3 calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(xyz calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(xyz-d50 calc(NaN) 0 0)']
expected: FAIL

[Property color value 'color(xyz-d65 calc(NaN) 0 0)']
expected: FAIL
Expand Up @@ -97,15 +97,3 @@

[Property color value 'oklab(20% 0 0.1/0.5)']
expected: FAIL

[Property color value 'lab(calc(NaN) 0 0)']
expected: FAIL

[Property color value 'oklab(calc(NaN) 0 0)']
expected: FAIL

[Property color value 'lch(calc(NaN) 0 0)']
expected: FAIL

[Property color value 'oklch(calc(NaN) 0 0)']
expected: FAIL

0 comments on commit a5e9752

Please sign in to comment.