Convert the "computed value" field from spec into a DeclarationMetadata attribute
(computed_value: &str)
| 363 | |
| 364 | /// Convert the "computed value" field from spec into a DeclarationMetadata attribute |
| 365 | fn convert_computed_value(computed_value: &str) -> Option<TokenStream> { |
| 366 | let normalized = computed_value.replace('\n', " ").to_lowercase(); |
| 367 | let result = match normalized.as_str() { |
| 368 | s if s.contains("as specified") && s.contains("absolute length") => { |
| 369 | quote! { computed_value_type = SpecifiedWithAbsoluteLengths } |
| 370 | } |
| 371 | s if s.contains("as specified") && s.contains("absolute") && s.contains("url") => { |
| 372 | quote! { computed_value_type = SpecifiedWithAbsoluteUrls } |
| 373 | } |
| 374 | s if s.starts_with("as specified") || s == "specified value" => { |
| 375 | quote! { computed_value_type = AsSpecified } |
| 376 | } |
| 377 | s if s.contains("absolute length") && s.contains("percentage") => { |
| 378 | quote! { computed_value_type = AbsoluteLengthOrPercentage } |
| 379 | } |
| 380 | s if s.contains("absolute length") && s.contains("none") => { |
| 381 | quote! { computed_value_type = AbsoluteLengthOrNone } |
| 382 | } |
| 383 | s if s.contains("absolute length") && (s.contains("keyword") || s.contains("specified")) => { |
| 384 | quote! { computed_value_type = SpecifiedKeywordPlusAbsoluteLength } |
| 385 | } |
| 386 | s if s.contains("two absolute length") => { |
| 387 | quote! { computed_value_type = TwoAbsoluteLengths } |
| 388 | } |
| 389 | s if s.contains("list") && s.contains("absolute length") => { |
| 390 | quote! { computed_value_type = ListOfAbsoluteLengths } |
| 391 | } |
| 392 | s if s.contains("absolute length") => { |
| 393 | quote! { computed_value_type = AbsoluteLength } |
| 394 | } |
| 395 | _ => { |
| 396 | quote! { computed_value_type = Unknown } |
| 397 | } |
| 398 | }; |
| 399 | Some(result) |
| 400 | } |
| 401 | |
| 402 | /// Convert a spec name (e.g., "css-align", "filter-effects") to a PropertyGroup variant (e.g., "Align", "FilterEffects") |
| 403 | fn spec_name_to_property_group(spec_name: &str) -> syn::Ident { |
no test coverage detected